#Perry

1 messages Β· Page 1 of 1 (latest)

narrow duneBOT
desert epoch
#

Hello, looking in to this. What are you trying to do with the token here?

dusk bramble
#

hello,
With token i will be using this token for future payments and not for immediate payments

#

just to save the details of customer once they have submitted it via Applepay

desert epoch
#

Gotcha, thank you for the context, still looking in to this and will get back to you

dusk bramble
#

Thank you πŸ™‚

#

Just remember, i am not trying to do payment via Applepay but just trying to get entered/saved card details which should be saved in the form of token since i am able to achieve this for cardElements

desert epoch
#

Definitely keeping that in mind. Also to be clear, in your current code are you always getting a specific error message?

dusk bramble
#

No i am not getting any error in the code

#

but when applepay payment interface opens up, it fails without any error

#

let me send you screenshot

#

This happens bcz onConfirm props of ExpressCheckoutElement is expecting something it seems

narrow duneBOT
desert epoch
#

Having trouble finding token-specific docs. The intended flow may be to confirm a SetupIntent instead of a PaymentIntent here. Trying to confirm that or to see if we have token specific docs

dusk bramble
#

Yes you are right, it will be SetupIntent instead of paymentIntent πŸ™‚

#

okay i will be waiting

desert epoch
#

Oh are you already trying to confirm a SetupIntent and that is giving you this behavior?

dusk bramble
#

I am yet to create setupIntent, but even if i did, how can i access token?

desert epoch
#

To be clear, confirming a SetupIntent shouldn't need a token as far as I am aware. You should be able to create and confirm a SetupIntent just like a PaymentIntent

dusk bramble
dusk bramble
crimson storm
#

Hello πŸ‘‹
Just to make sure I am on the same page, when you say "token" what exactly are you referring to?

tok_xxx object OR PaymentMethod object pm_xxx OR something else?

dusk bramble
#

hello,
referring to tok_xx

crimson storm
#

Tokens API is considered legacy

#

You can create a PaymentMethod using createPaymentMethod and then create a SetupIntent for it

#

That should let you save the PaymentMethod for future use

dusk bramble
#

yes actually i have read about the setupintent and createPaymentMethod as well, the only problem is i need to send this card saved details to a 3rd party platform who then will charge the customer in future using applepay
and they need tokens only as their intergation API with stripe is built in that way

#

i know with payment ID it is possible to achieve but this 3rd party client still needs Token as endpoint integration

crimson storm
#

My understanding was that only a few elements supported createToken function
https://stripe.com/docs/js/tokens_sources/create_token

I am not aware of Express Checkout Element supporting this.

When you call createToken , do you see an API error or something?

Can you look at the logs here and share the request ID (req_xxx)?
https://support.stripe.com/questions/finding-the-id-for-an-api-request

dusk bramble
dusk bramble
#

but i resolved this error by simply implementing StripeCardElement as a type

crimson storm
#

Yeah that's because we only support createToken with cardElement. It shouldn't really try to create a token with Express Checkout Element.

dusk bramble
#

yes createToken is used for only Card elements, but then how come it is creating tokens on logs page for ExpressCheckoutElement as well?

crimson storm
#

that seems like a bug.. Let me re-confirm

dusk bramble
#

ok

crimson storm
#

Are you seeing any other errors in your console when you see the Apple Pay modal show the error?

dusk bramble
#

no error

#

tried again, no errors at all

#

okay, very weird thing i just noticed
I try to get tokens for cardelements, it does get the token
and if i remove the code i sent you earlier for express checkout onConfirm and try to click on applepay button,
it still creates token for applepay as well

crimson storm
#

Gotcha. That's most liklely due to createToken is not supported by ECE.

#

Express Checkout creating the token is most likely a bug. I will make sure to flag this internally.

dusk bramble
#

ohh okay so basically ECE is stealing this create token from cardElements onChange?

#

Anyways, my main concern was to get token for ApplePay ExpressCheckoutElement button,

crimson storm
#

My understanding is that the ECE should block the function from running since it doesn't support it.

But yeah, createToken function is only supported by only a few elements.

dusk bramble
#

i see one error now for paymentfailed: arguments: TypeError: 'arguments', 'callee', and 'caller' cannot be accessed in this context.

dusk bramble
crimson storm
#

Like it should throw a clear error when you try to use .createToken with ECE

dusk bramble
#

yeah, that's not clear error, console logged event of onConfirm and it gave me the above error

#

if i create setupintent and confirmpayment method via ExpressCheckoutElement Onconfirm,
the Payment ID i will receive from this should be used for future payment right?

