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.init
method 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
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-form
component 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_status
event 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-status
component 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.