Payments API

Manages the following endpoints: Tenant, Merchant, Payment Order, Payments, Disbursements, Poke and Signing keys

Installation

dotnet CLI

Install the latest SDK using dotnet CLI:

dotnet add package PingPayment.Payments

NuGet.exe

Install the latest SDK using NuGet.exe:

nuget install PingPayment.Payments

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.Payments".
  5. Click on the PingPayments.Payments 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 Payments through your Ping Payments account. Ping Payments Client uses the Http Client for sending and receiving HTTP responses.

Ping Payments 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.PaymentsApi namespace:

using PingPayments.PaymentsApi;

Initializing the client with a valid Tenant Id and an appropriate environment.

  • For testing use the Sandbox environment, PingEnvironments.PaymentsApi.SandboxUri.
  • For Production use PingEnvironments.PaymentsApi.ProductionUri.
var tenantId = Configuration["PingPayments:TenantId"];
var httpClient = new HttpClient().ConfigurePingPaymentsClient(PingEnvironments.PaymentsApi.SandboxUri, tenantId);
var api = new PingPaymentsApiClient(httpClient);

Or use Dependency injection

services.AddHttpClient<IPingPaymentsApiClient, PingPaymentsApiClient>(client =>
{
    var tenantId = Configuration["PingPayments:TenantId"];
    client.ConfigurePingPaymentsClient(PingEnvironments.PaymentsApi.SandboxUri, tenantId);
});

Verify the connection

Use the Ping endpont to verify the connection to the API.


Tenant (Endpoint)

The Tenant endpoint provides access to two methods for managing your tenant.

Methods


Get Tenant

Get and returns information about your Tenant.

Usage

  1. Create a Ping Payments Api Client.
  2. Call the Get() method.
    1. await api.Tenants.V1.Get();
      
  3. Handle response

Returns

Object with information about the tenant, or an error response.


Example Usage

//Call the API
var response = await api.Tenants.V1.Get();

Response

200 OK

{
  "callback_signing_key": "QXJlIHlvdSB0cnlpbmcgdG8gc3RlYWwgbXkga2V5Pw==",
  "credit_accounts": [
    {
      "balance": 470000,
      "currency": "SEK"
    },
    {
      "balance": 0,
      "currency": "NOK"
    }
  ],
  "disbursement_callback_url": "https://some-host.net/some-path",
  "id": "bda47b95-04ad-4a58-a0a1-78961a2d0fdc",
  "merchant_status_callback_url": "https://some-host.net",
  "name": "A tenant",
  "organization": {
    "country": "SE",
    "no_organization_number": null,
    "se_organization_number": "5555555555"
  },
  "payment_provider_methods": [
    {
      "method": "credit",
      "provider": "ping"
    },
    {
      "method": "deposit",
      "provider": "ping"
    }
  ]
}

Update Tenant

Allows you to update the callbacks for your tenant.

Usage

  1. Create a Ping Payments Api Client.
  2. Call the Update() method with a updateTenantRequest:
    1. await api.Tenants.V1.Update(updateTenantRequest);
      
  3. Handle response

Parameters

ParameterTypeRequierdDescription
updateTenantRequestUpdateTenantRequestYesRequest body

Returns

Empty response, or an error response.


Example Usage

Uri creditAccountTopUpCallbackUrl = new("https://some-host.net");
Uri merchantStatusCallbackUrl = new("https://some-host.net");

// Create a UpdateTenantRequest
 var updateTenantRequest = new UpdateTenantRequest(creditAccountTopUpCallbackUrl, merchantStatusCallbackUrl);

//Call the API
var response = await api.Tenants.V1.Update(updateTenantRequest);

Response

204 No content

{}


Merchant (Endpoint)

The Merchant endpoint offers several methods for managing merchants.

Methods


List Merchants

Get an list of Merchant.

Usage:

  1. Create a Ping Payments Api Client.
  2. Call the List() method:
    1. await api.Merchant.V1.List();
      
  3. Handle response

Returns

An object with a list of merchants for a Tenant, or an error response.


Example Usage

var response = await api.Merchants.V1.List();

Response

200 OK

