#elijahworkz

1 messages ยท Page 1 of 1 (latest)

jaunty fogBOT
inland patio
#

Hi there

#

First, are you using Payment Element or Card Element currently?

umbral patrol
#

Card Element with individual inputs (card, expire, cvv)

inland patio
#

Gotcha

#

For your Subscriptions, are you using Charge Automatically?

#

As the payment_behavior

umbral patrol
#

yes - the only thing we're doing is setting an offset for trial payments sometimes

#

everything else is default

#

here's our current flow in more detail... On client - we're getting PaymentMethod and send it to server along with an email that we ask for...
There we create a customer with that email, attach payment method and then create subscription...
what I'm not sure is where/how is to plugin the payment request button payment

#

I set requestPayerName: true, requestPayerEmail: true,

#

on paymentRequest

vocal canopy
#

Hi ๐Ÿ‘‹ I'm stepping in as @inland patio needs to go.

#

So you want to use the Payment Request Button in place of the Card Element to speed up the buying process?

umbral patrol
#

not 'IN PLACE' but 'IN ADDITION TO' ๐Ÿ™‚

vocal canopy
#

Alright

umbral patrol
#

it came as business requirement and I'm trying to determine if it's possible without asking them for email first (what we currently do)

#

note: email is still required if they choose to use card elements

vocal canopy
#

What is the functionality you are trying to get out of the request button?

umbral patrol
#

from what I understand they don't want them to fill out the email (kind of a 'one click' solution)

#

we create a subscription and then fill out account information in the onboarding process

#

BUT we do need their email to send welcome message (which I was hoping to get by some api request for customer details) and we do need customer to create a subscription...

#

so the problem (question) is when/how to create a customer from PR button

vocal canopy
#

Have you tested/investigated this?

umbral patrol
#

Hmm... I'm not sure if we do use Charge...

#

let me check the code really quick

vocal canopy
#

You don't need to use the Charge object

#

In fact we don't recommend it. We recommend using the Payment Intent

#

But when you attempt to collect payment with a Payment Intent it generates a related Charge object.

umbral patrol
#

I don't generate PaymentIntent... We get paymentMethod.id from the client and use that to attach it to the customer

#

then we call subscription endpoint to create subscriptioin

#

I'm not sure if payment intent is generated automatically because we are looking for it in case of failed payment to send back to client

vocal canopy
#

I'm a little confused about this flow

#

How are you generating a Subscription if you don't have a Customer yet?

umbral patrol
#

in our current setup we do... on the client they fill out the form and it results in paymentMethod (we get it from stripe in client)

#

then we pass that to the server (along with email)

#

and the server creates customer, attaches payment method and tries to create subscription

#

the code we have was largely copied from and a demo subscription flow stripe had a couple of years back...

#

it's been on a backburner for all this time and now they want to revive the project with new additions

#

it works as expected in test environments - with failed cards, 3D secure scenarios etc...

vocal canopy
#

What works in test environment? The PRB?

umbral patrol
#

no.. the current setup without PRB

#

I'm just not sure how to plugin the PRB into what we already have ๐Ÿ™‚

#

If we change the flow to start the subscription process with a PaymentIntent (generate it on server on the first request) - will that simplify things?

vocal canopy
#

Right, I'm not sure it will work with the flow you have.

#

Since you need a Payment Intent to create/mount the Payment Request Button

#

Well...wait you could use a Setup Intent

umbral patrol
vocal canopy
#

What is "as it is"?

umbral patrol
#

the buttons show up on the form

#

I'm passing the same paymentRequest as before

#

Just to clarify again - this is what I have on client now...

  1. I create a stripe.paymentRequest({})
#
  1. I use paymentRequest to create PRB
#
  1. I have paymentRequest.on('paymentmethod'
#

that initiates subscription

vocal canopy
#

Okay so you are just using the PRB to generate the Payment Method from a digital wallet?

umbral patrol
#

I attached some of the code... I omitted the part where PRB buttons are generated as it's pretty much copied from the docs

vocal canopy
#

Okay so what are you attempting to do that is not working as you expect?

umbral patrol
#

when the click on PRB - I don't collect their email and it is not sent to the server

#

so all the flow I have on the server (create customer, attach PM, create subscription) is in question

#

how can I create/retrieve the customer if they clicked on PRB and I don't have an email to use

#

Just to give an example... this form also has PayPal button and I have a different flow for that

vocal canopy
#

When you receive the Payment Method are you logging the object?

umbral patrol
#

I'm only getting the ID from that object currently

#

I'm not sure how to test it with PRB

vocal canopy
#

In your event handler, examine the Payment method

umbral patrol
#

I see...

#

since I followed the demo - they only get the paymentMethodID there ๐Ÿ˜ญ

vocal canopy
#

Including the billing_details

#

Right, because the demo is focused on Payment Intents and is relatively simple

#

But your process is rather complex so we need to do a few extra steps

umbral patrol
#

So in this case I don't need to change anything in my flow - I can get info I need from PM object

#

and the rest is the same, correct?

vocal canopy
#

So the first thing I would do in your situation is to log the full pamyneMethod object in your else condition :

paymentRequest.on('paymentmethod', function(result) {
        console.log('payment method result', result)
        if (result.error) {
            displayStripeFeedback(result.error.message, 'error');
        } else {
                        console.log(paymentMethod)
            createSubscription(result.paymentMethod.id)

and examine the object in the console to be 100% sure where the values are

umbral patrol
#

OK...

#

How can I test that with PRB? Currently it shows Link button

#

If I click on that to pay (but I'm connected to test Stripe) - will it charge me?

#

or if can get Apple Pay to show?

vocal canopy
#

You need to test it with a browser that is set up for Google/Apple pay

umbral patrol
#

OK... I can use Safari for Apple... I am setup to see Google but it doesn't show (only Link does)

#

in any case - I should be ok clicking those as long as I'm in testing mode?

vocal canopy
#

Yup

#

Test mode means no actual communication with banks so no money actually moved

umbral patrol
#

Wonderful!!! thank you so much!

vocal canopy
#

You should get something like this:

{
  applePay: true,
  googlePay: false,
  link: false,
}

With whichever wallet is enabled in the browser set to true

umbral patrol
#

hmm... it shows that Google pay is not enabled... I in any case - I'll figure it out and I know that I can get ApplePay to show in Safari

#

Thanks again!

vocal canopy
#

Happy to help ๐Ÿ™‚