This method initiates a new payment associated with merchant generated transaction to be finalised by the customer using bank/MNO digital channels. You are required to setup payrequest.success and payrequest.reversed webhook events. For payload explanations for both request and response, click here
using OneKhusa.SDK;
using OneKhusa.SDK.Models.Transactions.Collections;
//code omitted for brevity
OneKhusaResponse<RequestToPayResponse> response = await client
.Transactions
.Collections
.CreateRequestToPayAsync(new RequestToPayRequest
{
MerchantAccountNumber = 12345678,
ReferenceNumber = "OK0987654321",
TransactionAmount = 6500000.00M,
TransactionDescription = "Samsung 85inch TV purchase",
CapturedBy = "joe.doe@example.com"
});
if (response is { IsSuccess: true, Data: not null })
{
Console.WriteLine($"""
MerchantAccountNumber: {response.Data.MerchantAccountNumber};
TimedAccountNumber: {response.Data.TimedAccountNumber};
ExpiryDate: {response.Data.ExpiryDate};
ExpiryInMinutes: {response.Data.ExpiryInMinutes}
""");
return;
}
//it means an error has occurred: RFC7807 compliant error object
Console.WriteLine($"""
Type: {response.Error?.Type};
Title: {response.Error?.Title};
Detail: {response.Error?.Detail};
ErrorCode: {response.Error?.ErrorCode};
Status: {response.Error?.Status};
Instance: {response.Error?.Instance};
Errors: {string.Join(";", response.Error?.Errors ?? [])}
""");
Console.ReadLine();
Note: This method accepts custom idempotency key generated by your system. By default, if not specified, it will create one on your behalf.