crimson storm
#

if i create setupintent and confirmpayment method via ExpressCheckoutElement Onconfirm,
the Payment ID i will receive from this should be used for future payment right?
If by Payment ID, you mean PaymentMethod ID (pm_xxx) then yes you should be able to.

dusk bramble
#

okay,
this 3rd party client still needs token as an endpoint, can you please have a look and let me know if it's possible?

crimson storm
#

Yeah I don't believe we have an example for deferred payment request in our docs
https://stripe.com/docs/apple-pay/merchant-tokens#merchant-token-types

But looks like it isn't supported for web today

DeferredPaymentRequests, released in XCode version 14.3, aren’t yet available on Apple Pay on the Web, and are only compatible with devices running iOS 16.4 or higher.
https://stripe.com/docs/apple-pay/merchant-tokens#deferred-payment:~:text=DeferredPaymentRequests%2C released in XCode version 14.3%2C aren’t yet available on Apple Pay on the Web%2C and are only compatible with devices running iOS 16.4 or higher.

dusk bramble
#

yup

#

any work around for this then? to save applepay card details?

crimson storm
#

As a tok_xxx? I don't believe so. still double checking just to be sure..

dusk bramble
#

yes thank you

#

also let me know if the bug you are referring to when ECE tries to save it's card details even when createToken is actually called on cardElement, if this really is a bug?

#

let me share the out put with you

#

Please see these token created on logs page and see difference between both

#

one says apple pay wallet, another doesn't have any since it's a direct cardElement payment

crimson storm
#

also let me know if the bug you are referring to when ECE tries to save it's card details even when createToken is actually called on cardElement, if this really is a bug?
yes, .createToken isn't supported by ECE. so it shouldn't try and create a token.

Please see these token created on logs page and see difference between both
The difference is expected since two diff tokenization methods were used

#

I did find a workaround

dusk bramble
#

okay

crimson storm
dusk bramble
#

i have tried this method, problem is, we need to give amount before hand, which is not usecase i can accept as of now

  country: 'US',
  currency: 'usd',
  total: {
    label: 'Demo total',
    amount: 1000,
  },
  requestPayerName: true,
  requestPayerEmail: true,
});```
crimson storm
#

Can you put 0 as an amount?

dusk bramble
#

no, zero is not acceptable in stripe anywhere

crimson storm
#

I am able to set 0 as the amount

dusk bramble
#

won't this create a token of zero payment then? what i mean is in future if client wants to fetch more amount, this token should not create an issue

dusk bramble
crimson storm
#

Tokens don't really have an amount attached to them..
https://stripe.com/docs/api/tokens/create_card

Great, i tried zero but i keep getting error on no zero payments allowed
Are you calling PaymentIntents API somewhere? If you just want to create a Token, then you don't need a PaymentIntent.

narrow duneBOT
dusk bramble
#

no i am not calling paymentIntent anywhere as of now
Can you get token in your demo code please? and attach response here (hide token if you can)

dusk bramble
#

Can you get token in your demo code please? and attach response here (hide token if you can)

crimson storm
#

I used Google Pay here so tokenization method is diff

dusk bramble
#

Thank you πŸ™‚
this above response is from paymentRequest.on('token', ()) ?

crimson storm
#

It is from the API request but it should be reflected similarly in the event handler too

dusk bramble
#

yes yes right, response shall be similar

#

okay let me quickly give this a try, i will be back

crimson storm
#

Just tested with the event handler, the function does get the same token there too

            console.log(ev.token);
            ev.complete('success');
})```
dusk bramble
#

Awsm! this is great
πŸ™‚

#

can you send me how you created PaymentRequestButtonElement ? right now i am facing issues IntegrationError: Invalid value for create(): paymentRequest should be a stripe.paymentRequest(...) instance. You specified: [object Object].

sage linden
#

HI πŸ‘‹

@crimson storm had to go so I'm stepping in. Which line is throwing the error here?

dusk bramble
#

Hello,
i think it's bcz of typescript 😦

#

this line

#

i am initiating
const [paymentRequest, setPaymentRequest] = useState<PaymentRequest | null>(null);

sage linden
#

Can you try using the code as written in our doc?

const [paymentRequest, setPaymentRequest] = useState(null);
dusk bramble
#

hmm i did, was getting this error

sage linden
#

Can you share the usEffect() code snippet?

dusk bramble
#

yes here it is

#

it is fine, i am leaving this error as is, as it's typescript error and not a blocker

#

