#Perry
1 messages Β· Page 1 of 1 (latest)
Hello, looking in to this. What are you trying to do with the token here?
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
Gotcha, thank you for the context, still looking in to this and will get back to you
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
Definitely keeping that in mind. Also to be clear, in your current code are you always getting a specific error message?
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
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
Yes you are right, it will be SetupIntent instead of paymentIntent π
okay i will be waiting
Oh are you already trying to confirm a SetupIntent and that is giving you this behavior?
I am yet to create setupIntent, but even if i did, how can i access token?
Ah we do have a code snippet specifically for this https://stripe.com/docs/apple-pay/merchant-tokens
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
Let me have look into this, i can see from first look, this does require amount for submission and is related to recurring payments
Okay lets consider we are not doing setupintent here, but just need tokens from stripe.createToken()
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?
hello,
referring to tok_xx
which you can see here on logs page https://dashboard.stripe.com/test/logs?method[0]=post&method[1]=delete&direction[0]=connect_in&direction[1]=self
Is there a guide you're following for this?
If you're only trying to store the payment method then you'd likely want to use createPaymentMethod function instead
https://stripe.com/docs/elements/express-checkout-element/accept-a-payment#create-pm
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
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
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
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
yes, request ID is: req_wdYPaKJTaWOmVj
when calling Createtoken i am getting this error: Argument of type 'StripeElement | null | undefined' is not assignable to parameter of type 'StripeCardElement | StripeCardNumberElement'.
but i resolved this error by simply implementing StripeCardElement as a type
Yeah that's because we only support createToken with cardElement. It shouldn't really try to create a token with Express Checkout Element.
yes createToken is used for only Card elements, but then how come it is creating tokens on logs page for ExpressCheckoutElement as well?
that seems like a bug.. Let me re-confirm
ok
Are you seeing any other errors in your console when you see the Apple Pay modal show the error?
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
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.
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,
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.
i see one error now for paymentfailed: arguments: TypeError: 'arguments', 'callee', and 'caller' cannot be accessed in this context.
what do you mean by block the function?
Like it should throw a clear error when you try to use .createToken with ECE
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?
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.
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?
i see this documentation for https://developer.apple.com/documentation/passkit/pkdeferredpaymentrequest which gives merchan tokens, but i cannot find deferred API in stripe
took the above API from https://stripe.com/docs/apple-pay/merchant-tokens#merchant-token-types
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.
As a tok_xxx? I don't believe so. still double checking just to be sure..
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
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,.createTokenisn'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
okay
If you use PaymentRequestButton instead of ECE, you can listen to token event for the PaymentRequest and get the token for Apple/Google Pay
https://stripe.com/docs/js/payment_request/events/on_token
https://stripe.com/docs/stripe-js/elements/payment-request-button
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,
});```
Can you put 0 as an amount?
no, zero is not acceptable in stripe anywhere
I am able to set 0 as the amount
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
Great, i tried zero but i keep getting error on no zero payments allowed
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.
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)
perfect
Can you get token in your demo code please? and attach response here (hide token if you can)
I used Google Pay here so tokenization method is diff
Thank you π
this above response is from paymentRequest.on('token', ()) ?
It is from the API request but it should be reflected similarly in the event handler too
yes yes right, response shall be similar
okay let me quickly give this a try, i will be back
Just tested with the event handler, the function does get the same token there too
console.log(ev.token);
ev.complete('success');
})```
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].
HI π
@crimson storm had to go so I'm stepping in. Which line is throwing the error here?
Hello,
i think it's bcz of typescript π¦
this line
i am initiating
const [paymentRequest, setPaymentRequest] = useState<PaymentRequest | null>(null);
Can you try using the code as written in our doc?
const [paymentRequest, setPaymentRequest] = useState(null);
hmm i did, was getting this error
Can you share the usEffect() code snippet?
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?
What part is intended?
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?
Yes
Sure right? then i think we were able to achieve this π
Great! I would recommend working through it in Test mode to be sure you get the behavior you are looking for.
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?
Are you using a Setup Intent to create the Payment Method?
no i am not using setupIntent, but during submission of form it will be required it seems for card verification right?
How are you saving the Payment Method to Stripe?
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
If you are not collecting payments and want to save the PM for future use I would recommend reviewing this doc https://stripe.com/docs/payments/save-and-reuse
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
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
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
in summary i will be using https://stripe.com/docs/payments/save-and-reuse?platform=web&ui=elements#submit-payment-details when i will submit the form
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
Got it
quick question
https://stripe.com/docs/payments/save-and-reuse?platform=web&ui=elements here
is it mandatory to create new customer for every transaction
await stripe.customers.create(); ?
Only when you want to create a new Customer/Payment Method.
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?
That all depends on what you are trying to do. How are these tokens/Payment Methods going to be used?
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
And this platform uses Stripe to process payments?
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
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?
yes that should work as long as the 3rd party is getting what they need on their end
Okay Great! π Thank you again for your support
We're happy to shed what π‘ we can π