#Zeeshan - PaymentElement
1 messages · Page 1 of 1 (latest)
Can you console.log the clientSecret and paste it here?
This client secret is valid, however you are not passing it in the correct function.
It should be: stripe.elements({clientSecret}) and later elements.create("payment").
I get the same error when using the braces. I have to omit them for me and write
this.elements = this.stripe.elements( clientSecret );
without the curly braces. clientSecret contains the json result {clientSecret: 'pi_3L...'}
I get the same error when using the braces. I have to omit them for me and write
Can you share your new code?
I do it like this in my Angular test app: async initialize() {
const body = JSON.stringify({items});
this.httpPaymentService.requestClientSecret(body).subscribe(
async (client_secret: ApiResult) => {
console.log("HomePage initialize() Result: ", client_secret);
if(client_secret.clientSecret !== undefined) {
console.log("HomePage initialize() hier client secret");
this.elements = this.stripe.elements( client_secret );
const paymentElement = this.elements.create("payment");
paymentElement.mount("#payment-element");
}
},
async (error) => { //Error callback
console.error('HomePage initialize error');
});
}
Can you replace this this.elements = this.stripe.elements( client_secret );
With this: this.elements = this.stripe.elements({client_secret});
As shown here: https://stripe.com/docs/js/elements_object/create
As I said, then I get the same error. Why the additional curly braces for the parameter, when client_secret already contains the braces?
Oh so your clientSecret variable is an object?
And what is the error with the above code?
There is no error, it was just a suggestion to Zeeshan to check if that could solve the problem 🙂