Stripe recurring payments for 3DS source - stripe-payments

I want to use Stripe to charge cards recurrently every 30 days with amounts that oscilate.
From the docs I got that if there is a possibility that the card requires 3DS we should use Sources so I switched to sources ;)
From the source object stripe.js retrieves I look at three_d_secure param to decide whether to create a source object that requires 3DS or a normal card charging.
The flow:
With JS I get the source object that has three_d_secure set to either optional or required.
When it's set to optional after I retrieve the source with: source = Stripe::Source.retrieve(source_id) it looks like this:
"status": "chargeable",
"type": "card",
"usage": "reusable",
"card":{"exp_month":12,"exp_year":2032,"brand":"Visa",...
I attach it to a customer and charge it. I guess usage: reusable means that I can charge the card again later...
When three_d_secure=='required' I create a new source calling this:
source = Stripe::Source.create({
amount: amount,
currency: currency,
type: 'three_d_secure',
three_d_secure: {
card: source_id, #src_xcvxcvxcvc
},
redirect: {
return_url: return_url
},
})
I redirect the user to the URL Stripe provides, user enters his 3DS PIN and gets back to my return_url. When Stripe redirects the user back to my return_url I retrieve the source again and get something like this:
"status": "chargeable",
"type": "three_d_secure",
"usage": "single_use",
"three_d_secure": {"card":"src_1B1JzQHopXUl9h9Iwk05JV1z","authenticated":true,"customer":null}
I would expect that after passing the 3DS the source becomes reusable and chargeable until the date of expiry or so :|
My questions are:
1 Why is the 3DS source single_use? Is this like this only in sanbox environment or with the card I am using to test?
2 Can a 3DS protected card be charged again at all?
3 What's the correct approach to attach to customer sources (3DS or normal) that can be charged again and again?
Thank you!

Because it is a source payment token, not a source card token. It expires on a due date or when is consumed. You can use reusable token to create single_use tokens. reusable one represents a card source token
Yes if a 3ds is optional or not_supported, no if required. If required then every payement needs to fulfill a 3ds.
Steps:
Create an src_card_token for a card or use saved one (reusable)
Create an customer object with an src from src_card_token
Create an src_payment_token for a customer using one of his saved cards (as token)
fullfil a 3ds redirect process if required.
create a charge

Related

How to create a customer and add a credit card using stripe / angular / node

I been trying to figure out how to create a user and store his credit card info in stripe for like a day and I cant get it to work.
I can see the following docs:
https://stripe.com/docs/api/customers/create
const stripe = require('stripe')('sk_test_xxx');
const customer = await stripe.customers.create({
description: 'My First Test Customer (created for API docs at https://www.stripe.com/docs/api)',
});
I understand the secret key aspect of the code.
I dont understand how to create the user object, though. where do I add the user name and info and email and stuff?
is there an example I can see using angular?
maybe the example can be for creating and storing the following information:
first name: juan
last name: cheese
email: jcasas#gmail.com
creditcard: 424242424242
csv: 231
creditcard name: juan cheese
exp: 02/02/25
i literally bough a course on udemy for this but that does not work either :(
If your intention is to save payment details, without an initial payment then you should follow this guide from the Stripe documentation.
The process creates a Customer object, and uses Setup Intents to correctly setup and save the payment details to that customer. Stripe.js and the Payment Element are used to safely collect payment details in a PCI compliant manner and handle any requested 3DS/authentication.

Check ACH credit transfer for customer in stripe using java

Is there any way to check whether ACH credit transfer added to customer or not in stripe using java with using only customerid.
ACH Credit Transfer is still only available on Stripe's legacy API called the Source API as documented here. Since it is not yet compatible with the PaymentMethod API you have to use one of the old calls in Java called getSources() which can be a bit hard to discover.
Your code would look something like this:
// Retrieve the customer with its legacy payment sources included
CustomerRetrieveParams retrieveParams =
CustomerRetrieveParams.builder()
.addExpand("sources")
.build();
Customer customer = Customer.retrieve("cus_1234", retrieveParams, null);
// Filter payment sources down to just Sources
PaymentSourceCollectionListParams sourcesParams =
PaymentSourceCollectionListParams.builder()
.setObject("source")
.build();
PaymentSourceCollection sources = customer.getSources().list(sourcesParams);
// Iterate over the Sources to find what you need
Iterable<PaymentSource> itSources = sources.autoPagingIterable();
for (PaymentSource paymentSource : itSources) {
Source source = (Source) paymentSource;
System.out.println(source.getId());
System.out.println(source.getType());
}
System.out.println("done");

How to use ACH payments in North America with stripe payment Intents

attempting to use a payment method of a ACH payment...but I can't figure out how to do it. Theoretically the documentation here says I can.
https://stripe.com/payments/payment-methods-guide#for-professional-services
However when I go here:
https://stripe.com/docs/api/payment_methods/create#create_payment_method-type
I see 'card' listed, but I do not see anything related to 'bank' or 'ach' or 'check' so I am confused.
I have no issues following their instructions to manually create a "bank" object programmatically, and then making then making that bank object a "source" as shown here:
const bank_submit_object = {
"object": 'bank_account',
"country": 'US',
"currency": 'usd',
"routing_number": routing_number,
"account_number": account_number,
"account_holder_name": account_name,
"account_holder_type": account_type
}
const bankAccount = await stripe.customers.createSource(
'customer_id',
{ source: bank_submit_object }
);
My problem is sources is listed as an Older api
https://stripe.com/docs/sources
And previously to today (the warnings are gone today for some reason), the documentation would flash a warning saying sources are the old way of doing things and to stop doing it.
So in order to do things the new way, can somebody help suggest how to do ACH payments using payment methods and NOT sources.
Thanks guys.
This is not supported by the current public API. For payments using ACH today, you should follow this guide using the legacy Charges API.
Note the callout at the top mentioning a beta for ACH payments using Payment Intents. If you're interested in that, you should fill out the linked form.
Edit 2022: The new Payment Methods & Payment Intents API support for ACH direct debit has since been released. See here: https://stripe.com/docs/payments/ach-debit

Stripe subscriptions.create - can you force use of payment intent?

Background:
Having obtained a paymentMethodId from the client with Stripe Elements, I am doing this on the server side:
stripe.paymentMethods.attach(..),
stripe.customers.update(...default_payment_method: ...).
stripe.subscriptions.create(..).
When additional action is required by 3DSecure, the subscription object (returned from create or fetched at a later date) includes a pending_setup_intent, which gives the info needed to resolve the intent (and i've got that working ok).
However if we run the subscriptions.create call when there aren't any payment methods on the Stripe Customer, the subscription object doesn't include a pending_setup_intent or anything else to indicate that the subscription doesn't have a way to pay.
Question:
Short of waiting for webhooks is there some way to have reasonably high confidence that the first payment on the subscription is likely to succeed, ie. there is a card, it's going to accept the payment (and yes, the 3DSecure stuff is sorted)?
Notes:
Although I'm not using trials on the subscription, the billing_cycle_anchor is in the future to provide a free period (basically a trial, but not explicitly making use of the stripe trial concept).
I'm using Stripe API version: 2015-03-24 (upgrading is a lower priority than resolving this)
Further clarification:
At the point we make the call to stripe.subscriptions.create(), the code is not aware of whether the paymentMethod was successfully attached and set as the default (I suppose we could check this, but my hope was that Stripe can handle that for us). For example when using the test card 4000000000000002 the payment method is not attached.
The call to stripe.subscriptions.create is of the form:
{
customer: stripeCustomerId,
billing_cycle_anchor: 1606946400,
cancel_at_period_end: undefined,
items: [{plan: "pro_annual"}],
prorate: false,
expand: ["pending_setup_intent", "pending_setup_intent.latest_attempt"]
}

Using Stripe How can i store card details of my customers and later on can charge them manually ....?

$stripe = new \Stripe\StripeClient(
'sk_test_123'
);
$stripe->customers->create([
'description' => 'My First Test Customer (created for API docs)',
]);
SHOULD I START WITH CREATING A CUSTOMMER ?? AND THEN SENDING AN INVOICE LATER ON.
You should follow the docs for saving a card during payment or saving a card without payment, depending on your needs. Both include samples for charging the saved card later.

Resources