Steps involved in implementing and capturing the payment form
- Create a form to capture the payment method information from customers.
- Use the Stripe JS library to create the form which will generate the input form and details will be captured in an IFrame hosted by Stripe so that you are PCI compliant.
- Call the stripe payment method api which will store the payment method and return the payment method id.
- Call the Stripe Customer API to create the customer and attach the payment method id to it.
- Call the Ordway customer’s API to update the stripe customer id with the Ordway customer for future payments via Ordway.
- Sample example source code for the below is found here: https://github.com/ordwaylabs/stripe-embedable-forms
Create Embeddable Form
- Include stripe js v3 in your html and follow the instruction mentioned in this document to initialize stripe.
https://stripe.com/docs/js/initializing
<script src="https://js.stripe.com/v3/"></script> |
2. Use the Stripe Elements to create the input form parameters using the Stripe element documentation found here: https://stripe.com/docs/js/elements_object/create
- Create a html form page with <div> tag with unique id inside which the stripe will be embedding the iframe like ‘example1-card’ in the below table.
<html> |
- Then create a javascript file ccform.js or any other javascript in which create the ‘Elements’ functions provides by the javascript Stripe library like this.
- Create a card element highlighted in orange. Provide styling as needed.
- Insert the card variable in the div element we specified above and register the element. This action embeds the element.
- Style the elements using the style object:
(function() { |
3. Invoke the payment methods API provided by the stripe JS library:
- https://stripe.com/docs/js/payment_methods/create_payment_method
- In the main index.js file, create a function for form onSubmitHandler and then call the stripe.createPaymentMethod api, passing the card element to it.
stripe.createPaymentMethod({ |
4. Create the Stripe Customer(https://stripe.com/docs/api/customers/create). Create the stripe customer and attach the payment method id generated in step 3.
-
- Creation of stripe customer is not supported by the stripe client JS library, instead it must be implemented at the server side as it requires the Stripe API key to create it.
- Sample using Ruby:
require 'stripe' |
5. Grab the customer ID from the response and pass the both stripe customer id and the payment method id gathered in Step 3 and call another API to attach the payment method to customer.
require 'stripe' |
6. Send the stripe customer Id returned from Step 4 to the Ordway Customer.
Comments
0 comments
Please sign in to leave a comment.