#lafafm-prb-amountupdate

1 messages · Page 1 of 1 (latest)

olive geyserBOT
past sonnet
#

I don't know if I fully understand the question. Can you include a detailed numbered step-by-step explanation for what you're hoping to achieve?

Also, I see that this question may have already been answered. Can you also confirm that your current question is not answered with the below response already?

that's what https://stripe.com/docs/js/payment_request/events/on_shipping_address_change is for
you can't really do custom logic between the customer clicking the button and showing the popup, since browsers will block the popup from showing if it's not called from a 'gesture handler' (a click event; if you make an XHR to your backend then you lose that context)

unique galleon
#

The main question here - is probably how to generate a correct PaymentRequest without creating subscription

But keeping in mind a possiblity of coupon usage and taxRate assignment to the future subscription

So the final amount shown in Apple Pay would be correct

past sonnet
#

Can you include a detailed numbered step-by-step explanation for what you're hoping to achieve?
Please help us help you by providing the information we request

unique galleon
#

We have a one-page registration form
With PaymentRequestButton

If user wants to register with ApplePay:

  1. He fills all required fields in a form (name / email / phone)
  2. Enters zip, which we're using for tax calculation in 3rd-party provider
  3. Enters coupon code, which would give a discount on subscription creation
  4. Presses Apple Pay button

By the moment of step 4 - Payment Request Button have a PaymentRequest which doesn't know about a discount% and taxRate applied, as they gonna be calculated on subscription creation

So, in case when plan costs $200 - we'll show ApplePay confirmation for $200, but the taxRate may increase that sum afterwards to $220
Or in case of coupon - that sum may be decreased to $180

The question here - is how to make an XHR request between steps 3 and 4 to calculate taxRate / coupon discount to show a correct amount in PaymentRequest

shrewd timber
#

By the moment of step 4 - Payment Request Button have a PaymentRequest which doesn't know about a discount% and taxRate applied, as they gonna be calculated on subscription creation
you would need to make a call to your server, calculate the amount and the update the PaymentRequest to reflect that

unique galleon
#

Yea, but when?

I can't emulate a GPay button click
And can't use async requests in .click handler

#

The only possibility is to listen fields.change, and calculate taxes / coupons on the go?

shrewd timber
#

yeah that's what I'd do

#

It's that or require a double click on the click handler basically

#

like they choose Apple Pay or Google Pay and you do a round trip to your server for the updated amount and then require a second click

#

you can technically do it in the first click handler but there's a limit to how long it can take before you call .show()but it doesn't work

unique galleon
#

Okay, got you

It's a bit confusing in comparison with a flow used with a card element

In Apple Pay scenario - we'd actually create subscription only after we got a paymentRequest.on('payment_method' ..) to get a setup intent / etc

shrewd timber
#

lafafm-prb-amountupdate

#

Not sure I understand why either

#

Why wouldn't you create the Subscription upfront and then collect the payment?

unique galleon
#

We're trying to keep our registration form with 1 button click only

E.g. fill out the fields, press the button, see the welcome page

So, to create it upfront - we need to make double-click action, as you described

shrewd timber
#

I don't really get it, what's the difference with a non Apple Pay flow?

unique galleon
#

As for non Apple Pay flow - we're free to create a subscription on a button click, and then createPaymentMethod from cardElement and proceed with SetupIntents / etc

shrewd timber
#

But yeah no way around this otherwise