#samiya_code

1 messages ยท Page 1 of 1 (latest)

sacred idolBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1430859912124174336

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

bleak spruce
formal hound
#

Preauthorization code
case 'customer.subscription.created':
$subscription = $event->data->object;
if (!empty($subscription->items->data) &&
isset($subscription->items->data[0]->price->id) &&
$subscription->items->data[0]->price->id === 'price_1RVbnpED5xkfDv2cFGpuEsb7' &&
isset($subscription->metadata['preauthorized_subscriptions']) &&
$subscription->metadata['preauthorized_subscriptions'] === 'true'
) {
$customer_id = $subscription->customer;
$payment_method_id = $subscription->default_payment_method ?? $subscription->payment_settings->default_payment_method;

            if ($payment_method_id) {
                // Attempt to create PaymentIntent, with error logging
                try {
                    $paymentIntent = $stripe->paymentIntents->create([
                        'amount' => 1999,
                        'currency' => 'gbp',
                        'customer' => $customer_id,
                        'payment_method' => $payment_method_id,
                        'capture_method' => 'manual',
                        'confirm' => true,
                        'off_session' => true,
                        'metadata' => [
                            'subscription_id' => $subscription->id,
                            'purpose' => 'preauthorization_day4',
                        ],
                    ]);
                } catch (\Exception $e) {
                    error_log('PaymentIntent creation error: ' . $e->getMessage());
                    echo('PaymentIntent creation error: ' . $e->getMessage());
                }

error: {"error":"PaymentIntent creation failed"}PaymentIntent creation error: Your card was declined

bleak spruce
#

Can you give me more details on what you're trying to do, in particualar with regard to this "preauthorizing" Generally, if you're not intending on charging straight away, Setup Intents are used. Some info on the differences here: https://docs.stripe.com/payments/paymentintents/lifecycle

formal hound
#

Yes I am using setup intents. Basically what I am doing is I have a 7 day free trial based subscription that I am creating usng setup intent and then creating a suscription using a webhook event setup.intent.succeeded. Now what I want to do is create a preauthorization on the 4th day of trial using event trial.will.end, but in order to test it, I am adding the trigger on customer.subscription.created so that I can test it immediately rather than waiting for 4 days

bleak spruce
#

Can you find me the request ID (req_xxx) for the failed attempt?

formal hound
#

evt_1SLKjWED5xkfDv2cVY5JlKGI

Will this work for you?

bleak spruce
#

Let me take a look..

formal hound
#

sure thanks

bleak spruce
#

Looks like you have a Radar rule that's blocking non-GB cards - this seems to have been triggered by your requests

formal hound
#

So that means the preauthorization code is correct but its failing due to the radar rule?

bleak spruce
#

It's creating the request fine anyway, but we won't attempt to perform any authorization with the bank at all in this instance due to the Radar rule

formal hound
#

Can you please help like how do we check that which radar rule is affecting it?

#

Do we see that in the event itself?

bleak spruce
#

Specfically, outcome.rule

sacred idolBOT
formal hound
#

How to fetch charge object from the payment intent?

tawny tusk
formal hound
#

I mean is there a way to check it in stripe. E.g how can I confirm that the the non-GB cards radar rule is triggering my webhook event

tawny tusk
#

Which webhook event are you referring to here?

#

From the Dashboard you can see which payments matched a block rule