Search code examples
node.jsmongodbencryptioncredit-cardpaypal-rest-sdk

Node.js and MongoDB making payments and storing credit card data


I'm very new to NodeJS and I am making an application that will need to accept payments. For example, a user will have to enter their payment info, but the payment will not go through until a later event happens (may be days). So, I need to save this information in my database (I'm using MongoDB) I am wondering what is the best way to do this. How should I go about encrypting the credit card info to store it in my db and also making the payments when the event occurs. I was looking at the PayPal REST SDK but I'm unsure if this is the best way to go. What are the best libraries to use?


Solution

  • I have a good experience with https://stripe.com. It has a great nodejs library. It works in the following way: Customer fulfill the card data. You send it to stripe. They provide you a token (saved customer id). You just store this token. It is totally safe, since you are not storing credit card details locally. Then, later, you charge "this token" in the way you want. Method like stripe.charge(client_token, summ, callback).

    In virtually same way works https://www.braintreepayments.com/. Braintree is paypal's daughter.