This feature represents the self-hosted service by OneKhusa to simplify checkout process initiated by the third-party systems being supported by Request To Pay feature. For payload explanations for both request and response, click here
using OneKhusa.SDK;
using OneKhusa.SDK.Models.Transactions.Collections;
//code omitted for brevity
OneKhusaResponse<InitiateRtpCheckoutPaymentResponse> response = await client
.Transactions
.Collections
.InitiateRequestToPayCheckoutAsync(new InitiateRtpCheckoutPaymentRequest
{
Payment = new CheckoutPaymentTransactionDto
{
Amount = 15000.00M,
Description = "Groceries Payment",
SourceReferenceNumber = "QWSFCTXF233433"
},
Route = new CheckoutRouteDto
{
CallbackApiUrl = "API-URL",
SuccessRedirectionUrl = "SUCCESS-REDIRECTION-URL",
FailureRedirectionUrl = "FAILURE-REDIRECTION-URL"
}
});
if (response is { IsSuccess: true, Data: not null })
{
Console.WriteLine($"""
MerchantAccountNumber: {response.Data.MerchantAccountNumber};
SourceReferenceNumber: {response.Data.SourceReferenceNumber};
PaymentTransactionId: {response.Data.PaymentTransactionId}
""");
Console.ReadLine();
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.