Accept Dynamic Stripe Payments via API

Learn how to integrate dynamic Stripe payments using Corvid (a.k.a. Wix Code) and the Stripe API. Stripe is a leading alternative to PayPal and features a more streamlined payments process for end users.

​This example allows you to choose between membership options and then pay via Stripe. When a paid membership option is chosen, a Stripe credit card form will appear to facilitate the payment. This example is set to 'test mode' and therefore does not accept real credit card numbers. Try the example below with this dummy credit card number 4000005540000008 for a successful payment or 4000000000009995 for a declined payment.

Try it!
#txtMessage
<Payment Message>
arrow&amp;v

The following page code imports the API functions from the public and backend code pages. The createCard function creates a card object from the card input variables, and passes that to the API functions to create a token for processing the Stripe payment. This code should be adapted for your website needs, whereas the page and backend code can remain 'as is' except for adding your public and secret API keys which you can obtain from Stripe.com once you make an account with them. The amount passed to the Stripe API is in cents, so must be multiplied by 100 if the value is taken in dollars.

Page Code

The following code is placed in the public and backend pages as stipulated. They can be implemented 'as is', except for the public and secret API key's which you will get upon creating a Stripe account. Replace 'test' API keys with 'live' API keys once you are happy that your code works as expected.

Public Code

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Backend Code

Please wait ...
Disclaimer: To the best of our knowledge, this code works for its stipulated purpose. If you find an error in our code, or know of a better way to achieve the same result - please contact us! All our code snippets come with full support to help you implement them on your own website - simply contact us for help.