This documentation covers the integration of the Recurring Payments API, which allows merchants to process recurring transactions using stored customer card details. The process involves retrieving a customer's saved cards and initiating payments using the cardToken.

Prerequisites

Ensure the following before starting:

  1. A valid Bearer token from the Machine to Machine Authorization service.
  2. The customer ID for whom you want to process recurring payments.

Step 1: Retrieving Customer's Saved Cards

API Endpoint

GET: https://api.omno.com/transaction/customer/{customerId}/cards

Replace {customerId} with the actual customer ID.

Request Headers

  • Accept: application/json
  • Authorization: Bearer <token>

.NET Core Example

using System;
using System.Net.Http;
using System.Threading.Tasks;

namespace RecurringPayments
{
    class Program
    {
        static async Task Main(string[] args)
        {
            var client = new HttpClient();
            var bearerToken = "your_bearer_token"; // Replace with your bearer token
            var customerId = "customer_id"; // Replace with the customer's ID
            client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", bearerToken);

            try
            {
                var response = await client.GetAsync($"https://api.omno.com/transaction/customer/{customerId}/cards");
                if (response.IsSuccessStatusCode)
                {
                    var content = await response.Content.ReadAsStringAsync();
                    Console.WriteLine("Cards: " + content);
                }
                else
                {
                    Console.WriteLine("Error: " + response.StatusCode);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception occurred: " + ex.Message);
            }
        }
    }
}

Step 2: Initiating a Recurring Payment

After retrieving the cardToken, use it to initiate a payment through the Payment Generation API.

Payment API Endpoint

POST: https://api.omno.com/transaction/create

Including the CardToken

Include the cardToken field in your payment request.

.NET Core Example for Payment Initiation

using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace RecurringPayments
{
    class Program
    {
        static async Task Main(string[] args)
        {
            var client = new HttpClient();
            var bearerToken = "your_bearer_token"; // Replace with your bearer token
            var cardToken = "retrieved_card_token"; // Replace with the card token from previous step
            client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", bearerToken);

            var json = $"{{'cardToken': '{cardToken}', /* Other necessary payment fields */ }}";
            var content = new StringContent(json, Encoding.UTF8, "application/json");

            try
            {
                var response = await client.PostAsync("https://api.omno.com/transaction/create", content);
                if (response.IsSuccessStatusCode)
                {
                    var responseContent = await response.Content.ReadAsStringAsync();
                    Console.WriteLine("Payment Initiated: " + responseContent);
                }
                else
                {
                    Console.WriteLine("Error: " + response.StatusCode);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception occurred: " + ex.Message);
            }
        }
    }
}

Security and Best Practices

  • Ensure the confidentiality and integrity of all customer data.
  • Always use HTTPS for API requests.
  • Manage bearer tokens securely to prevent unauthorized access.

Next Steps

Leverage the provided .NET Core examples to integrate recurring payment functionality into your application. For further customization and additional features, explore our full API documentation.