#-7he-judge-_error

1 messages ยท Page 1 of 1 (latest)

sleek gulchBOT
#

๐Ÿ‘‹ 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/1423683241751089244

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

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

novel scarab
#

Hello
Can you share a request ID?

pallid canopy
#

I do no understand way how to implement it

novel scarab
#

Can you share a request ID where you're seeing the error?

pallid canopy
#

req_1204OS29gca865

#

no, not this

novel scarab
pallid canopy
#

req_1DJkxXN5zlqHH1

#

according to my code
what's wrong there?

{
  "error": {
    "message": "You must provide a `return_url` when confirming a PaymentIntent with the payment method type amazon_pay.",
    "request_log_url": "https://dashboard.stripe.com/test/logs/req_1DJkxXN5zlqHH1?t=1759503234",
    "type": "invalid_request_error"
  }
}
#
const subscription = await this.stripe.subscriptions.create({
      customer: stripeCustomer.id,
      items: subItems,
      add_invoice_items: addInvoiceItems.length > 0 ? addInvoiceItems : undefined,
      default_payment_method: defaultPaymentMethod,
      discounts: subscriptionDiscounts,
      payment_behavior: 'allow_incomplete', // Allow incomplete but try to charge immediately
      automatic_tax: { enabled: false },
      metadata: typeof dto.metadata === 'object' ? (dto.metadata as any) : {},
    });
novel scarab
#

You're not passing off_session: true

pallid canopy
#

yes, I know

req_uwY4G1jfYqjkYO
novel scarab
pallid canopy
#

but transaction - incomplete
subscription - is not active

novel scarab
#

why are you setting payment_behavior: "allow_incomplete" ?

pallid canopy
#

looking for that

#

req_QX8CzUfKXz9mrn

novel scarab
#

looking

pallid canopy
#

look at my last disscusion with support
they said the user need to do smth
cause intent has status requires_payment_method

sleek gulchBOT
novel scarab
#

Not exactly.. With off_session: true, we don't expect the user to be around.
Subscriptions API should just charge the payment method at this point

pallid canopy
#

but I do not understand what's a problem

#

why does not it charge the payment

novel scarab
#

I think you're missing a Step. How exactly did you create the Payment Method before you attempted to use it?

#

The payment method is missing a mandate

#

You need to use a SetupIntent and confirm it before you can use that Payment Method with a Subscription

pallid canopy
vast notch
#

๐Ÿ‘‹ changing of the guard, I'll be taking voer the thread,just reading through you code.

pallid canopy
#

okay

vast notch
pallid canopy
#

Hm, Iโ€™d take a look

pallid canopy
#

But do not close this thread

pallid canopy
#

does this way supports other methods
except for Amazon?

vast notch
#

Yes, SetupIntents are the recommended way to createa a payment method in advance before charging.

sleek gulchBOT
pallid canopy
#

I'm keep trying to change

sweet lily
#

๐Ÿ‘‹ Taking over this thread, catching up now

#

Let me know if you have any further question

pallid canopy
#

I'm confused
What certainly wrong in my variant?
code you look at my code above?

#

Do we need to adjust logic for each payment method?
Could not work via on implementation?

sweet lily
#

How are you creating a payment method now? Are you using direct or deferred intent flow? Could you share the code on you create a Payment Method and use it for the subscription?

pallid canopy
#

deffered

pallid canopy
sleek gulchBOT
stone mauve
#

Hi taking over here. This thread has been open for a long time. What is your current issue exactly? I don't understand your latest questions

pallid canopy
#

My subscription with Amazon Pay does not work
I tried differect ways, but without result

stone mauve
#

Can you please share more details. That doesn't give me anything to work with

#

My colleagues already told you what's wrong with the initial request you shared

#

So what have you tried since then and what's not working

pallid canopy
#

One moment

#

I've extended frontent with this code

if (confirmResult.confirmationSecret && confirmResult.requiresAction) {
            console.log('Amazon Pay confirmation required');
            
            // Use Stripe.js to confirm Amazon Pay payment
            const { error, paymentIntent } = await (stripe as any).confirmAmazonPayPayment(
              confirmResult.confirmationSecret,
              {
                return_url: `${window.location.origin}/checkout/success`,
                mandate_data: {
                  customer_acceptance: {
                    type: 'online',
                    online: {
                      infer_from_client: true,
                    },
                  },
                },
              }
            );

            if (error) {
              onError(error.message || 'Amazon Pay payment failed');
              setIsProcessing(false);
              return;
            }

            if (paymentIntent && paymentIntent.status === 'succeeded') {
              onSuccess(paymentIntent.id);
            } else {
              onError('Amazon Pay payment not completed');
            }
            setIsProcessing(false);
            return;
          }
#

is that a correct way?

stone mauve
#

You should collect payment method via a setupintent per my colleague's advice so mandate is generated at that time

#

That's how our docs instruct you to do it

pallid canopy
#

hm, after long manipulation
I managed to show authorization page, to accept/decline amazon payment
but after I accept, I being redirected to /checkout page
but not /success

stone mauve
#

I don't know what you're referring to

#

You seem to be ignoring our advice and going off and doing things on your own without telling us what those things are

#

So hard for me to help you

pallid canopy
#

there's a part
responses for authorize payment

how to adjust redirect here correct?

#
// Handle Amazon Pay confirmation flow
          if (
            confirmResult.confirmationSecret &&
            confirmResult.requiresAction
          ) {
            console.log('Amazon Pay confirmation required');
            console.log(
              'Using return_url:',
              `${window.location.origin}/checkout/success`
            );

            // Use Stripe.js to confirm Amazon Pay payment
            const { error, paymentIntent } = await (
              stripe as any
            ).confirmAmazonPayPayment(confirmResult.confirmationSecret, {
              return_url: `${window.location.origin}/checkout/success`,
              mandate_data: {
                customer_acceptance: {
                  type: 'online',
                  online: {
                    infer_from_client: true,
                  },
                },
              },
            });```
#
            if (error) {
              onError(error.message || 'Amazon Pay payment failed');
              setIsProcessing(false);
              return;
            }

            if (paymentIntent && paymentIntent.status === 'succeeded') {
              // For Amazon Pay, manually redirect to success page since the return_url might not work as expected
              console.log(
                'Amazon Pay payment succeeded, redirecting to success page'
              );
              window.location.href = `${window.location.origin}/checkout/success?payment_intent=${paymentIntent.id}`;
            } else if (
              paymentIntent &&
              paymentIntent.status === 'requires_action'
            ) {
              // Payment requires additional action, but Amazon Pay should handle this automatically
              console.log(
                'Amazon Pay payment requires action, redirecting to success page'
              );
              window.location.href = `${window.location.origin}/checkout/success?payment_intent=${paymentIntent.id}`;
            } else {
              onError('Amazon Pay payment not completed');
            }
            setIsProcessing(false);
            return;
          }```