[
  {
    "email": "[email protected]",
    "id": "55555555-5555-5555-5555-555555555555",
    "name": "Merchant A",
    "organization": {
      "country": "NO",
      "no_organization_number": "555555555"
    },
    "phone_number": "0731231234",
    "status": "APPROVED"
  },
  {
    "email": "[email protected]",
    "id": "55555555-5555-5555-5555-555555555555",
    "name": "Merchant B",
    "organization": {
      "country": "SE",
      "se_organization_number": "555555-5555"
    },
    "phone_number": "0705555555",
    "status": "CREATED"
  }
]

Create Merchant

Create a new Merchant.

Usage

  1. Create a Ping Payments Api Client.
  2. Call the Create() method with a merchantRequest:
    1. await api.Merchant.V1.Create(merchantRequest);
      
  3. Handle response

Parameters

ParameterTypeRequierdDescription
merchantRequestCreateMerchantRequestYesRequest body

Returns

Id of the merchant that got created, or an error response.

Example Usage

// Create a merchant request
var merchantRequest = new CreateMerchantRequest
{
    Name = "test merchant AB",
    Organization = new Organization
    {
        Country = "SE",
        SeOrganizationNumber = "1234567890"
    }
};

//Call the API
var response = await api.Merchants.V1.Create(merchantRequest);

Response

200 OK

{
  "id": "04cd9fcf-7172-4b41-a52a-98c23948c854"
}


Get Merchant

Retrieves information about a specific Merchant.

Usage

  1. Create a Ping Payments Api Client.
  2. Call the Get() method with a merchantId:
    1. await api.Merchant.V1.Get(merchantId);
      
  3. Handle response

Parameters

ParameterTypeRequierdDescription
merchantId GuidYesGuid of a specific merchant

Returns

Object of a merchant with the given Merchant Id, or an error response.


Example Usage

//Get a merchant Id 
Guid merchantId = Guid.Parse("892ab762-17a2-45bc-b216-7220c961a88d"); 

//Call the API
var response = await api.Merchants.V1.Get(merchantId);

Response

200 OK

{
  "email": "[email protected]",
  "id": "7446a43c-7063-481e-a959-e8adda12bd09",
  "name": "Merchant",
  "organization": {
    "country": "SE",
    "se_organization_number": "555555-5555"
  },
  "phone_number": "0705555555",
  "status": "APPROVED",
  "refund": {
  	"amount": 100,
    refunded_at: "11-11-2011"
  }
}


Payment Order (Endpoint)

The Payment Order endpoint provides access to several methods for managing payment orders, which are containers for all payments related to a single purchase. These methods include:

Methods


List Payment Orders

Retrieves a list of payment orders for your tenant..

Usage

  1. Create a Ping Payments Api Client.
  2. Call the List() method. You can use an optional date range argument containing from and to values to limit the list of Payment Order objects returned.
    1. await api.PaymentOrder.V1.List(from, to);
      
  3. Handle response

Parameters:

ParameterTypeRequierdDescription
from DateTimeOffsetNoStart date for the range.
to DateTimeOffsetNoEnd date for the range.

Returns

Object with a list of Payment Order objects for a Tenant, or an error response.


Example Usage

// Get from and to date interval 
var from = new DateTimeOffset(2022, 01, 01, 0, 0, 0, TimeSpan.Zero);
var to = from.AddMonths(6);

//Make call to API
var response = await api.PaymentOrder.V1.List((from, to));

Response

200 OK

