The interactive walkthrough displays code examples alongside step-by-step explanations.
Follow the walkthrough to use the SDK in your C# code.
{/* Hidden markdown content for server rendering and AI ingestion */}
/// Import required namespaces
Import the Payabli SDK to make it available in your code.
```csharp
// Program.cs
using PayabliApi;
```
/// Initialize the client
Create an authenticated client instance with your API key. This client has methods that call Payabli's API endpoints.
```csharp focus=4
// Program.cs
using PayabliApi;
var client = new PayabliApiClient("REPLACE_WITH_YOUR_API_KEY");
```
/// Define the entrypoint
Define your entrypoint. Get this value from your Payabli account.
```csharp focus=6
// Program.cs
using PayabliApi;
var client = new PayabliApiClient("REPLACE_WITH_YOUR_API_KEY");
var entrypoint = "REPLACE_WITH_YOUR_ENTRYPOINT";
```
/// Build the payment request
Construct a request object that contains all the necessary fields to process a transaction. Include payment details, a payment method, and customer data.
```csharp focus=8-32
// Program.cs
using PayabliApi;
var client = new PayabliApiClient("REPLACE_WITH_YOUR_API_KEY");
var entrypoint = "REPLACE_WITH_YOUR_ENTRYPOINT";
var request = new RequestPayment
{
Body = new TransRequestBody
{
CustomerData = new PayorDataRequest
{
CustomerId = 4440,
},
EntryPoint = entrypoint,
Ipaddress = "255.255.255.255",
PaymentDetails = new PaymentDetail
{
ServiceFee = 0,
TotalAmount = 100,
},
PaymentMethod = new PayMethodCredit
{
Cardcvv = "999",
Cardexp = "02/27",
CardHolder = "Kassiane Cassian",
Cardnumber = "4111111111111111",
Cardzip = "12345",
Initiator = "payor",
Method = "card",
},
},
};
```
/// Execute the transaction
Call `MoneyIn.GetpaidAsync()` to process the transaction. The client calls Payabli's `POST /MoneyIn/getpaid` endpoint.
```csharp focus=36-39
// Program.cs
using PayabliApi;
var client = new PayabliApiClient("REPLACE_WITH_YOUR_API_KEY");
var entrypoint = "REPLACE_WITH_YOUR_ENTRYPOINT";
var request = new RequestPayment
{
Body = new TransRequestBody
{
CustomerData = new PayorDataRequest
{
CustomerId = 4440,
},
EntryPoint = entrypoint,
Ipaddress = "255.255.255.255",
PaymentDetails = new PaymentDetail
{
ServiceFee = 0,
TotalAmount = 100,
},
PaymentMethod = new PayMethodCredit
{
Cardcvv = "999",
Cardexp = "02/27",
CardHolder = "Kassiane Cassian",
Cardnumber = "4111111111111111",
Cardzip = "12345",
Initiator = "payor",
Method = "card",
},
},
};
var result = await client.MoneyIn.GetpaidAsync(new RequestPayment
{
Body = request.Body,
});
```
/// Show the result
Log the transaction response. Check the output to see if the transaction was successful.
```csharp focus=41-47
// Program.cs
using PayabliApi;
var client = new PayabliApiClient("REPLACE_WITH_YOUR_API_KEY");
var entrypoint = "REPLACE_WITH_YOUR_ENTRYPOINT";
var request = new RequestPayment
{
Body = new TransRequestBody
{
CustomerData = new PayorDataRequest
{
CustomerId = 4440,
},
EntryPoint = entrypoint,
Ipaddress = "255.255.255.255",
PaymentDetails = new PaymentDetail
{
ServiceFee = 0,
TotalAmount = 100,
},
PaymentMethod = new PayMethodCredit
{
Cardcvv = "999",
Cardexp = "02/27",
CardHolder = "Kassiane Cassian",
Cardnumber = "4111111111111111",
Cardzip = "12345",
Initiator = "payor",
Method = "card",
},
},
};
var result = await client.MoneyIn.GetpaidAsync(new RequestPayment
{
Body = request.Body,
});
Console.WriteLine($"Response: {result.ResponseText}");
Console.WriteLine($"Success: {result.IsSuccess}");
if (result.ResponseData != null)
{
Console.WriteLine($"Reference ID: {result.ResponseData.ReferenceId}");
Console.WriteLine($"Result: {result.ResponseData.ResultText}");
}
```