List all payment methods from customer - stripe-payments

I am using the Java client for Stripe on my backend.
At the moment I'd like to support credit cards and bank accounts (SEPA). A customer is able to add multiple credit cards of bank accounts if he wishes to.
If I got that right, what I want is to use the Sources API, which allows me to add differend types of payment methods.
However, I am not certain how to fetch alle created payment methods (sources) in one call.
Is this possible ?

You can retrieve a list of a specific customer's sources via the GET /v1/customers/{customer_id}/sources endpoint.

https://stripe.com/docs/api/payment_methods/list you can use a customer_id to list all the payment methods saved for a user, assuming you attached a customer_id to the user.

Related

Stripe Payment Links with Customer Id

I am currently building an application where we want to user Stripe Payment links rather then building our own version of UI to support the same functionality. However I notice that Stripe Payment Links create a new customer every single time. Is there a way to attach my customer id to the payment link so that a new customer is not created when they attempt to buy more then one product? I would prefer not to have to have a single user have multiple customer ids inside of my database.
Thanks!
Payment Links are not specific to a Customer record. The documentation does include examples of how you might append data to them to aid in reconciling payments to a specific individual.
If you want to make use of the Stripe hosted UI while still assigning specific Customer records then I would recommend making use of Stripe Checkout.

Can we covert the guest customer in stripe to real customer?

I have strange situation ... I want to convert my guest customers in my stripe account to the real customers ... Real customers have the customerID but the guest customer doesn’t have the customer ID ... Is there any way to convert them.
Guest customers are only available in Stripe Dashboard so there is not a way to manipulate them via the API and there is not an option to convert them to a customer object via the Dashboard.
The recommendation is to create real customers moving forward. Although there is not a way to associate previous payments to real customers, you’d be able to track payments that belong to the same customer and create recurring charges. To achieve this, you’d pass the customer object on the PaymentIntent creation or if you’re using Checkout, you’d pass it when creating the Checkout Session.

With Stripe, how to attach a single payment method created from Setup Intent API for multiple customers

With Stripe, how to use the payment method created from setup intent for multiple customers?
According tp the Create Setup Intent API, it only let us define one customer ID.
param name: customer (optional)
description of this param:
attached to the Customer on successful setup. Payment methods attached
to other Customers cannot be used with this SetupIntent.ID of the Customer this SetupIntent belongs to, ifone exists. If present, the SetupIntent’s payment method will be
TLDR
I want to let the same user to reuse same payment method to subscribe items with different presentment currencies,
I assume I should solve this requirement by directly creating multiple customer objects for a single user, and using create Setup Intent API to attach his/her same payment method for multiple "customer objects".
But, I am not sure if this is possible, therefore I welcome any recommendation for alternative approaches, such as using attach payment method to customers API, or any workarounds.
PS: Detail info (for why I am interested to ask this question)
Business requirement:
My business requirement is that customers have to subscribe to international services that must be presented with different presentment currencies. To makes thing even harder, each customer has to use the same list of saved payment methods to subscribe to services with different presentment currencies in the future. In other words, users should not have to re-enter card info again if they subscribe to items in different presentment currencies.
Limitation of the Stripe API:
Why not just use single customer object for subscribing to services (aka "price" objects) with multiple presentment currency?
I tried and it results in an error. According to this Stripe documentation, it indeed says that each customer can only be used for transactions in single currency.
If the user in my app want to subscribe to another service with another
currency, I need to create new "Customer" object in Stripe.
Why not just use /v1/payment_methods/:pm_id/attach api to attch payment method to multiple customer object?
Because according to this Attact payment method to customer API doc, Stripe does not recommend, yet I do not fully understand the risk of not performing any necessary steps as it warns. Therefore, it is just my risk averse instinct to avoid this.
To attach a new PaymentMethod to a customer for future payments, we
recommend you use a SetupIntent or a PaymentIntent with
setup_future_usage. These approaches will perform any necessary steps
to ensure that the PaymentMethod can be used in a future payment.
This is not supported. A payment method can only be consumed once if not attached, and attaching to a customer counts as a consumption. A PM can only be attached to a single customer, so you'll need to collect the payment details for each.
Stripe recommends using that customer's currency for all presentment to optimize for their experience, though that may not be suitable for all use cases.

How use different payment gateways based on credit card type on Spree?

I'm using activemerchant as a payment gateway plugin for Spree and I'm trying to use two different payment gateways (The implementation is the same but the credentials are different and they connect to different merchants) based on credit card type/brand? Is there a easy way to to this or where can I find the entrypoint method/class to add this logic?
I end up duplicating payment methods using different credentials and passing down the payments to front-end and redirect credit cards with specific companies to mapped payment methods.
1-Duplicate the payment method with different merchant credentials
2-Pass down the payment details in Rails views e.g. payment_methods: payment_methods in partial
3-Use erb evaluation to embed payment methods with their associated credit card companies e.g {stripe01: 1, stripe02: 2}
4-Check against credit card number which in this case is masked maskedCardInfo to get the company name
5-Return which payment method id is meant to be used for a specific credit card company
6-Replace form inputs/fields names before submit
DONE

Retrieve a list of supported countries from Stripe API?

I've read over Stripe's API and couldn't find a way to find if a country is supported by Stripe.
e.g: I have an user who is going to receive a payment and he is from a country, I need to check if he can use Stripe to receive this payment based on his country.
Thanks
Stripe's Country Specs API should do what you need:
https://stripe.com/docs/api#list_country_specs
Their documentation includes sample code and sample responses for multiple languages.
No such info as I know in api, but there are not so many countries they support at he moment to accept payments. https://support.stripe.com/questions/what-countries-does-stripe-support
So you can add them into a global variable to your app and update it whenever a new country will be in the list. A settings page in admin panel may be, so you can easily update the list.

Resources