[
   {
      "created_at":"2021-11-05T10:04:19.275000Z",
      "currency":"SEK",
      "id":"55555555-5555-5555-5555-555555555555",
      "payments":[
         {
            "created_at":"2021-11-15T09:15:01.400000Z",
            "currency":"SEK",
            "id":"55555555-5555-5555-5555-555555555555",
            "payments":[
               {
                  "currency":"SEK",
                  "id":"55555555-5555-5555-5555-555555555555",
                  "metadata":{
                     
                  },
                  "method":"m_commerce",
                  "order_items":[
                     
                  ],
                  "provider":"swish",
                  "status":"INITIATED",
                  "status_history":[
                     {
                        "details":null,
                        "occurred_at":"2022-06-15T12:00:33.714179Z",
                        "status":"INITIATED"
                     }
                  ]
               },
               {
                  "currency":"SEK",
                  "id":"55555555-5555-5555-5555-555555555555",
                  "metadata":{
                     
                  },
                  "method":"m_commerce",
                  "order_items":[
                     
                  ],
                  "provider":"swish",
                  "status":"ABORTED",
                  "status_history":[
                     {
                        "details":null,
                        "occurred_at":"2022-06-15T12:00:33.714179Z",
                        "status":"INITIATED"
                     },
                     {
                        "details":null,
                        "occurred_at":"2022-06-15T12:01:32.714179Z",
                        "status":"ABORTED"
                     }
                  ]
               },
               {
                  "currency":"SEK",
                  "id":"55555555-5555-5555-5555-555555555555",
                  "metadata":{
                     
                  },
                  "method":"m_commerce",
                  "order_items":[
                     
                  ],
                  "provider":"swish",
                  "status":"COMPLETED",
                  "status_history":[
                     {
                        "details":null,
                        "occurred_at":"2022-06-15T12:00:33.714179Z",
                        "status":"INITIATED"
                     },
                     {
                        "details":null,
                        "occurred_at":"2022-06-15T12:01:30.714179Z",
                        "status":"PENDING"
                     },
                     {
                        "details":null,
                        "occurred_at":"2022-06-15T12:01:32.714179Z",
                        "status":"COMPLETED"
                     }
                  ]
               },
               {
                  "currency":"SEK",
                  "id":"55555555-5555-5555-5555-555555555555",
                  "metadata":{
                     
                  },
                  "method":"m_commerce",
                  "order_items":[
                     
                  ],
                  "provider":"swish",
                  "status":"COMPLETED",
                  "status_history":[
                     {
                        "details":null,
                        "occurred_at":"2022-06-15T12:00:33.714179Z",
                        "status":"INITIATED"
                     },
                     {
                        "details":null,
                        "occurred_at":"2022-06-15T12:01:30.714179Z",
                        "status":"PENDING"
                     },
                     {
                        "details":null,
                        "occurred_at":"2022-06-15T12:01:32.714179Z",
                        "status":"COMPLETED"
                     }
                  ]
               },
               {
                  "currency":"SEK",
                  "id":"55555555-5555-5555-5555-555555555555",
                  "metadata":{
                     
                  },
                  "method":"m_commerce",
                  "order_items":[
                     
                  ],
                  "provider":"swish",
                  "status":"ABORTED",
                  "status_history":[
                     {
                        "details":null,
                        "occurred_at":"2022-06-15T12:00:33.714179Z",
                        "status":"INITIATED"
                     },
                     {
                        "details":null,
                        "occurred_at":"2022-06-15T12:01:30.714179Z",
                        "status":"PENDING"
                     },
                     {
                        "details":null,
                        "occurred_at":"2022-06-15T12:01:32.714179Z",
                        "status":"ABORTED"
                     }
                  ]
               }
            ],
            "status":"OPEN"
         }
      ]


Create Payment Order

Creates a new Payment Order connected to a Split Tree datastructure.

Usage

  1. Create a Ping Payments Api Client.
  2. Call the Create() method with a paymentOrderRequest:
    1. await api.PaymentOrder.V1.Create(paymentOrderRequest);
      
  3. Handle response

Parameters

ParameterTypeRequierdDescription
paymentOrderRequestCreatePaymentOrderRequestYesRequest body

Returns

Object containing a Payment Order Id of the created Payment Order, or an error response.


Example Usage

//Create a Payment Order request
var paymentOrderRequest = new CreatePaymentOrderRequest(CurrencyEnum.SEK);

//Make call to API
var response = await api.PaymentOrder.V1.Create(paymentOrderRequest);

Response

200 OK

{
  "id": "55555555-5555-5555-5555-555555555555"
}


Get Payment Order

Gets a specific Payment Order associated with a Tenant.

Usage

  1. Create a Ping Payments Api Client.
  2. Call the Get() method with a PaymentOrderId:
    1. await api.PaymentOrder.V1.Get(paymentOrderId);
      
  3. Handle response

Paramaters:

ParameterTypeRequiredDescription
PaymentOrderId GuidYesGuid of a specific payment Order

Returns

A Payment Order object, or an error response.


Example Usage

//Get payment order id  
Guid paymentOrderId = Guid.Parse("3d5ad038-f2ca-4390-b8c6-75566ae85146");

//Make call to API
var response = await api.PaymentOrder.V1.Get(paymentOrderId);

Response

200 OK

{
  "created_at": "2021-11-15T09:15:01.400000Z",
  "currency": "SEK",
  "id": "55555555-5555-5555-5555-555555555555",
  "payments": [
    {
      "currency": "SEK",
      "id": "55555555-5555-5555-5555-555555555555",
      "metadata": {},
      "method": "m_commerce",
      "order_items": [],
      "provider": "swish",
      "status": "INITIATED",
      "status_history": [
        {
          "at": "2022-06-15T12:00:33.714179Z",
          "details": null,
          "status": "INITIATED"
        }
      ]
    },
    {
      "currency": "SEK",
      "id": "55555555-5555-5555-5555-555555555555",
      "metadata": {},
      "method": "m_commerce",
      "order_items": [],
      "provider": "swish",
      "status": "COMPLETED",
      "status_history": [
        {
          "at": "2022-06-15T12:00:33.714179Z",
          "details": null,
          "status": "INITIATED"
        },
        {
          "at": "2022-06-15T12:01:32.714179Z",
          "details": null,
          "status": "PENDING"
        },
        {
          "at": "2022-06-15T12:03:33.714179Z",
          "details": null,
          "status": "COMPLETED"
        }
      ]
    },
    {
      "currency": "SEK",
      "id": "55555555-5555-5555-5555-555555555555",
      "metadata": {},
      "method": "m_commerce",
      "order_items": [
        {
          "amount": 850,
          "merchant_id": "55555555-5555-5555-5555-555555555555",
          "name": "Utkörning, Pizza",
          "vat_rate": 12
        }
      ],
      "provider": "swish",
      "status": "PENDING",
      "status_history": [
        {
          "details": null,
          "occurred_at": "2022-06-15T12:00:33.714179Z",
          "status": "INITIATED"
        },
        {
          "details": null,
          "occurred_at": "2022-06-15T12:01:32.714179Z",
          "status": "PENDING"
        }
      ]
    }
  ],
  "status": "OPEN"
}


Update Payment Order

Updates a Payment Order with a new Split Tree Id and potential related parameters.

Usage

  1. Create a Ping Payments Api Client.
  2. Call the Update() method with a paymentOrderId , splitTreeId and opptional splitParameters:
    1. await api.PaymentOrder.V1.Update((paymentOrderId, splitTreeId, splitParameters));
      
  3. Handle response

Parameters:

ParameterTypeRequiredDescription
paymentOrderID GuidYesGuid of a specific Payment Order
splitTreeId GuidYesGuid of the new Split Tree to be used.
splitParameters Dictionary<string, dynamic>NoParameters used to control parts of the split tree

Returns

Returns an empty response, or an error response.


Example Usage

//Get Payment Order Id and split tree Id 
var paymentOrderId = Guid.Parse("80f478a8-506c-466b-b9e2-fbd728f3dfef");
var splitTreeId = Guid.Parse("f44e2f6e-d3da-4322-9f05-6c3ef7a0796b");

//Make call to API
var response = await api.PaymentOrder.V1.Update((paymentOrderId, splitTreeId));

Response

204 No content

{}


Allocations for Payment Order

Get Allocations for a PaymentOrder.

Usage

  1. Create a Ping Payments Api Client.
  2. Call the Allocations() method with a paymentOrderId:
    1. await api.PaymentOrder.V1.Allocations(paymentOrderId);
      
  3. Handle response

Parameters

ParameterTypeRequierdDescription
paymentOrderId GuidYesGuid for a Payment Order

Returns

An array of allocations, or an error response.


Example Usage

//Get Payment Order Id 
var paymentOrderId = Guid.Parse("80f478a8-506c-466b-b9e2-fbd728f3dfef");

//Make call to API
await api.PaymentOrder.V1.Allocations(paymentOrderId);

Response

200 OK

[
  {
    "allocated_at": "2022-10-06T09:37:28.371Z",
    "amount": 12300,
    "disbursement_id": null,
    "id": "384f3be5-7e24-4058-96f3-f096a6429df4",
    "label": null,
    "merchant_id": "8402ae75-225a-4d50-82a9-05bce6d4d999",
    "metadata": {
      "article_number": 50
    },
    "payment_id": "214f1f17-b5a8-49e8-bb4a-d748572598f4",
    "payment_order_id": "6fa581c3-ebf9-404e-867d-52c8da437853",
    "recipient_name": "recipient name",
    "recipient_type": "merchant"
  }
]


Closed Payment Order

Closes a Payment Order. No further Payments can be added to the Payment Order. Refunds are still possible at this stage.

Usage

  1. Create a Ping Payments Api Client.
  2. Call the Close() method with a paymentOrderId:
    1. await api.PaymentOrder.V1.Close(paymentOrderId);
      
  3. Handle response

Parameters:

ParameterTypeRequiredDescription
paymentOrderId GuidYesGuid of a specific payment order

Returns

Returns an empty response, or an error response.


Example Usage

//Get Payment Order Id 
var paymentOrderId = Guid.Parse("80f478a8-506c-466b-b9e2-fbd728f3dfef");

//Make call to API
var response = await api.PaymentOrder.V1.Close(paymentOrderId);

Response

204 No content

{}


Split Payment Order

Splits a Payment Order according to its Split Tree. Partial refunds are possible at this stage.

Usage

  1. Create a Ping Payments Api Client.
  2. Call the Split() method with a paymentOrderId:
    1. await api.PaymentOrder.V1.Split(paymentOrderId);
      
  3. Handle response

Parameters:

ParameterTypeRequiredDescription
paymentOrderId GuidYesGuid of a specific payment order

Returns

Returns an empty response, or an error response.


Example Usage

//Get Payment Order Id 
var paymentOrderId = Guid.Parse("80f478a8-506c-466b-b9e2-fbd728f3dfef");

//Make call to API
var response = await api.PaymentOrder.V1.Split(paymentOrderId);

Response

204 No content

{}


Settled Payment Order

Settles a Payment Order. The final stage of a Payment Order. Refunds are not possible at this stage.

Usage

  1. Create a Ping Payments Api Client.
  2. Call the Settle() method with a paymentOrderId:
    1. await api.PaymentOrder.V1.Settle(paymentOrderId);
      
  3. Handle response

Parameters:

ParameterTypeRequiredDescription
paymentOrderId GuidYesId of a specific payment order

Returns

Returns an empty response, or an error response.


Example Usage

//Get Payment Order Id 
var paymentOrderId = Guid.Parse("80f478a8-506c-466b-b9e2-fbd728f3dfef");

//Make call to API
var response = await api.PaymentOrder.V1.Settle(paymentOrderId);

Response

204 No content

{}


Payment (Endpoint)

The Payment endpoint provides access to five methods for managing payments.

Methods


Initiate Payment

Initiates new Payment.

Usage

  1. Create a Ping Payments Api Client.
  2. Call the Initiate() method with a paymentOrderId and initatePaymentRequest:
    1. await api.Payments.V1.Initiate(paymentOrderId, initatePaymentRequest); 
      
  3. Handle response

Parameters

ParameterTypeRequiredDescription
initatePaymentRequestInitiatePaymentRequestYesRequest body
paymentOrderId GuidYesGuid of a payment Order

Returns

An payment Object , or an error response.


Example Usage

// Get Mechant Id and Payment Order Id 
var merchantId = Guid.Parse("53a273d5-1a8b-4a79-b817-e8b0caff7c4f");
var paymentOrderId = Guid.Parse("9737673d-e4c8-4fba-9697-88f3812e843c");

// Prepare request
var orderItems = new OrderItem
(
    100.ToMinorCurrencyUnit(),
    "A test article",
    SwedishVat.Vat25,
    merchantId
).InList();

// Create request
var InitiatePaymentRequest = CreatePayment.Swish.Mcommerce
(
    orderItems,
    "This message will be shown to the payer",
    new Uri("https://my-callback.my-api.com")
);

// Make call to API 
var response = await api.Payments.V1.Initiate(paymentOrderId, InitiatePaymentRequest);

Response

200 OK

{
  "id":"52d526b9-83f8-4879-b2bb-0155bfc27f57",
  "provider_method_response": {
    "payment_request_token": "-P3RvSYrQQqNFhY3lyFgBy6hCg1qFGdz",
    "qr_code": null,
    "swish_url": "swish://paymentrequest?token=c28a4061470f4af48973bd2a4642b4fa&callbackurl=merchant%253A%252F%252F"
  }
}


Get Payment

Get a specific Payment.

Usage

  1. Create a Ping Payments Api Client.
  2. Call the Get() method with paymentOrderId and paymentId
    1. await api.Payments.V1.Get(paymentOrderId, paymentId); 
      
  3. Handle response

Parameters

ParameterTypeRequiredDescription
paymentId GuidYesGuid of a payment
paymentOrderId GuidYesGuid of a payment order

Returns

A Payment object , or an error response.


Example Usage

//Get payment Id and Payment Order Id 
var paymentId = new Guid("398bcbdc-eec5-4f05-ade2-0e54f4b6b918");
var paymentOrderId = new Guid("097f8325-ad1a-49d1-9453-db7f6beedf5b");

//Make call to API 
var response = await api.Payments.V1.Get(paymentOrderId, paymentId);

Response

200 OK

{
  "currency": "SEK",
  "id": "380cad75-db1a-4aa4-b19c-7581148d7174",
  "metadata": {
    "delivery_id": "230955"
  },
  "method": "e_commerce",
  "order_items": [
    {
      "amount": 850,
      "merchant_id": "00328a14-fd85-4c08-a02b-7ecbeed110d1",
      "metadata": {
        "article_number": 50
      },
      "name": "Utkörning, Pizza",
      "vat_rate": 12
    }
  ],
  "provider": "swish",
  "status": "DECLINED",
  "status_history": [
    {
      "details": null,
      "id": "30328a14-fd85-4c08-a02b-7ecbeed110d2",
      "occurred_at": "2022-06-15T12:00:33.714179Z",
      "status": "INITIATED"
    },
    {
      "details": null,
      "id": "10328a14-fd85-4c08-a02b-7ecbeed110d1",
      "occurred_at": "2022-06-15T12:01:32.714179Z",
      "status": "PENDING"
    },
    {
      "details": {
        "provider_data": {
          "errorCode": "RF07",
          "errorReason": "Transaction declined"
        }
      },
      "occurred_at": "2022-06-15T12:03:33.714179Z",
      "status": "DECLINED"
    }
  ],
  "total_amount": 850
}


Update Payment

Updates a specific Payment.

Usage

  1. Create a Ping Payments Api Client.
  2. Call the Update() method with paymentOrderId, paymentId and updatePaymentRequest:
    1. await api.Payments.V1.Update(paymentOrderId, paymentId, updatePaymentRequest);
      
  3. Handle response

Parameters

ParameterTypeRequiredDescription
paymentId GuidYesGuid of a payment
paymentOrderId GuidYesGuid of a payment order
updatePaymentRequestUpdatePaymentRequestYesRequest body

Returns

Empty response , or an error response.


Example Usage

// Get Payment Id, Payment Order Id and Merchant Id
Guid paymentId = Guid.Parse("52e5990e-7f33-49dc-bd49-5e994e845525");
Guid paymentOrderId = Guid.Parse("3294c207-f261-4ccf-9fe5-f2147de982d1");
Guid merchantId = Guid.Parse("1a1770fa-428a-42d0-8308-b06a991ab60a");

// Update the items for the  purchase 
var newOrderItems = new OrderItem[]
{
	new OrderItem(100.ToMinorCurrencyUnit(), "Name of item", SwedishVat.Vat25, merchantId),
  	new OrderItem(200.ToMinorCurrencyUnit(), "Name of item", SwedishVat.Vat12, merchantId),
};

// Create a UpdatePaymentRequest 
var updatePaymentRequest = new UpdatePaymentRequest(newOrderItems);

// Make call to API
var response = await _api.Payments.V1.Update(paymentOrderId, paymentId, updatePaymentRequest);
          

Response

204 No content

{}


Reconcile Payment Funding

Reconcile the difference between expected amount and the received amount.

Usage

  1. Create a Ping Payments Api Client.
  2. Call the Reconcile() method with paymentOrderId, paymentId and orderItems:
    1. await api.Payments.V1.Update(paymentOrderId, paymentId, orderItems);
      
  3. Handle response

Parameters

ParameterTypeRequiredDescription
paymentId GuidYesGuid of a deposit payment
paymentOrderId GuidYesGuid of a payment order containing that payment.
orderItemsOrderItem[]NoArray of order items. Can be omitted when reconciling a payment with status FUNDED.

Returns

Empty response , or an error response.


Example Usage

// Get Payment Id, Payment Order Id and Merchant Id
Guid paymentId = new("52e5990e-7f33-49dc-bd49-5e994e845525");
Guid paymentOrderId = new("3294c207-f261-4ccf-9fe5-f2147de982d1");
Guid merchantId = new("1a1770fa-428a-42d0-8308-b06a991ab60a");

// Update the value for the order items of purchase to match the deposited amount 
var orderItems = new OrderItem[]
{
	new OrderItem(100.ToMinorCurrencyUnit(), "Name of item", SwedishVat.Vat25, merchantId),
  new OrderItem(100.ToMinorCurrencyUnit(), "Name of item", SwedishVat.Vat12, merchantId),
};

// Make call to API
var response = await _api.Payments.V1.Reconcile(paymentOrderId, paymentId, orderItems);
          

Response

204 No content

{}


Stop Payment

Stops a specific Payment.

Usage

  1. Create a Ping Payments Api Client.
  2. Call the Stop() method with paymentOrderId and paymentId:
    1. api.Payments.V1.Stop(paymentOrderId, paymentId);
      
  3. Handle response

Parameters

ParameterTypeRequiredDescription
paymentId GuidYesGuid of a payment
paymentOrderId GuidYesGuid of a payment order

Returns

Empty response , or an error response.


Example Usage

// Get Payment Id and Payment Order Id 
Guid paymentId = Guid.Parse("52e5990e-7f33-49dc-bd49-5e994e845525");
Guid paymentOrderId = Guid.Parse("3294c207-f261-4ccf-9fe5-f2147de982d1");

// Make call to API 
var response = await _api.Payments.V1.Stop(paymentOrderId, paymentId);
          

Response

204 No content

{}


Payout (Endpoint)

The Payout endpoint provides access to two methods for managing payouts.

Methods


List Payout

Returns a list of Payouts objects for a Tenant.

Usage

  1. Create a Ping Payments Api Client.
  2. Call the List() method. You can use an optional date range argument containing from and to values to limit the list of payouts to be returned.
    1. await api.Payouts.V1.List((from, to));
      
  3. Handle response

Parameters:

ParameterTypeRequierdDescription
from DateTimeOffsetNoStart date for the range. Format: YYYY-MM-DD.
to DateTimeOffsetNoEnd date for the range. Format: YYYY-MM-DD.

Returns

A list of Payouts, or an error response.


Example Usage

var from = new DateTimeOffset(2022, 01, 01, 0, 0, 0, TimeSpan.Zero);
var to = from.AddMonths(12);

//Make call to API
var response = await api.Payouts.V1.List((from, to));

Response

200 OK

[
  {
    "amount": 1000,
    "completed_at": "string",
    "currency": "SEK",
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
  },
   {
    "amount": 1500,
    "completed_at": "string",
    "currency": "SEK",
    "id": "c9b2c4b9-2613-41aa-974f-7f642553c963"
  },
   {
    "amount": 100,
    "completed_at": "string",
    "currency": "SEK",
    "id": "7fa82904-c83d-4d1e-89a6-ca74e57b6faa"
  }
]


Get Payout

Get a specific Payment.

Usage

  1. Create a Ping Payments Api Client.
  2. Call the Get() method with an payoutId.
    1. await api.Payouts.V1.Get(payoutId);
      
  3. Handle response

Parameters

ParameterTypeRequiredDescription
payoutId GuidYesGuid of a payout.

Returns

A Payout object , or an error response.


Example Usage

//Get payout Id as Guid 
var payoutId =  Guid.Parse("5413c79b-0e48-47b6-8233-ac64c13b15a5");

//Make call to API 
var response = await api.Payments.V1.Get(payoutId);

Response

200 OK

{
  "amount": 1000,
  "completed_at": "string",
  "currency": "SEK",
  "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
}


Disbursements (Endpoint)

The Disbursement endpoint offers two methods for accessing disbursement information.

Methods


List Disbursements

Get an list of Disbursements connected to a Tenant.

Usage:

  1. Create a Ping Payments Api Client.
  2. Call the List() method. You can use an optional date range argument containing from and to values to limit the list of Disbursements to be returned.
    1. await api.Disbursements.V1.List((from, to));
      
  3. Handle response

Parameters:

ParameterTypeRequierdDescription
from DateTimeOffsetNoStart date for the range.
to DateTimeOffsetNoEnd date for the range.

Returns

An object connating a list of disbursements, or an error response.


Example Usage

var from = new DateTimeOffset(2022, 01, 01, 0, 0, 0, TimeSpan.Zero);
var to = from.AddMonths(12);

var response = await api.Disbursements.V1.List((from, to));

Response

200 OK

{
  "disbursements": [
    {
      "disbursed_at": "2022-09-15T11:28:27.618208Z",
      "id": "2d041d6d-21c9-4c65-96eb-5b9047732417"
    }
  ]
}


Get Disbursement

Get a specific Disbursement connected to a Tenant.

Usage

  1. Create a Ping Payments Api Client.
  2. Call the Get() method with a disbursementId:
    1. await api.Disbursement.V1.Get(disbursementId);
      
  3. Handle response

Parameters

ParameterTypeRequierdDescription
disbursementId GuidYesGuid of a specific disbursement

Returns

An object with information about a specific Disbursement, or an error response.


Example Usage

//Get a Disbursement Id 
Guid disbursementId = Guid.Parse("7754d563-0b6d-422b-85dc-a9e52c33aac7");

//Call the API
var response = await api.Disbursement.V1.Get(disbursementId);

Response

200 OK

{
  "currency": "string",
  "disbursed_at": "2022-11-29T12:24:23.489Z",
  "id": "string",
  "manual_corrections": [
    {
      "amount": 3100,
      "name": "Organization name",
      "organization": {
        "counrty": "SE",
        "no_organization_number": null,
        "se_organization_number": "5839103817"
      },
      "person": null
    }
  ],
  "settlements": [
    {
      "allocation_id": "64bd0ccf-27ae-4e32-92d2-3f8e817c8a60",
      "amount": 350000,
      "id": "93bd0c75-6375-4f55-b765-e1928abae17f",
      "label": null,
      "merchant_id": "8a1b459f-1617-4ff4-a874-5baeed16cb29",
      "metadata": {
        "article_number": 50
      },
      "payment_id": "214f1f17-b5a8-49e8-bb4a-d748572598f4",
      "payment_order_id": "6fa581c3-ebf9-404e-867d-52c8da437853",
      "recipient_name": "recipient name",
      "recipient_type": "merchant",
      "reference": "Ping*01337"
    }
  ]
}


Poke (Endpoint)

The Poke endpoint exposes one method that triggers a poke callback to the given target callback URL.

Method


Requests Poke

Triggers a poke callback to the given callback url.

Usage:

  1. Create a Ping Payments Api Client.
  2. Call the Requests() method with a callbackUrl.
    1. await api.Poke.V1.Requests(callbackUrl);
      
  3. Handle response

Parameters:

ParameterTypeRequierdDescription
callbackUrl UriYesThe URL that the callback should be targeting.

Returns

Empty response, or an error response.


Example Usage

Uri callbackUrl = new (https://callback.website.com)

await api.Poke.V1.Requests(callbackUrl);

Response

200 OK

{}


Signing keys (Endpoint)

The Signing keys endpoint exposes two methods used to get and generate public and private keys using Edwards-curve Digital Signature Algorithm (EdDSA) with the ed25519 curve.

Method


Get Signing key

Get a Signing key.

Usage:

  1. Create a Ping Payments Api Client.
  2. Call the Get() method.
    1. await api.SigningKey.V1.Get();
      
  3. Handle response

Returns

An object contaning the key, or an error response.


Example Usage

await api.SigningKey.V1.Get();

Response

200 OK

{
  "key": "string"
}


Generate Signing key

Generate a Signing key.

Usage:

  1. Create a Ping Payments Api Client.
  2. Call the Generate() method.
    1. await api.SigningKey.V1.Generate();
      
  3. Handle response

Returns

An object contaning the key that was generated, or an error response.


Example Usage

await api.SigningKey.V1.Generate();

Response

200 OK

{
  "public_key": "string"
}