#How to add card details and generate stripe token using Relation manager form?

6 messages · Page 1 of 1 (latest)

violet sleet
#

Hello,

I am using stripe-php to add card information to Stripe and using card details relation manager for customers.
I am able to add the card details in the self hosted form but Stripe requires us to generate token by sending card details using their Javascript api which I can send by dispatching the Livewire event but I am not able to set the value for the token field with the class card_token on the form after getting response from Stripe.
Please let me know how can I generate the token, validate it and set the token as value for card_token textinput before submitting the form.

Thank you

radiant anvilBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

violet sleet
#

Here is the custom.js file code

document.addEventListener('livewire:init', () => {
Livewire.on('generate-stripe-token', (event) => {
// stripe token generate process here

    console.log("test");
    token = "token here"; // get the token from stripe


    document.getElementsByClassName("card_token")[0].value = token;

});

});

#

Here is the CreateAction

#

and the form

violet sleet
#

Please someone help with this issue.