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:

  1. Open the Solution Explorer.
  2. Right-click on a project within your solution.
  3. Click on Manage NuGet Packages...
  4. Click on the Browse tab and search for "PingPayments.PaymentLinks".
  5. 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:

  1. Create a Ping Payment Links Client.

  2. Call the List() method.

    1. await api.PaymentLinks.V1.List();
      
  3. Handle response.

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

  1. Create a Ping Payment Links Client.

  2. Call the Create() method with a createPaymentLinkRequest.

    1. await api.PaymentLinks.V1.Create(createPaymentLinkRequest);
      
  3. Handle response.

Parameters

ParameterTypeRequierdDescription
createPaymentLinkRequestCreatePaymentLinkRequestYesRequest 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

  1. Create a Ping Payment Links Client.

  2. Call the Get() method with a Payment Link Id.

    1. await api.PaymentLinks.V1.Get(paymentLinkId);
      
  3. Handle response.

Parameters

ParameterTypeRequierdDescription
paymentLinkId GuidYesID 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

  1. Create a Ping Payment Links Client.
  2. Call the Cancel() method with a Payment Link Id
    1. await api.PaymentLinks.V1.Cancel(paymentLinkId);
      
  3. Handle response.

Parameters

ParameterTypeRequierdDescription
paymentLinkId GuidYesID 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

  1. Create a Ping Payment Links Client.
  2. Call the Send() method with a Payment Link Id and a send sendRequest.
    1. await api.PaymentLinks.V1.Send(paymentLinkId, sendRequest);
      
  3. Handle response.

Parameters

ParameterTypeRequierdDescription
paymentLinkId GuidYesID of a specific Payment Link.
sendRequestSendPaymentLinkRequestBodyYesRequest 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

  1. Create a Ping Payment Links Client.
  2. Call the Get() method with a Payment Link Id.
    1. Guid paymentLinkId = Guid.parse("3b19b19f-d096-4556-885d-a1cae5bb9911D");
      await api.Invoice.V1.Get(paymentLinkId);
      
  3. Handle response.
ParameterTypeRequierdDescription
paymentLinkId GuidYesId 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

  1. Create a Ping Payment Links Client.
  2. Call the Create() method with a Payment Link Id and a createRequest.
    1. await api.Invoice.V1.Create(paymentLinkId, createRequest);
      
  3. Handle response.

Parameters

ParameterTypeRequierdDescription
paymentLinkId GuidYesId of a specific Payment Link
createRequestCreateInvoiceRequestYesObject 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

  1. Create a Ping Payment Links Client.
  2. Call the Get() method with a Payment Link Id.
    1. await api.Receipt.V1.Create(paymentLinkId);
      
  3. Handle response.

Parameters

ParameterTypeRequierdDescription
paymentLinkId GuidYesId 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"
}