Installation
Prerequisites
- Node.js 16.0 or higher
- npm, yarn, or pnpm (package manager)
- Access to Yabetoo API (API keys)
- An active Yabetoo account
Installation via npm
To install the SDK, use npm, yarn, or pnpm. Run one of the following commands in your project:Configuration
SDK Initialization
Before using the SDK, you must initialize an instance of theYabetoo class. Simply provide your API key during initialization. The SDK automatically detects whether you are in test or production mode based on your key prefix.
Advanced Configuration
You can customize the SDK behavior with additional options:Payment Management with Yabetoo
You can create payments, retrieve information about specific payments, and manage payments using thepayments resource.
Yabetoo operates on a two-step payment model. This means that to process a payment, you must first create a payment intent and then confirm that intent to capture the amount.
This approach offers increased flexibility, allowing you, for example, to verify available funds or obtain user authorization before finalizing a transaction. Here’s how it works step by step:
- Create a payment intent: You create a payment intent specifying the amount, currency, and other relevant details.
- Confirm the payment intent: Once you’ve created the intent, you can confirm it to capture the amount. This can be done immediately or at a later date, depending on your needs.
- Manage payments: You can retrieve payment information, cancel payments, or handle other transaction-related aspects.
Create a Payment Intent
A payment intent is a resource that represents your wish to receive a payment for a specific amount. When you create a payment intent, you don’t immediately capture the amount; it’s a preparatory step.id) for the payment intent that you’ll use during confirmation.
Confirm a Payment Intent
After creating the payment intent, you must confirm it to capture the amount. This typically occurs when the end user has completed all necessary steps (such as providing payment information or accepting terms and conditions).Error Handling During Confirmation
It’s important to handle errors because confirming a payment intent can fail for various reasons (insufficient funds, incorrect payment information, etc.).
Retrieve Payment Details
To retrieve information about an existing payment, use the payment ID as a parameter:List All Your Payments
To retrieve a list of all your payments, use theall method. You can also filter payments by status or other criteria if needed.
Advanced Filtering and Sorting
Using Payment Sessions with Yabetoo
With Yabetoo, you can create payment sessions that allow your users to go through a hosted payment page. This page is fully managed and secured by Yabetoo, simplifying online payment integration while ensuring transaction compliance and security.What is a Payment Session?
A payment session is an instance that generates a unique URL pointing to a payment page hosted by Yabetoo. This page allows your customers to complete their payment simply and securely, without you having to directly manage sensitive details like credit card or mobile money information.Advantages of Using a Payment Session
Using a hosted payment page offers several advantages for you as a developer or merchant:- Security: Yabetoo handles payment security, allowing you to focus on your application.
- Compliance: By using a hosted payment page, you reduce your PCI compliance burden since Yabetoo manages sensitive information.
- User Experience: The payment page is optimized to provide a smooth and fast user experience.
- Customization: You can customize the payment page appearance to match your brand.
Create a Payment Session
Payment sessions allow you to create a secure and smooth payment process for your users. This session redirects the user to a hosted payment page to finalize the transaction.How the Payment Session Works
1
Session Creation
When you create a session, you send information about the items, total amount, currency, and redirect URLs (for success or cancellation).
2
Hosted Payment Page
Yabetoo returns a unique URL that you can use to redirect your users to the hosted payment page.
3
Payment Confirmation
Once the payment is successfully completed, the user is redirected to the URL you defined in
successUrl, with transaction details. If the user cancels, they will be redirected to the URL defined in cancelUrl.Redirect After Payment
When the payment is made via the payment page hosted by Yabetoo, you will be redirected to the URL you defined in thesuccessUrl field. Yabetoo automatically adds a parameter to this URL: the payment ID. This payment ID is crucial for verifying payment details and performing a double verification of the payment status.
It’s important to always perform this double verification to ensure the security and integrity of your payment process.