Payment Links API

Installation

pip install

Install the latest SDK using pip:

pip install ping-sdk

Import

from ping.payment_links_api import PaymentLinksApi

Ping PaymentLinksApi Client

The PaymentLinksApiclient class acts as a factory for the Ping PaymentLinks API resource endpoints and holds the configuration of the Ping PaymentLinks API.

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

  • For testing use the Sandbox environment environment = "sandbox".
  • For Production use environment = "production".
from ping.payment_links_api import PaymentLinksApi

payment_links_api = PaymentLinksApi(
  tenant_id = '55555555-5555-5555-5555-555555555555', #tenant_id given py ping
  environment = 'sandbox' #"sandox" for testing, "production" for production usage.
)

Verify the connection

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



Payment Link (Endpoint)

The payment link endpoint exposes several functions dedicated to dealing with payment link objects. Payments are made through a link generated by the Ping Payments Links API.

Functions


List Payment Links

Get an list of all the Payment Link objects connected to a specific Tenant.

Usage:

  1. Create a Ping Payment Links Api Client.
  2. Call the list() function:
    1. payment_links_api.payment_link.list()
      
  3. Handle response

Returns

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


Example Usage

from ping.payment_links_api import PaymentLinksApi

payment_links_api = PaymentLinksApi(
  tenant_id = '55555555-5555-5555-5555-555555555555',
  environment = 'sandbox'
)

result = payment_links_api.payment_link.list()
if result.is_success():
    print(result.body)
    # successful code
elif result.is_error():
    print(result.errors)
    # error code

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 Payment Link

Get an list of all the Payment Link objects connected to a specific Tenant.

Usage:

  1. Create a Ping Payment Links Api Client.
  2. Call the create() function with a payment_links_object:
    1. payment_links_api.payment_link.create(payment_link_object)
      
  3. Handle response

Parameters

ContainsTypeDescription
payment_link_objectobjectRequest body for creating a payment link

Returns

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


Example Usage

from ping.payment_links_api import PaymentLinksApi

payment_links_api = PaymentLinksApi(
  tenant_id = '55555555-5555-5555-5555-555555555555',
  environment = 'sandbox'
)

result = payment_links_api.payment_link.list()
if result.is_success():
    print(result.body)
    # successful code
elif result.is_error():
    print(result.errors)
    # error code

Response

200 OK

{
  "checkout_url": "www.checkout-url.com",
  "id": "55555555-5555-5555-5555-555555555555"
}


Get Payment Link

Get an list of all the Payment Link objects connected to a specific Tenant.

Usage:

  1. Create a Ping Payment Links Api Client.
  2. Call the get() function with a Payment Link Id:
    1. payment_links_api.payment_link.get(payment_link_id)
      
  3. Handle response

Parameters

ContainsTypeDescription
payment_link_idstringId of a specific payment link

Returns

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


Example Usage

from ping.payment_links_api import PaymentLinksApi

payment_links_api = PaymentLinksApi(
  tenant_id = '55555555-5555-5555-5555-555555555555',
  environment = 'sandbox'
)
payment_link_id = '55555555-5555-5555-5555-555555555555'

result = payment_links_api.payment_link.get(payment_link_id)
if result.is_success():
    print(result.body)
    # successful code
elif result.is_error():
    print(result.errors)
    # error code

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": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "price": 0,
      "quantity": 0,
      "unit": "string",
      "vat": 0
    }
  ],
  "locale": "sv-SE",
  "logo_image_link": "string",
  "metadata": {},
  "payment_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "payment_link_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "payment_link_status_callback_url": "string",
  "payment_order_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "payment_provider_methods": [
    {
      "method": "card",
      "parameters": {},
      "provider": "verifone"
    }
  ],
  "sms_status": "DELIVERED",
  "status": "CREATED",
  "tenant_id": "string",
  "total_amount": 0
}


Cancel Payment Link

Get an list of all the Payment Link objects connected to a specific Tenant.

Usage:

  1. Create a Ping Payment Links Api Client.
  2. Call the cancel() function with a Payment Link Id:
    1. payment_links_api.payment_link.cancel(payment_link_id)
      
  3. Handle response

Parameters

ContainsTypeDescription
payment_link_idstringId of a specific payment link

Returns

Empty object, or an error response.


Example Usage

from ping.payment_links_api import PaymentLinksApi

payment_links_api = PaymentLinksApi(
  tenant_id = '55555555-5555-5555-5555-555555555555',
  environment = 'sandbox'
)
payment_link_id = '55555555-5555-5555-5555-555555555555'