i can see Applepay button, i can click on it and generate a token for future payments and also payment can be seen successful on Applepay payment UI

#

this is intended right? to generate token for future payments?

sage linden
#

What part is intended?

dusk bramble
#

that with PaymentRequestButtonElement i can retrieve token from paymentRequest?.on('token', () => {}) and the same token can be used for future payments whenever clients wants to charge the customer?

#

even though initially i have charged Zero to customer, but same token can be used to create future payments right?

sage linden
#

Yes

dusk bramble
#

Sure right? then i think we were able to achieve this πŸ™‚

sage linden
#

Great! I would recommend working through it in Test mode to be sure you get the behavior you are looking for.

dusk bramble
#

Thank you for all the support πŸ™‚ Really appreciate the hard work you guys are doing!

#

yes right now it is working properly, needed token for future payments so that is retrieved as of now πŸ™‚

#

i hope this token even though zero can be used in future, this should not create issue saying that zero amount was taken?

sage linden
#

Are you using a Setup Intent to create the Payment Method?

dusk bramble
#

no i am not using setupIntent, but during submission of form it will be required it seems for card verification right?

sage linden
#

How are you saving the Payment Method to Stripe?

dusk bramble
#

right now i am not since i just started with the cardElement and PaymentRequestButtonElement

#

according to the Stripe usually what should be the flow?

#

In my scenario, customer lands on hotel booking page, fills out personal details section and then scrolls to payment section
in payment section user has these options
above one is applepay using PaymentRequestButtonElement and below on is created using CardNumberElement, CardExpiryElement, CardCvcElement

#

as of now i have just created

      mode: 'setup',
      payment_method_types: ['card'],
      setup_future_usage: 'off_session'
  };

  return (
      <Elements options={optionsElements as StripeElementsOptionsMode} stripe={stripePromise}>
        <PaymentForm fields={fields} isMonthly={isMonthly} />
      </Elements>
  );```
#

Payment form has the payment section in screenshot

#

let me know if this makes sense to you

sage linden
dusk bramble
#

i think with given reference, a new checkout page is displayed to user right? which is basically a checkout session url

#

this is not intended in my case, we just submit our form to 3rd party platform and then they take care from their end of when to deduct the amount from customer's given card details

#

can you please tell me a proper sequence of how the calls should usually happen? given my scenario

sage linden
#

That is only if you use the Stripe Checkout Session.

#

There is a tab on that document for Custom code

#

That should be what you are looking for

dusk bramble
#

Oh yes, sorry my bad,
I have already referred to this code earlier and tried to create Client_Secret ID which was <PaymentElement

#

then i switched to Express checkout element which needed just mode, payment_methode_types

#

and as Express checkout element was not of much help, now i am using PaymentRequestButtonElement

#

so setup intent will be created and and also paymentmethod will be submitted to stripe

#

but our 3rd party platform just needs token in hand as of now they don't need payment method ID

sage linden
#

Got it

narrow duneBOT
dusk bramble
sage linden
#

Only when you want to create a new Customer/Payment Method.

dusk bramble
#

Yes but in my case do i have to create new payment method everytime? I mean to say, what does stripe expect from us? Does stripe want token in the end or these payment methods?

#

I am literally confused now like what stripe is expecting from us?

sage linden
#

That all depends on what you are trying to do. How are these tokens/Payment Methods going to be used?

dusk bramble
#

So these tokens i am retrieving will be used by 3rd party platform 'peoplevine' (if you have heard of them) then by their own plugins or Apis these guys will deduct amount using the token I submitted them on that form submission

#

I had word with peoplevine and they said they just need token and NO payment method ids

sage linden
#

And this platform uses Stripe to process payments?

dusk bramble
#

Yes i think

#

Linked with stripe

#

They have their own APIs for payments

sage linden
#

Okay then it would be up to them to specify which Stripe object they need you to return to them.

#

Unfortuntaely I don't know their integration so I can't speak to what they need in order to ensure they can process payments successfully

dusk bramble
#

Exactly..... that's a big question for me as well....i already had a word with them but they just need tokens
So i am under assumption that they will have their own integration to do via these tokens.... that's why even though i know tokens will be deprecated in future but they still want to use them

#

I have given them headsup for tokens going to extinct but in not near future.....so i think using tokens should be fine?

sage linden
#

yes that should work as long as the 3rd party is getting what they need on their end

dusk bramble
#

Okay Great! πŸ™‚ Thank you again for your support

sage linden
#

We're happy to shed what πŸ’‘ we can πŸ™‚