How to retrieve a customer's payment history with Stripe? - reactjs

For my react app, I am using the Session object to handle purchases in Stripe, and I am using a Customer object if the user is logged in. I'm having trouble figuring if I'm supposed to use the Payment Intent, Charge, or Balance Transaction object to retrieve a customer's payment history (provided the customer id).
Any advice is appreciated!

You would use the List all PaymentIntents API to get a customer's payment history:
https://stripe.com/docs/api/payment_intents/list
https://stripe.com/docs/api/payment_intents/list#list_payment_intents-customer
By default this will return the last 10 payments that the customer made. But, you can increase that number to 100:
https://stripe.com/docs/api/payment_intents/list#list_payment_intents-limit
If you want to list more than the last 100 payments you would need to use the auto-pagination feature provided by Stripe's libraries:
https://stripe.com/docs/api/pagination/auto
Depending on what information you need to display in your app you could also use the List Charges API. But that resource is being phased out in favor of PaymentIntents so I would look to use PaymentIntents first. The Balance Transactions API is mainly useful for displaying changes to a given Stripe account's balance rather than a given customer's payment history (i.e., tracking all payments, transfers, payouts and refunds on the account as a whole).

Related

Stripe, how to retrieve payment history?

For my react app, I am using the Session object to handle purchases in Stripe, and I am using a Customer object if the user is logged in. I tried using Payment Intents, however it only gives me the total balance for each payment and not the actual items and their amounts that were purchased. I want to be able to retrieve the line_items a customer purchased in each payment (they're not Product objects if that helps).
Any help is appreciated!
You should retrieve the Session object, which does contain those.

Best way to skip a payment with Stripe Subscriptions (give a free month)?

I am looking to implement a referral program for our app that will gives users a free month off their subscription every time they have a successful referral.
I came across this question Stripe: add free days to a subscription but it is 6 years old so I am not sure if this is still the way to go since Stripe has updated their service and API multiple times since then.
Reading through the Stripe Docs it seems there may be 2 ways to implement:
Use a coupon and apply it against the customer's subscription. (Stripe Subscription Discounts)
Move the date for their billing cycle by 1 month (Stripe Subscription Billing Cycles)
I would imagine this is a common thing. Is there a best practice on how to proceed?
I ended up contacting Stripe customer support and option 1 is the way to go (coupons).
Basically you create a coupon that deducts 100% of the subscription fee and you enable it for 1 month only. This will effectively skip 1 month's payment. It can be enabled manually via the Stripe Dashboard or the API.
Follow this link for more details: Stripe Coupons

How to withdraw money (earnings) using PayPal/Transferwise/Bill.com/Payoneer in React (RCA) + Koa (Sequelize + PostrgeSQL)

I'm building a platform, where users would be able to withdraw their earnings using one of supported services: PayPal, Transferwise, Bill.com and Payoneer.
I haven't worked with money withdrawal before, so I'm a bit confused on how it should work (npm packages, what would be the process in the context of the client-server comunication, best practices, patterns/antipatterns etc.).
My current tech stack is React + Koa.js
I would be appreciated for any useful information.
Thanks in advance.
I've built something similar recently, and here are the steps I've followed:
Collect beneficiary details from the user
This could be their Paypal email, bank account details or something else depending on the payment provider. If you go with Paypal or Payoneer, you'll need to ask the user to sign up for an account if they don't already have one.
Validate that the information is in the correct format
Especially if you are collecting bank account details, doing a bit of validation up front could save you a lot of hassle later on.
Saving the information securely
If you are collecting bank details, you need to decide whether you want to store the bank details in your own system, or if you prefer to only store them with the payment provider.
Storing the data in your own system allows you to review the information before passing it on to your payment provider. However you will need to make sure the information is managed securely.
Setting up the payment
You now need to decide how you will initiate the payment. You could let the user request to be paid. You could also do the payments automatically based on some rules. E.g. weekly payments if amount is over a threshold. Whichever way you go, most providers give you the option to use their API or some file based system.
Funding the payments
This will depend on your provider. Some allow you to fund the payments over API using a prefunded balance. Others require you to do final approval inside their system.
React component for collecting bank details
I needed to collect bank details that work with TransferWise for my own project, so I built <BankDeets/>, a React component that's available on NPM. It supports 40+ currencies and collects all the data you need to make payments.
Example:
<BankDeets submitURL="bankdeets.co/save"/>
It's available via npm install bankdeets (or https://github.com/321k/bankdeets) and comes with validation and translations. I'm the creator, so please ping me any questions about it.

How to make payment to store business account byu paypal?

I am developing an mobile app where I present products (items) from different stores just like ebay.com. User can select product, can add to cart and then finally can make payment via paypal.
I have created an Paypal business account on sandbox. Currently all payment made by users are coming to this business account I mentioned in my code. But my requirement is different. I want that payment should go to store's (product owner's) account.
So I made changes so that whenever i make call to paypal I chnaged business account email to store owner email address and payment done successfully. :) Payment posted to store owner business.
I made changes only in paypal.recipient email address but still paypal object is created by my paypal application ID. This is what I am worried about. Does it will work on production mode? I really doubt that.
Please help me guys!!!
What API or service are you using to do this? Are you just using Website Payments Standard, Exprses Checkout, or one of the other API? You mentiioned application id, are you using Adaptive Payments? You could use Adative Payments to do what you are wanting to, if you are not already doing this. This would allow you to process payments and split it between different accounts. In your business model, it would allow you to split the payments between different store owners if the buyers checkout contained items from different merchants/stores.

