#Zeeshan - PaymentElement

1 messages · Page 1 of 1 (latest)

royal trout
#

Hi there!

#

Did you pass a client_sercet to your payment element?

autumn torrent
#

yes

#

like i have done this thing as well

royal trout
#

Can you console.log the clientSecret and paste it here?

autumn torrent
#

pi_3LQrWBJUiXDWO9VH0Znx4Vds_secret_sT6ZuKFFNFueHaFaSUO0HNcQv

royal trout
#

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").

unreal laurel
#

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...'}

royal trout
#

I get the same error when using the braces. I have to omit them for me and write
Can you share your new code?

unreal laurel
#

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');
});

}

royal trout
unreal laurel
#

As I said, then I get the same error. Why the additional curly braces for the parameter, when client_secret already contains the braces?

royal trout
#

Oh so your clientSecret variable is an object?

#

And what is the error with the above code?

unreal laurel
#

There is no error, it was just a suggestion to Zeeshan to check if that could solve the problem 🙂