-
-
Save gr2m/5463675 to your computer and use it in GitHub Desktop.
// purchase a product with a credit card | |
purchase('productId') | |
.using( { | |
cc: "4556934156210213", | |
valid: "2016-10", | |
csc: "123" | |
} ) | |
// purchase a product with paypal | |
purchase('productId') | |
.using( 'paypal' ) | |
// upgrade a user to a pro plan, payment via paypal. | |
purchase( | |
account.upgradoTo( 'pro' ) | |
).using('paypal') |
I think we can keep the CC option. Of course you as the app owner can decide not to use it, but technically I don't see a problem with it yet. Let's say for example you'd use stripe to recieve CC payments. If you'd run this code in your visitor's browser:
purchase('productId')
.using( {
cc: "4556934156210213",
valid: "2016-10",
cvc: "123"
} ).then( sayThankYou )
it would
- And order object with
product: "productId"
gets stored in the user's store. - The CC information gets sent right to Stripe's server.
- Stripe receives the payment, calls a URL that you configured
- Your app's backend receives the POST by Stripe, and markes the order object as successfully processed.
sayThankYou
callback gets executed.
This looks a lot like: http://simplecartjs.org/
Seems secure to me, just make sure the sensitive information is only stored transiently and always sent over HTTPS.
wow, simpleCart looks very nice indeed!
Bitcoin payments can be easily added with:
http://bitcore.io/playground/#/address and #/transaction
// ...
.using( 'bitcoin/bitcore' )
.payment_request({
address: "1address...",
amount: 10000, // satoshis
})
or some more sophisticated and complete example like:
// ...
.using(['bitcoin/bitcore', 'bitcoin/blockchain_info', 'bitcoin/blockr_io'])
.to({
address: "1address...",
amount: 10000, // satoshis
}).sign({
privateKey: "5pvtkey...." // signs the transaction, doesn't send the private key
}).propagate(['blockchain_info', 'blockr_io'])
super-alpha version, need to be discussed I think, also what about multisig? Anyway dreamcode ftw!
FYI, there's a standard for this now.
Although the API is a bit more complex.
@gr2m probably we will have to act something like paypal where the user pass to a secured page all the information and only there it will be asked to the user to provide his/her cc info.
So we can change it with something easier like:
purchase(arrayOfItems).with(paymentMethod);
where paymentMethod can be something like:
Then the app will route to the right secured page to proceed