Get an SDK
Available SDKs and code libraries for integrating with the Pinch API.
The Pinch REST API is straightforward to use, and the .NET SDK takes things further by handling authentication, pagination, and webhook verification for you. Here are the available SDKs and libraries:
| Language/Framework | SDK |
|---|---|
| C# / .NET | https://github.com/pinchpayments/Pinch.SDK |
| Postman Collection (view samples in multiple languages) | https://github.com/PinchPayments/postman-pinch-api |
If you are interested in contributing to an SDK in your own favourite language, we're happy to give you a hand. Just give us a shout.
Can't find your Language or Framework of choice?Send an email to [email protected] or book in a chat with our API team and we can help.
Getting started with the .NET SDK
Install
Install the NuGet package into your project:
dotnet add package Pinch.SDKOr via the NuGet Package Manager:
Install-Package Pinch.SDK
Configure the client
The SDK uses your Merchant ID and Secret Key (or Application ID and Secret) to authenticate. Retrieve these from the API Keys section of the Developer Portal.
using Pinch.SDK;
var settings = new PinchApiSettings
{
MerchantId = "mch_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
SecretKey = "your-secret-key",
BaseUri = "https://api.getpinch.com.au/test/" // use /live/ for production
};
var api = new PinchApi(settings);Create a payer
var payer = await api.Payers.Save(new PayerSaveOptions
{
FirstName = "Jane",
LastName = "Smith",
Email = "[email protected]",
Mobile = "0400000000"
});
Console.WriteLine($"Payer ID: {payer.Data.Id}"); // pyr_XXXXSchedule a payment
var payment = await api.Payments.Save(new ScheduledPaymentSaveOptions
{
PayerId = payer.Data.Id,
Amount = 5000, // $50.00 in cents
Description = "Monthly subscription",
TransactionDate = DateTime.UtcNow.AddDays(1)
});
Console.WriteLine($"Payment ID: {payment.Data.Id}"); // pmt_XXXXTake a realtime credit card payment
Tokenise the card first using CaptureJS, then pass the token to the SDK:
var payment = await api.Payments.ExecuteRealtime(new RealtimePaymentSaveOptions
{
FullName = "Jane Smith",
Email = "[email protected]",
CreditCardToken = "tkn_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
Amount = 5000,
Description = "One-off payment"
});
Console.WriteLine($"Payment status: {payment.Data.Status}");Handle errors
All SDK methods return a result object. Check IsSuccess before using the data:
var result = await api.Payments.Save(options);
if (!result.IsSuccess)
{
foreach (var error in result.Errors)
{
Console.WriteLine($"Error: {error.Message}");
}
}Verify webhooks
When receiving webhook events, use the SDK to verify the signature before processing:
// In your webhook controller/handler:
var isValid = api.Webhooks.VerifyWebhook(
requestBody,
pinchSignatureHeader,
webhookSecret
);
if (!isValid)
{
return Unauthorized();
}See WebhookClient.cs in the SDK source for the full verification implementation.
Switching to live mode
Change the BaseUri in your settings to the live endpoint:
BaseUri = "https://api.getpinch.com.au/live/"Your credentials are the same for both environments.
Got feedback on this feature?
Send an email to [email protected] or book in a chat with our API team.
Updated 7 days ago
