#remi.lapierre
1 messages ยท Page 1 of 1 (latest)
Basically you will need to present the 3DS auth to your user either on your page or a stripe hosted one.
Is this the first subscription payment or a recurring one?
Recurring one
In a context where first payment was great and on a recurring event, it didnt pass
Gotcha, so basically you will want to send the user to a webpage where they can complete the 3DS auth flow. https://stripe.com/docs/billing/subscriptions/overview#requires-action
So either you can send them to the stripe hosted invoice page, or you can send them to your own page where you present the 3DS modal
That first doc also mentions that you can turn on a Stripe setting so that we automatically email the user about 3DS being required with a link to complete it
I see, how can I detect it on the code?
try {
$charge = $organization->account->createCharge($invoiceItem->total * 100, $stripeId, $methodId);
if ($charge == null) throw new GeneralException('Unable to create Stripe payment charge');
} catch (\Exception $e) {
// stripe error
Log::info("Job RecurringPayments Stripe Charge Error organization #{$organization->id} {$organization->name}:" . $e->getMessage());
$recurring->errors++;
$recurring->save();
// should create a new recItem instead of adding days to the current one
$recItem->scheduled_at = $now->addDays(2);
$recItem->save();
if (!empty($membership->credit_card_error_template_id)) {
// should send it to org also
$this->sendEmail($membership->recipientList, $recipient, $invoice, $membership->credit_card_error_template_id, $sendOutRepository);
}
throw new GeneralException("Job RecurringPayments Stripe Charge Error organization #{$organization->id} {$organization->name} {$recItem->id}");
}
I have something like this going on... but it doesnt trigger an erorr
and than throws an error here
protected function createPaymentFromStripeCharge(Organization $organization, Invoice $invoice, Recipient $recipient, $pi, $amount){
$payment = Payment::create([
'charge_id' => $pi->charges->data[0]->id,
'card_brand' => $pi->charges->data[0]->payment_method_details->card->brand,
'last4' => $pi->charges->data[0]->payment_method_details->card->last4,
'stripe_status' => $pi->status,
'paid_at' => now(),
'organization_id' => $organization->id,
'invoice_id' => $invoice->id,
'recipient_id' => $recipient->id,
'currency' => $organization->account->currency,
'type' => 'stripe',
'amount' => $amount,
'stripe_id' => $pi->id,
'receipt_no' => Payment::nextReceiptNo($organization),
'is_test_mode' => $organization->account->is_test_mode,
]);
return $payment;
}
Listen for the invoice.payment_action_required event https://stripe.com/docs/api/events/types#event_types-invoice.payment_action_required
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Is there a way to test it out somehow on local?
Like having a card that passes the first time but blocks on the second time via 3d stuff?
As I want to make sure my code handle it
Yes, we have a test card that I think you can use here. The one ending in 3184 always requires 3DS and the https://stripe.com/docs/testing#authentication-and-setup
Yes but it will work for the first attempt
But in a recurring context, it wont
As I need to capture the first payment
I am not clear on what you mean here. Test payments with that card will all succeed as long as you go through the test 3DS auth
So they will be held up by 3DS until that is completed.
Can you elaborate a bit on the test you are trying to do here?
I want the first attempt to succeed but when i try to charge it again
it will show 3ds auth
As i am working in a recurring payment envirormenet
That card will do that. The first payment will require 3Ds and then succeed, all subsequent recurring payments will also require 3DS
Great, will try that!
Also, if we attempted 3 times already, does it nofify her that we did or not at all?
As I dont want to charge her 3 times ๐
What was attempted 3 times already?
Are these three attempts to charge a real customer?
Yes, this code was in prod
And Im fixing it right now locally
๐ฆ
amount_received of the PayementIntent object will be at 0 when Stripe wasnt able to fully procees?
Correct. They won't be charged until 3DS succeeds. And I don't think Stripe would notify this person but if there were three payments that required 3DS it is possible that their bank may notify them though I don't know if they would do that just for this.
So if you just forward them to a page to complete 3Ds for one of those payments they should be able to complete it
And you can cancel any other incomplete payment intents related to this
Yes i am planning to send them to an invoice page to pay