Skip to main content
Orientation: Choosing Your Integration Flow, before you begin, please review the Official Integration Flow.
  • Standard Flow (Full Checkout): Recommended for most merchants. Yuno handles the UI, security, and automatic updates for payment methods.
  • Custom Flow (This SDK): Use this only if you require full control over the UX. Note: You will be responsible for manually handling payment statuses, 3DS transitions, and fraud routing data collection.

Yuno’s Headless SDK lets you create payments. Note that when using the Headless SDK, you will need to request and send via API all the mandatory fields the payment provider requires to generate payment in their API. Yuno’s Headless SDK enables you to create payments in two different scenarios:
  • Create a One-Time Use Token using credit card information, then create a payment.
  • Create a One-Time Use Token using a vaulted_token from a previously enrolled credit card, then create a payment.
The following steps describe creating a payment using Yuno’s Headless SDK.

Step 1: Include the library in your project

Before proceeding with the Headless SDK implementation, see the SDK Integration Overview for detailed instructions on how to properly integrate the SDK into your project. The integration guide provides three flexible methods:
  1. Direct HTML script inclusion
  2. Dynamic JavaScript injection
  3. NPM module installation
Choose the integration method that best suits your development workflow and technical requirements. After completing the SDK integration, you can proceed with the following steps to implement the Headless checkout functionality.
TypeScript LibraryIf you are using TypeScript, Yuno provides a library that you can use to see all available methods in the Yuno Web SDK.

Step 2: Initialize Headless SDK with the public key

In your JavaScript application, create an instance of the Yuno class by providing a valid PUBLIC_API_KEY.
CredentialsSee the credentials page for more information: /reference/getting-started/authentication

Step 3: Start the checkout process

Next, you will start the checkout process using the apiClientPayment function, providing the necessary configuration parameters.

Parameters

Configure the payment with the following options:

Step 4: Generate token

After collecting all user information, you can start the payment. First, you need to create a one-time token (OTT) using the function apiClientpayment.generateToken. As it is an asynchronous function, you can use try/catch to ensure you will correctly handle triggered errors. The following examples show different scenarios to create the one-time token:
  1. Example 1: Create a one-time token utilizing a card as the payment method and including all requisite card information.
  2. Example 2: Create a one-time token using the vaulted_token information.
Benefits of Using a Vaulted TokenWhen you use a vaulted token with the SDK, all the fraud information from the providers you configured in your card routing is collected and attached to the one-time token. In addition, you can add installment information and a security code if the provider requires it.
Example 1

Parameters for Example 1

Example 2

Parameters for Example 2

The following code block shows the apiClientPayment.generateToken function responses for both examples above:
Example 1
Example 2

Step 5: Create the Payment

After receiving the one-time token, you can create the payment using the Create Payment endpoint to get the final payment result. You will inform the one-time token received in Step 4 through the request’s payment_method.token parameter. The following code block shows a request example for creating a payment:
The endpoint response provides the sdk_action_required parameter that defines if additional actions are necessary to conclude the payment:
  • If your customer selects a synchronous payment method, the payment is completed instantly. In this scenario, the field sdk_action_required in the API response will be false, and the payment process concludes at this step.
  • When an additional interaction of the SDK is needed to complete the payment flow, sdk_action_required will be true. If this is the case, you need to follow the instructions from Step 6.

Step 6: Get the 3DS challenge URL

As described on the 3DS Card Verification page, a payment with 3DS may require an additional challenge to check the customer’s identity. If an additional verification step is necessary related to a 3DS verification challenge, the response to the Create Payment endpoint will have the following information:
  • A THREE_D_SECURE transaction type.
  • Status equal to PENDING and sub status equal to WAITING_ADDITIONAL_STEP.
  • The sdk_action_required set as true.
To get the 3DS challenge URL, you should call the getThreeDSecureChallenge function, providing the checkoutSession used to create the payment.
If the card does not require a challenge to verify the customer’s identity, the url will return null. In a web browser, you can open the URL in a new tab or an IFrame. To open the URL in an iframe, you must set the param embedded = true. If not, you can omit this parameter, whose default value is false. The following code block shows an example of displaying the 3DS challenge content in an IFrame:
You are responsible for redirecting your customers to the URL provided by the redirect_url to complete the challenge. Once the customer successfully completes the 3DS challenge, they will be automatically redirected to the callback_url, which you provided when creating the checkout_session with the Create Checkout Session endpoint. To complete the Headless SDK payment flow, you need to use Yuno Webhooks, which will promptly notify you about the outcome of the 3DS challenge and the final payment status. Using webhooks ensures that you receive real-time updates on the progress of the payment transaction. In addition to the webhooks, you can retrieve the payment information using the Retrieve Payment by ID endpoint.

Step 7: Get payment actions

Sometimes the payment may require an extra action to continue the payment flow. To determine what action is needed, you should call the getContinuePaymentAction method, providing the checkoutSession used to create the payment.
The getContinuePaymentAction method returns a ContinuePaymentAction object that describes the specific action required to continue the payment flow, depending on the provider and the specific step required.

ContinuePaymentAction response structure

The response contains information about the type of action required and the necessary data to perform that action:

ContinuePaymentAction Fields

Provider Types and Actions

The following enums define the supported payment providers and possible actions:

Provider Types and Actions

Handling different action types

Based on the action field in the response, you should handle each type of action accordingly:

REDIRECT_URL Action

When the action is REDIRECT_URL, you should redirect the user to the URL provided in data.redirect.init_url:

Other Action Types

Each action type requires specific handling based on the data provided:
  • PAYMENT_CODE: Display the payment code and reference to the user
  • IMAGE: Show a QR code or other image to the user
  • OTP: Present an OTP input form to the user
  • SDK_PROVIDER: Initialize the specific provider’s SDK
  • RENDER_IFRAME: Display an iframe with the provider’s interface
Payment Action HandlingThe specific implementation for handling each action type will depend on your application’s UI framework and requirements. Ensure you handle all possible action types that your configured payment providers might return.
Demo AppIn addition to the code examples provided, you can access the Demo App for a complete implementation of Yuno SDKs (clone from the repository).

Error handling

Handle errors returned by the SDK in your app (e.g. failed payments, validation errors). For HTTP status and response codes, see Status and response codes in the API reference. To refund a payment, see Refund payments and the Refund payment API.

Stay Updated

Visit the changelog for the latest SDK updates and version history.