Payment Links API
Manages the following endpoints: Payment Links, Invoice and Receipt.
The Payment Links solution allow a seller to accept payments electronically. For more information regarding Payment Links click here.
Installation
dotnet CLI
Install the latest SDK using dotnet CLI:
dotnet add package PingPayment.PaymentLinks
NuGet.exe
Install the latest SDK using NuGet.exe:
nuget install PingPayment.PaymentLinks
Visual Studio
From within Visual Studio:
- Open the Solution Explorer.
- Right-click on a project within your solution.
- Click on Manage NuGet Packages...
- Click on the Browse tab and search for "PingPayments.PaymentLinks".
- Click on the PingPayments.PaymentLinks package, select the appropriate version in the right-tab and click Install.
Client
The client exposes all enpoints and It's operations that let you create and interact with Payment Links through your Ping Payments account. Ping Payment Links Client uses the Http Client for sending and receiving HTTP responses.
Ping Payment Links Client
The using
directive allows you to use types defined in a namespace without specifying the fully qualified namespace of that type. Add the following using directive from the PingPayments.PaymentLinksApi
namespace:
using PingPayments.PaymentLinksApi;
Initializing the client with a valid Tenant Id and an appropriate environment.
- For testing use the Sandbox environment,
PingEnvironments.SandboxUri
. - For Production use
PingEnvironments.ProductionUri
.
var tenantId = Configuration["PingPayments:TenantId"];
var httpClient = new HttpClient().ConfigurePingPaymentsClient(PingEnvironments.PaymentLinksApi.SandboxUri, tenantId);
var api = new PingPaymentLinksApiClient(httpClient);
Or use Dependency injection
services.AddHttpClient<IPingPaymentLinksApiClient, PingPaymentLinksApiClient>(client =>
{
var tenantId = Configuration["PingPayments:TenantId"];
client.ConfigurePingPaymentsClient(PingEnvironments.PaymentLinksApi.SandboxUri, tenantId);
});
Verify the connection
Use the Ping endpont to verify the connection to the API.
Payment Links (Endpoint)
The Payment Links enpoint exposes several methods dedicated to dealing with payment Link objects.
Methods
List Payment Links
Gets and returns a list of all Payment Link objects for a Tenant.
Usage:
-
Create a Ping Payment Links Client.
-
Call the
List()
method.await api.PaymentLinks.V1.List();
Returns
A list of all Payment Link objects for a valid Tenant, or an error response.
Example Usage
var response = await api.PaymentLinks.V1.List();
Response
200 OK
[
{
"checkout_url": "string",
"customer": {
"email": "string",
"first_name": "string",
"last_name": "string",
"phone": "string",
"reference": "string"
},
"delivery_address": {
"city": "string",
"street_address": "string",
"zip": "string"
},
"distributed_by_email": true,
"due_date": "string",
"invoice_address": {
"city": "string",
"street_address": "string",
"zip": "string"
},
"invoice_created": true,
"items": [
{
"description": "string",
"item_number": "string",
"merchant_id": "55555555-5555-5555-5555-555555555555",
"price": 0,
"quantity": 0,
"unit": "string",
"vat": 0
}
],
"locale": "sv-SE",
"logo_image_link": "string",
"metadata": {},
"payment_id": "55555555-5555-5555-5555-555555555555",
"payment_link_id": "55555555-5555-5555-5555-555555555555",
"payment_link_status_callback_url": "string",
"payment_order_id": "55555555-5555-5555-5555-555555555555",
"payment_provider_methods": [
{
"method": "card",
"parameters": {},
"provider": "verifone"
}
],
"sms_status": "DELIVERED",
"status": "CREATED",
"tenant_id": "string",
"total_amount": 0
}
]
Create a Payment Link
Creates a Payment Link.
Usage
-
Create a Ping Payment Links Client.
-
Call the
Create()
method with acreatePaymentLinkRequest
.await api.PaymentLinks.V1.Create(createPaymentLinkRequest);
Parameters
Parameter | Type | Requierd | Description |
---|---|---|---|
createPaymentLinkRequest | CreatePaymentLinkRequest | Yes | Request body |
Returns
An object containing a checkout url and a Payment Link Id, or an error response.
Example Usage
var paymentLinkRequest = new CreatePaymentLinkRequest
(
orderId,
CurrencyEnum.SEK,
customer,
Locale.Swedish,
items,
suppler,
new PaymentProviderMethod[]
{
swishMcommmerce,
billmate,
}
);
var response = await api.PaymentLinks.V1.Create(paymentLinkRequest);
Response
200 OK
{
"checkout_url": "string",
"id": "string"
}
Get Payment link
Gets and returns a specific Payment Link.
Usage
-
Create a Ping Payment Links Client.
-
Call the
Get()
method with a Payment Link Id.await api.PaymentLinks.V1.Get(paymentLinkId);
Parameters
Parameter | Type | Requierd | Description |
---|---|---|---|
paymentLinkId | Guid | Yes | ID of a specific Payment Link. |
Returns
Object of a Payment Link, or an error response.
Example Usage:
Guid paymentLinkId = Guid.parse("e41913e4-f642-478b-b77a-dd5ab25c1e33");
var response = await api.PaymentLinks.V1.Get(paymentLinkId);
Response
200 OK
{
"checkout_url": "string",
"customer": {
"email": "string",
"first_name": "string",
"last_name": "string",
"phone": "string",
"reference": "string"
},
"delivery_address": {
"city": "string",
"street_address": "string",
"zip": "string"
},
"distributed_by_email": true,
"due_date": "string",
"invoice_address": {
"city": "string",
"street_address": "string",
"zip": "string"
},
"invoice_created": true,
"items": [
{
"description": "string",
"item_number": "string",
"merchant_id": "55555555-5555-5555-5555-555555555555",
"price": 100,
"quantity": 1,
"unit": "string",
"vat": 12
}
],
"locale": "sv-SE",
"logo_image_link": "string",
"metadata": {},
"payment_id": "55555555-5555-5555-5555-555555555555",
"payment_link_id": "55555555-5555-5555-5555-555555555555",
"payment_link_status_callback_url": "string",
"payment_order_id": "55555555-5555-5555-5555-555555555555",
"payment_provider_methods": [
{
"method": "card",
"parameters": {},
"provider": "verifone"
}
],
"sms_status": "DELIVERED",
"status": "CREATED",
"tenant_id": "string",
"total_amount": 100
}
Cancel Payment Link
Cancels a specific Payment Link.
Usage
- Create a Ping Payment Links Client.
- Call the
Cancel()
method with a Payment Link Idawait api.PaymentLinks.V1.Cancel(paymentLinkId);
- Handle response.
Parameters
Parameter | Type | Requierd | Description |
---|---|---|---|
paymentLinkId | Guid | Yes | ID of a specific Payment Link. |
Returns
An Empty Response, or an error response.
Example Usage
Guid paymentLinkId = Guid.parse("e41913e4-f642-478b-b77a-dd5ab25c1e33");
var response = await api.PaymentLinks.V1.Cancel(paymentLinkId);
Response
204 No content
{}
Send Payment Link
Sends Payment Link via SMS and/or email to the Payer.
Usage
- Create a Ping Payment Links Client.
- Call the
Send()
method with a Payment Link Id and a sendsendRequest
.await api.PaymentLinks.V1.Send(paymentLinkId, sendRequest);
- Handle response.
Parameters
Parameter | Type | Requierd | Description |
---|---|---|---|
paymentLinkId | Guid | Yes | ID of a specific Payment Link. |
sendRequest | SendPaymentLinkRequestBody | Yes | Request body containing the distribute method and required information for the chosen method. |
Returns
An Empty Response, or an error response.
Example Usage
Guid paymentLinkId = Guid.parse("e41913e4-f642-478b-b77a-dd5ab25c1e33");
var sendRequest = DistributeMethod.Sms.New("0700000000");
var response = await api.PaymentLinks.V1.Send(paymentLinkId, sendRequest);
Response
204 No content
{}
Invoice (Endpoint)
The invoice endpoint exposes two methods dedicated to dealing with invoices of Payment Links.
Methods
Get Invoice
Gets and returns an url to a invoice.
Usage
- Create a Ping Payment Links Client.
- Call the
Get()
method with a Payment Link Id.Guid paymentLinkId = Guid.parse("3b19b19f-d096-4556-885d-a1cae5bb9911D"); await api.Invoice.V1.Get(paymentLinkId);
- Handle response.
Parameter | Type | Requierd | Description |
---|---|---|---|
paymentLinkId | Guid | Yes | Id of a specific Payment Link |
Returns
Url, reference and a reference type for an invoice of a Payment Link, or an error response.
Example Usage
var response = await api.Invoice.V1.Get(paymentLinkId);
Response
200 OK
{
"reference_type": "string",
"reference": "string",
"url": "string"
}
Create Invoice
Creates an Invoice for the given Payment Link. Can only be used once for each Payment Link
Usage
- Create a Ping Payment Links Client.
- Call the
Create()
method with a Payment Link Id and acreateRequest
.await api.Invoice.V1.Create(paymentLinkId, createRequest);
- Handle response.
Parameters
Parameter | Type | Requierd | Description |
---|---|---|---|
paymentLinkId | Guid | Yes | Id of a specific Payment Link |
createRequest | CreateInvoiceRequest | Yes | Object containing DokumentName (string Not Required) and ReferenceType (Enum: KID, OCR Required) |
Returns
Empty response, or an error response.
Example Usage
CreateInvoiceRequest requestBody = new(ReferenceTypeEnum.KID);
Guid paymentLinkId = Guid.parse("3b19b19f-d096-4556-885d-a1cae5bb9911D");
var response = await api.Invoice.V1.Create(paymentLinkId, requestBody);
Response
204 No content
{}
Receipt (Endpoint)
The Receipt endpoint exposes a Get method dedicated to dealing with Receipts of Payment Links.
Methods
Get Receipt
Gets and returns an url to a receipt of a completed Payment Link.
Usage
- Create a Ping Payment Links Client.
- Call the
Get()
method with a Payment Link Id.await api.Receipt.V1.Create(paymentLinkId);
- Handle response.
Parameters
Parameter | Type | Requierd | Description |
---|---|---|---|
paymentLinkId | Guid | Yes | Id of a specific payment link |
Returns
Url for a receipt of a payment link, or an error response.
Example Usage
Guid paymentLinkId = Guid.parse("3b19b19f-d096-4556-885d-a1cae5bb9911D");
var response = await api.Receipt.V1.Get(paymentLinkId);
Response
200 OK
{
"url": "string"
}
Updated 3 months ago