Implement a paid subscription service on a website

I have a website and I would like to implement a paid subscription service. Its a simple service with only 2 types of plans. For now, ill just use Paypal. But im a little lost before start, mainly with the data model.
My main question for now is, what information do I need to keep for each subscription? Do I need to implement a shopping cart for this (dont think so)? Im not asking for a detailed explanation, just a few lights or resources to find a way to start. Thanks.
Depends on what technology you're using. Basic payments work a bit like this
-> You send them to paypal with a plan (you define the plan on paypal)
they know which amount to charge
you can pass custom parameters which they will pass back
Customer fills in application
<- paypal tells you that your predefined plan got purchased
in this same request, they send a lot of info about the payment including a GUID and your params
-> you ask paypal "hey, some one just told me this plan GUID got purchased, can you confirm"
<- paypal service returns 'yes'
-> you take the customer's ID from the params that you attached when you sent them to the paypal service and update them to "paid" in the database, or whatever
That's it in a nutshell...
Look at any subscription card mailer from any magazine and you can get an idea of what kind of data you will have to record. Start and end date for the subscription would be a good thing to keep, and what kind of plan the user is subscribed to. Once you have the end date, you just need to run a query to get the records of the users that have access. Something like
Select * from users where subscription_end_date is >= today
I'm sure there will be a lot of other columns that will go into your final product, but that will be up to you to decide what data you want to keep. What are the different states that a subscription can be in? Can someone be subscribed to both services at the same time?
PayPal does a decent job if you want to charge the same amount every month. However, if you anticipate your users making changes to their subscription plans (upgrades/downgrades) or needing to provide credits to their account for customer support purposes, PayPal would require that you cancel the subscription...and then have the customer re-subscribe.
[Full disclosure - I am a co-founder of Recurly.com]
Recurly handles the upgrades and downgrades, and provides automated customer emails to be sent out to your customers (on your behalf) for every event confirmation, and invoice that occurs. You also have a full account management dashboard and reporting so that you don't need to build this yourself.
Best of all, if you ever decide to leave PayPal, and move your business to a standalone payment gateway, Recurly stores all of your credit cards in a PCI compliant vault so you don't need to ask you customers to come back and re-subscribe. (PayPal will not return your customer credit card information). You simply configure your new gateway in Recurly, and payments will be processed without any interruption to your business.
Here is a blog post we wrote on the topic:
http://blog.recurly.com/2010/08/top-ten-reasons-to-use-recurly-vs-paypal-for-recurring-billing/
-Best of luck.
-Dan

Resources