result = payment_links_api.payment_link.cancel(payment_link_id)
if result.is_success():
    print(result.body)
    # successful code
elif result.is_error():
    print(result.errors)
    # error code

Response

204 OK

{
  
}


Send Payment Link

Get an list of all the Payment Link objects connected to a specific Tenant.

Usage:

  1. Create a Ping Payment Links Api Client.
  2. Call the send() with a Payment Link Id and a send_object:
    1. payment_links_api.payment_link.send(send_object)
      
  3. Handle response

Parameters

ContainsTypeDescription
send_objectobjectRequest body containing information about how the payment link is getting distributed

Returns

Empty object, or an error response.


Example Usage

from ping.payment_links_api import PaymentLinksApi

payment_links_api = PaymentLinksApi(
  tenant_id = '55555555-5555-5555-5555-555555555555',
  environment = 'sandbox'
)
payment_link_id = '55555555-5555-5555-5555-555555555555'
send_object = 
	{
    "customer_email": "[email protected]",
    "methods": ["email"]
  }

result = payment_links_api.payment_link.send(payment_link_id, send_object)
if result.is_success():
    print(result.body)
    # successful code
elif result.is_error():
    print(result.errors)
    # error code

Response

204 OK

{
  
}


Invoice (Endpoint)

The invoice endpoint exposes several functions dedicated to dealing with invoices of payment links. Invoices are accessible by url.

Functions


Get Invoice

Get an Invoice of a payment link connected to a specific Tenant.

Usage:

  1. Create a Ping Payment Links Api Client.
  2. Call the get() function with a Payment Link Id:
    1. payment_links_api.invoice.get(payment_link_id)
      
  3. Handle response

Parameters

ContainsTypeDescription
payment_link_idstringId of a specific payment link

Returns

Object with an invoice url, or an error response.


Example Usage

from ping.payment_links_api import PaymentLinksApi

payment_links_api = PaymentLinksApi(
  tenant_id = '55555555-5555-5555-5555-555555555555',
  environment = 'sandbox'
)
payment_link_id = '55555555-5555-5555-5555-555555555555'

result = payment_links_api.invoice.get(payment_link_id)
if result.is_success():
    print(result.body)
    # successful code
elif result.is_error():
    print(result.errors)
    # error code

Response

200 OK

{
  "url": "string"
}


Create Invoice

Creates an Invoice of a payment link connected to a specific Tenant_.

Usage:

  1. Create a Ping Payment Links Api Client.
  2. Call the create() function with a Payment Link Id and an invoice_object:
    1. payment_links_api.invoice.create(payment_link_id, invoice_object)
      
  3. Handle response

Parameters

ContainsTypeDescription
payment_link_idstringId of a specific payment link
invoice_objectobjectRequest body containing parameters regarding the invoice type and name

Returns

Empty object, or an error response.


Example Usage

from ping.payment_links_api import PaymentLinksApi

payment_links_api = PaymentLinksApi(
  tenant_id = '55555555-5555-5555-5555-555555555555',
  environment = 'sandbox'
)
payment_link_id = '55555555-5555-5555-5555-555555555555'
invoice_object = {"reference_type": "OCR"}

result = payment_links_api.invoice.get(payment_link_id)
if result.is_success():
    print(result.body)
    # successful code
elif result.is_error():
    print(result.errors)
    # error code

Response

200 OK

{

}


Receipt (Endpoint)

The Receipt endpoint exposes a get-functionthat fetches a receipt of a paymed payment link.

Functions


Get Receipt

Get a rceipt of a completed payment link connected to a specific Tenant.

Usage:

  1. Create a Ping Payment Links Api Client.
  2. Call the get() function with a Payment Link Id:
    1. payment_links_api.receipt.get(payment_link_id)
      
  3. Handle response

Parameters

ContainsTypeDescription
payment_link_idstringId of a specific payment link

Returns

Object with an invoice url, or an error response.


Example Usage

from ping.payment_links_api import PaymentLinksApi

payment_links_api = PaymentLinksApi(
  tenant_id = '55555555-5555-5555-5555-555555555555',
  environment = 'sandbox'
)
payment_link_id = '55555555-5555-5555-5555-555555555555'

result = payment_links_api.receipt.get(payment_link_id)
if result.is_success():
    print(result.body)
    # successful code
elif result.is_error():
    print(result.errors)
    # error code

Response

200 OK

{
  "url": "string"
}