Auto-Debit

Ottu provides businesses and developers with the ability to incorporate Ottu's auto-debit functionality into their existing systems, allowing for seamless and automated payment processing.

But what is auto debit? Auto debit is a financial arrangement where a customer authorizes a company to deduct money from their account on a recurring basis. The frequency and amount of these deductions are determined in advance and can vary depending on the type of agreement, be it a subscription, a loan repayment, or any other kind of periodic payment. Imagine you are a merchant providing a monthly subscription service to your customers. Each month, you need to charge your customers, but the process becomes tedious when you have to remind them to make the payment or when they have to manually make the payment each time. This is where the auto debit functionality shines. With Ottu's Auto Debit API, you can schedule these charges automatically, ensuring seamless business operations and improving customer experience, all while saving valuable time and effort. With the power of Ottu's Auto Debit API at your fingertips, setting up recurring payments, processing one-time payments, and managing transaction records becomes a breeze. All it takes to get started is a simple integration.

In the following sections , we will guide you through the steps of installation, authentication, and how to use the various endpoints available. This will give you the tools and knowledge needed to fully leverage the capabilities of the Ottu Auto Debit API.

Before you can integrate with Ottu's Auto Debit API, there are several prerequisites that need to be fulfilled. These prerequisites are essential to ensure that the API functions correctly and securely.

  1. Payment Gateway: A Payment Gateway with auto debit enabled is required for the API to work. The Payment Gateway is a tool that authorizes and processes transactions between you and your customers. For a detailed understanding of what a Payment Gateway is and how it functions, please refer to our Payment Gateway User Guide.

  2. Checkout API: Before you call the Auto Debit API, the Checkout API must be used to create a payment transaction. This is where important details such as the amount, customer data, and more are added. Once the payment has been created via the Checkout API, a session_id will be generated. This session_id is a key parameter for the Auto Debit API.

  3. Tokenization and User Cards API: Understanding and utilizing the Tokenization and User Cards API is an essential step in the process. In order to handle transactions securely and keep sensitive data such as card information safe, Ottu uses a process called tokenization. When a user saves a card, the sensitive card data is replaced with a unique token generated by the PG. In the context of the Auto Debit API, you will need to retrieve these tokens (i.e., the saved card details of the customer) by calling the User Cards API. The tokens received from this API call are used to identify which card will be used for the auto debit process, ensuring a secure transaction without exposing sensitive customer information. Thus, getting familiar with the User Cards API and the concept of tokenization is crucial to the successful implementation of the Auto Debit API.

  4. Payment Webhook Response: Lastly, you need to be familiar with the Payment Webhook response. This response is returned by the Auto Debit API, providing important information about the transaction status.

  5. Optional: Checkout SDK as an optional but highly recommended step, you can utilize our Checkout SDK. This software development kit does the heavy lifting for you by handling tasks such as rendering all the payment methods, showing saved cards, and giving payers the option to save their card for future transactions. By integrating the Checkout SDK into your system, you can significantly streamline the payment process, enhance user experience, and ensure secure transactions. Although it's not a strict prerequisite, using the Checkout SDK can simplify your work and make the process of integrating the Auto Debit API much smoother.

Once you've fulfilled these prerequisites, you're ready to integrate the Auto Debit API. The following sections of this document will guide you through the authentication process and the usage of various API endpoints.

Ottu's Auto Debit API process involves two primary phases - The First Payment and Subsequent Payments. Let's dive into each step:

For the initial payment, the payer must be online to initiate and perform the transaction. During this process, the payer can opt to save their card for future automatic payments. Here's the flow:

  • Call Payment Methods API: Start by fetching the pg_codes (payment gateways) which are enabled for auto-debit. This can be done by calling the Payment Methods API.

  • Call Checkout API: Once you have the pg_codes, call the Checkout API to create a payment transaction. In order to provide the option for the payer to save their card for future payments, it is mandatory to include the customer_id parameter.

  • Present Payment Options to Payer: Now, present the payment options to the payer. You can either use the payment_methods response from the Checkout API or use the Checkout SDK. The SDK does the heavy lifting by rendering all payment options and capturing the payment.

  • Customer Makes Payment and Saves Card: The customer then proceeds to pay and save their card.

  • Merchant Receives Notification: Once the payment is made, your webhook_url gets notified about the payment. You can then save the card details in your database for future transactions.

After the initial payment, you can automate subsequent payments using the Auto Debit API.

  • Call Checkout API: Start by calling the Checkout API to create a payment transaction. Remember to use the pg_code associated with the saved card, and the customer_id value that was used for the initial payment.

  • Call Auto Debit API: Now, call the Auto Debit API using the session_id from the Checkout API and the card/token you wish to use to charge the customer.

  • The automated debit process is now initiated, and the payment will be processed automatically without the need for the payer to be online.

  • Keep in mind that this process assumes that the payer has agreed to have their card saved and enabled for auto-debit during the first payment.

