SDK

Integrate AlphaX Payments into your web application with our flexible and customizable SDK.
View as Markdown

Obtain Public Client Key

Visit AlphaX’s dashboard, go to Developers > Public Clients and create a new Public Client.

Once you have created the Public Client, you will be able to see the Public Client Key. This key is essential for integrating the AlphaX Payments SDK into your web application.

Inject the SDK

https://alphax-payment-sdk.b-cdn.net/main/payment-sdk.js

To integrate the AlphaX Payments SDK into your web application, include the following script tag in your HTML:

1<script src="https://alphax-payment-sdk.b-cdn.net/main/payment-sdk.js"></script>

Please don’t download the SDK and host it on your own server, as we will be updating the SDK regularly to add new features and fix bugs. By using the CDN link, you will always have access to the latest version of the SDK without needing to manually update it.

Initialize the SDK

After including the SDK script in your HTML, you can initialize the SDK using the following code:

1await AlphaXPayment.init({
2 clientId: '<your_client_id_here>',
3 environment: 'production', // available: production, demo
4 onInitialized() {
5 // on initialized, do your stuff
6 },
7 onPaymentSucceeded(res) {
8 // when we submit the payment and it's all good, this function will be triggered
9 // you will have the order information in "res"
10 console.log('Payment succeeded', res);
11 },
12 onPaymentFailed(error) {
13 // When it fails to charge the user, you can use the "error" to show up to your
14 // customer
15 console.error('Payment failed', error);
16 },
17});

Create a Payment Element

To create a payment element, use the following code:

1await AlphaXPayment.createPaymentElement({
2 // Pass your unique orderID here
3 orderId: 'order' + Date.now(),
4 amount: 10.50,
5 currency: 'USD',
6 mountElement: '#payment',
7 firstName: 'John', // not required
8 lastName: 'Snow', // not required
9});