Custom Checkout Integration
If you prefer to create a custom implementation for integrating Coinsub subscription payments without using the provided widget, you can directly create a form that posts to the Coinsub server. Below is a guide on how to achieve this.
1. Creating a Custom Form
You can create a custom HTML form that collects the necessary data and posts it to the Coinsub server. Here’s an example of how to set up such a form:
2. Explanation of the Code
Form Structure:
The form uses the POST method and points to the URL for creating a subscription payment:
https://buy.coinsub.io/YOUR_PRODUCT_CODE
.Replace
YOUR_PRODUCT_CODE
with your actual product code found on the product's widget page obtained from the Coinsub Merchant UI.
Hidden Input Field:
The form includes a hidden input field to pass customer data. This field is populated with a JSON string containing customer information.
Submit Button:
A styled submit button is provided for users to initiate the payment process. You can customize its appearance using CSS.
JavaScript:
JavaScript is used to set the customer data in the hidden field dynamically. You can customize the customer data object as needed.
An optional event listener is added to perform any additional logic before the form is submitted.
3. Customizing the Form
Button Customization:
You can customize the button's appearance using CSS. Modify the
.subscription-button
class to change colors, padding, font size, etc.
Customer Data:
Customize the
customerData
object to include the relevant customer information required for the transaction.
Additional Fields:
If you need to collect more data from the user, you can add additional input fields to the form.
4. Example Use Case
Here’s an example use case for integrating a custom subscription form on your website:
With this approach, you have full control over the form and its submission process, allowing for greater flexibility and customization to suit your specific needs. For further integration details, refer to the Coinsub API documentation or contact our support team.
Last updated