C#
Setting up the Infrastructure
Install the following packages via our NuGet feed at https://baget.klogs.io/v3/index.json:
Klogs.PaymentGateway.ClientKlogs.PaymentGateway.Client.Abstraction
Then configure the services in your .NET 6+ application:
builder.Services.AddPaymentGatewayClient(opt =>
{
opt.Endpoint = "https://test-pgw.klogs.io/";
opt.AccessTokenFactory = sp =>
{
var cache = sp.GetService<IDistributedCache>();
var act = new KlogsIdpClientSecretCredential(new Klogs.Identity.Core.ClientSecretCredentialOptions
{
ClientId = "klogs.api",
Secret = "key",
Source = new Uri("https://idp.klogs.io")
}).GetToken().AccessToken;
return act;
};
});After entering the provided key in the Secret section, your infrastructure integration is complete. Congratulations!
Redirecting to Hosted Payment Page
Inject the
IHostedPaymentHttpClientinterface provided byKlogs.PaymentGateway.Client.Abstractionvia constructor injection.Use the
_hostedPaymentHttpClient.CreatePayment()method to generate the hosted payment page URL.The
CreatePaymentmethod requires theHostedPaymentRequestmodel fromKlogs.PaymentGateway.Client.Abstraction.Model.HostedPayment.HostedPaymentRequest Fields:
Amount- decimal (Amount to be collected)Currency- string (TRY, USD, EUR)FullName- string (Customer's full name)NationalNumber- string (Customer's national ID number, mandatory for some POS providers like Iyzico, Sipay)Email- string (Customer's email address)Explanation- string (Description)Phone- string (Customer's phone number)Reference- string (Unique reference number required for later inquiries)ReturnURL- string (URL to redirect to after payment)ChargeType- enum (UseKlogs.PaymentGateway.Abstraction.Types.SalesType, eitherDirectSaleorProvision)Products- array of Product (List of products related to payment)
- Product Fields (Klogs.System.Types.Product):
Id- string (Product ID)Price- decimal (Product price)Quantity- double (Product quantity)Category- string (Product category)Code- string (Product code)Description- string (Product description)
After following the above steps, a request is sent and a successful response returns the hosted payment page URL.
Redirect the customer to the URL where they will enter their card details and complete the payment.
After payment, the system redirects automatically to the
ReturnURLprovided.To check the payment status, you need to create a request using another service.
Inject the
IPaymentTransactionHttpClientinterface via constructor injection.Use the
_paymentTransactionHttpClient.DetailAsync()method to query the payment status using the reference number.The response will be a
TransactionDetailResponsemodel fromKlogs.PaymentGateway.Client.Abstraction.Model.Transaction.

