Integrate SDK on application side
After installing and initializing SDK:
- Initialize the payment UI specifying the payment method ID and redirect URL:
- The
headlessCheckout.form.initmethod returns an object used for further interaction with the payment UI. - The redirect URL is used to redirect the user, for example, after completing the 3-D Secure verification.
- The
Note
You can’t initialize multiple payment methods on the same page.
When initializing some payment methods, you can get the isFormAutoSubmitted: true parameter in response. It means that the step was automatically skipped because the user didn’t have to provide any data in the payment form, e.g., when paying via QR code.
Copy
- typescript
1await headlessCheckout.form.init({
2 paymentMethodId: ID,
3 returnUrl: 'returnUrl',
4});
- Add the following components to the HTML markup of the payment UI:
- Mandatory components:
psdk-legal— to display information about legal documents.psdk-total— to display the total purchase amount.
- Payment form components. You can either use the built-in
psdk-payment-formcomponent or manually create payment UI elements using the ready-to-use components. - The payment button component —
psdk-submit-button.
- Mandatory components:
Copy
- html
1<psdk-legal></psdk-legal>
2<psdk-total></psdk-total>
3
4
5<psdk-payment-form></psdk-payment-form>
6<psdk-submit-button text="Pay"></psdk-submit-button>
- Add the handling of the
check_statusevent for the payment status change.
Copy
- typescript
1headlessCheckout.form.onNextAction((nextAction) => {
2 switch (nextAction.type) {
3 case 'check_status': {
4 showStatus = true;
5 }
6 }
7});
- Add the
psdk-statuscomponent to the HTML markup of the payment UI to display a payment status.
Copy
- html
1@if (showStatus) {
2 <psdk-status></psdk-status>
3}
Was this article helpful?
Thank you for your feedback!
We’ll review your message and use it to help us improve your experience.Found a typo or other text error? Select the text and press Ctrl+Enter.