Headless SDK (Enrollment)
The Headless SDK provides a solution to enrol customers’ payment methods for a frictionless purchase experience. In addition, you have complete control of your UX/UI using our payment_method_token. To use the Headless SDK for payment Enrollment, follow the next steps:
Step 1: Create a customer
To initiate the enrollment process, you need to create a customer to associate payment methods with it. Otherwise, the enrollment process is not possible. You can create a customer using the Create Customer endpoint. You will receive the customer's id
created in Yuno.
You can skip this step if you have created the customer before.
Step 2: Create a customer session
To enrol payment methods in an existing customer, you need to create a customer_session
using the Create Customer Session endpoint. Each enrollment needs a new customer_session, which allows you to access all available payment methods for enrollment and extend these options to your customers. To create the customer_session
, you need to provide the customer id
created in the previous step.
Step 3: Retrieve and display the payment methods
To access all payment methods available for your customer, call the Retrieve Payment Methods endpoint using the customer_session
. You can enable or disable payment methods using the Checkout Builder within the Yuno dashboard.
After receiving the payment methods available, display them so your customers can select the one they want to enrol in.
When utilizing the Headless SDK, you are responsible for showcasing the available payment methods and collecting the customer's selection. You're also responsible for collecting all necessary information about the payment method. For card payments, you must collect all the required card details.
Step 4: Enroll the payment method
Once your customer selects the payment method they want to enrol with your platform, you need to call the Enroll Payment Method endpoint. The Yuno system will evaluate if an additional step is required to complete the enrollment. The endpoint response will return the enrollment.sdk_required_action
parameter, which will inform you if an extra step is needed:
- If
sdk_required_action = true,
you need to use the Headless SDK to continue the enrollment process. In addition, the endpoint response will contain theREADY_TO_ENROLL
status, which indicates that you need to perform additional action to complete the enrollment. This extra step is necessary to acquire the payment details from your customer. See Step 5 for further information on what to do. - If
sdk_required_action = false
, you have successfully enrolled the payment method into your customer profile, and the enrollment process ends. In this case, the status can beENROLLED
orDECLINED
.
The Enroll Payment Method endpoint response will also provide the enrollment information and an id
. The id
is the vaulted_token
, which you can save in your system and use to create future payments if the final status received is ENROLLED
.
Step 5: Finish the enrollment using the Headless SDK
This step is only necessary if you have received enrollment.sdk_required_action = true
in Step 4.
After starting the enrollment in Step 4, you will use the Headless SDK to capture and share the payment method details with Yuno.
PCI Compliance
Please bear in mind that you are capturing sensitive card data. Therefore, you need to comply with good practices regarding data management. If you don't have a PCI certification, you can't save any card data other than the token provided by the SDK.
To conclude the enrollment using the Headless SDK, follow the steps below where you need to inform your credentials and the customer_session
created previously:
- Include the library in your project.
- Initialize the SDK with your public key, which you will find in the Developers section of the Yuno dashboard.
- Configure SDK by calling the function
yuno.apiClientEnroll
with the desired configuration. - Use the
apiClientEnroll. continueEnrollment
function to obtain the payment method enrollment information, including thevaulted_token
and enrollment status. The status will inform you if the enrollment was successful.
For more detailed information on how to initiate Yuno's SDK, refer to one of the following sections according to the corresponding platform:
Webhook confirmation
Not all payment methods have a synchronous enrollment process. For these payment methods, when you use the apiClientEnroll.continueEnrollment
function, the received status might inform you that the enrollment is in progress. As a result, you should use Webhooks to confirm that the enrollment was successful.
Step 6: Webhook confirmation
The enrollment process is asynchronous. Therefore, you should use Webhooksto obtain the final enrollment status.
At the end of the process, you will receive the enrollment status, enrollment information, and the vaulted_token
, equal to the id
received when in Step 4.
In the case of a successful enrollment, the final status will be ENROLLED
, you can save the vaulted_token
in your system and use it to create future payments.
Updated 25 days ago