This diagram visually represents the steps needed to set up subsequent payments. After calling the Checkout API, you then call the Auto Debit API using the session_id and card/token. The payment is then processed automatically, eliminating the need for the payer to manually authorize each transaction.

There might be instances where the card linked to automatic payments might expire or the customer may want to change the card being used. Here's how you can handle such scenarios:

  • Customer Has Other Saved Cards If the customer has other saved cards, you can fetch these by calling the User Cards API. Present the available cards to the customer and let them select the one they wish to use for ongoing payments. Save the chosen card details and use it for future transactions.

  • Customer Does Not Have Saved Cards If the customer does not have any other saved cards, you will need to repeat the process used for the first payment. The customer will need to complete a payment and save a new card.

In both cases, always remember to update the saved card information in your database for future automatic payments.

The Auto Debit API utilizes API Key Authentication to ensure secure communication and prevent unauthorized access. Before making requests to the API, you need to generate an API Key from your Ottu account. Once you have the API Key, it needs to be included in the header of each API request. To understand in detail how API Key authentication works and how you can generate your API Key, please refer to Authentication User Guide. Always ensure to keep your API Key secret. If you believe your API Key has been compromised, regenerate it immediately from your Ottu account.

For a more detailed technical understanding and the implementation specifics of these operations, please refer to the Open API schema in the API Schema Reference.

Suppose the initial payment is being made and the payer has opted to save their card details. Here's an example of a request to the Checkout API:

POST: https://<ottu-url>/b/checkout/v1/pymt-txn/
{
  "amount": "2000",
  "type": "type", // Available choices are `payment_request` or `e_commerce`.
  "currency": "USD",
  "pg_code": "PG001",
  "customer_id": "CustomerID",
  "redirect_url": "https://yourwebsite.com/return",
  "webhook_url": "https://yourwebsite.com/webhook"
}

This request will return a session_id which you need to save and use for the subsequent payments.

When making subsequent payments, the Auto Debit API will be used. Here's an example:

POST: https://<ottu-url>/b/pbl/v2/auto-debit/
{
  "session_id": "sess_123",
  "token": "token_123"
}

This request will return a response indicating whether the transaction was successful.

If the card has expired or the customer wants to switch the card, you can fetch the saved cards of the customer by calling the User Cards API. Here's an example:

GET: https:<ottu-url>/b/pbl/v2/card?type=sandbox&pg_codes=PG001&customer_id=CustomerID

This will return a list of saved cards for that customer. You can present these options to the customer and let them select the card they want to use for future payments.

For a scenario where the customer does not have other saved cards, the first payment process needs to be repeated.

Please note that the above examples are illustrative and the actual API calls would depend on the specific configuration of your Ottu setup.

Absolutely. With Ottu, you don't have to worry about PCI DSS compliance. Our platform securely handles all the sensitive data and never exposes this information to the merchant. This means you can safely implement the auto-debit feature just like any other Rest API

Yes, you certainly can. Ottu uses tokenization to ensure that your customer's Primary Account Number (PAN) is never exposed. What you receive and can safely store is a token, not an actual card number. It's structured like a card number but doesn't carry the same security risks. If you're curious about how tokenization works, you can check out this for a deeper dive.

The optimal time to save the card token in your database is immediately after the first payment against the subscription that you plan to auto-debit. While it's not strictly necessary—you can always fetch this information through the User Cards API and Payment Methods APIs—it does streamline your processes and reduce development complexity.

Currently, the only way to save a new card is by having the customer successfully complete a payment with it. At the moment, it's not possible to just save new card details directly.

No, it's not mandatory to use the Checkout SDK. You can control the payment process using the responses from the Checkout API. However, it's worth noting that the Checkout SDK simplifies the UI implementation and is necessary for certain payment methods such as Apple Pay, Google Pay, STC Pay, and others. While it's recommended to use the Checkout SDK for its simplicity and comprehensive features, the choice ultimately lies in your hands based on your specific needs.

As we come to the end of this guide to Ottu's Auto Debit API, we hope you found it comprehensive and instructive. This document has aimed to demystify the process of integrating our API into your system, equipping you with the necessary insights to employ auto-debit payments effectively. Should you have more specific queries or require further guidance, we urge you to reach out to our dedicated support team. Their expertise is available to help you navigate any complexities you encounter during integration. At Ottu, we believe in simplifying payments and enhancing user experience. We're confident that with the Auto Debit API, you'll have the tools at your disposal to achieve seamless, automated transactions. Thank you for choosing Ottu, and we look forward to powering your business's payment solutions.

Last updated