Charges API

The charges API allows you to create new payment card charges and retrieve details of previous charges.

POST /charges

Creates a new charge and returns its details. This may be a long-running request.

Parameters

email The email address of the purchaser.
description A description of the item purchased (e.g. 500g of single origin beans).
amount The amount to charge in the currency’s base unit (e.g. cents for AUD, yen for JPY). There is a minimum charge amount for each currency; refer to the documentation on supported currencies.
ip_address The IP address of the person submitting the payment.
Optional currency The three-character ISO 4217 currency code of one of our supported currencies, e.g. AUD or USD. Default value is AUD.
Optional capture Whether to immediately capture the charge (true or false). If false, we will attempt to create an authorisation; if this is successful, you can capture at a later time. Authorised charges automatically expire after five days. Default value is true.
Optional metadata Arbitrary key-value data to be associated with the charge.{...}
{
  "OrderNumber": "123456",
  "CustomerName": "Roland Robot",
  "order taken by": "Rachel",
  "Location": "Lat:-31.950527, Long:115.860457",
  "time_order_completed": "01 JUL 2016 10:35:03 UTC+08:00"
}
A metadata item is composed of a key (a string with a maximum length of 50 characters) and a value (a string with a maximum length of 500 characters). You can supply up to 25 metadata items per charge. Pin Payments does not display metadata to your customers.

and one of the following:

card The full details of the payment card to be charged {...}.
{
  "number": "5520000000000000",
  "expiry_month": "05",
  "expiry_year": "2019",
  "cvc": "123",
  "name": "Roland Robot",
  "address_line1": "42 Sevenoaks St",
  "address_city": "Lathlain",
  "address_postcode": "6454",
  "address_state": "WA",
  "address_country": "Australia"
}
See the cards API for a description of each card parameter.
card_token The token of the card to be charged, as returned from the cards API or customers API.
customer_token The token of the customer to be charged, as returned from the customers API.

Example

curl https://test-api.pinpayments.com/1/charges -u your-secret-api-key: \
 -d "amount=400" \
 -d "currency=AUD" \
 -d "description=test charge" \
 -d "email=roland@pinpayments.com" \
 -d "ip_address=203.192.1.172" \
 -d "card[number]=5520000000000000" \
 -d "card[expiry_month]=05" \
 -d "card[expiry_year]=2019" \
 -d "card[cvc]=123" \
 -d "card[name]=Roland Robot" \
 -d "card[address_line1]=42 Sevenoaks St" \
 -d "card[address_line2]=" \
 -d "card[address_city]=Lathlain" \
 -d "card[address_postcode]=6454" \
 -d "card[address_state]=WA" \
 -d "card[address_country]=Australia" \
 -d "metadata[OrderNumber]=123456" \
 -d "metadata[CustomerName]=Roland Robot"
201 Created
{
  "response": {
    "token": "ch_lfUYEBK14zotCTykezJkfg",
    "success": true,
    "amount": 400,
    "currency": "AUD",
    "description": "test charge",
    "email": "roland@pinpayments.com",
    "ip_address": "203.192.1.172",
    "created_at": "2012-06-20T03:10:49Z",
    "status_message": "Success",
    "error_message": null,
    "card": {
      "token": "card_pIQJKMs93GsCc9vLSLevbw",
      "scheme": "master",
      "display_number": "XXXX-XXXX-XXXX-0000",
      "issuing_country": "US",
      "expiry_month": 5,
      "expiry_year": 2019,
      "name": "Roland Robot",
      "address_line1": "42 Sevenoaks St",
      "address_line2": "",
      "address_city": "Lathlain",
      "address_postcode": "6454",
      "address_state": "WA",
      "address_country": "Australia",
      "customer_token": null,
      "primary": null
    },
    "transfer": [],
    "amount_refunded": 0,
    "total_fees": 42,
    "merchant_entitlement": 358,
    "refund_pending": false,
    "authorisation_expired": false,
    "captured": true,
    "captured_at": "2012-06-20T03:10:49Z",
    "settlement_currency": "AUD",
    "metadata": {
      "OrderNumber": "123456",
      "CustomerName": "Roland Robot"
    }
  }
}

Error Responses

422 invalid_resource {...}
{
  "error": "invalid_resource",
  "error_description": "One or more parameters were missing or invalid",
  "messages": [
    {
      "code": "description_invalid",
      "message": "Description can't be blank",
      "param": "description"
    }
  ]
}
400 card_declined {...}
{
  "error": "card_declined",
  "error_description": "The card was declined",
  "charge_token": "ch_lfUYEBK14zotCTykezJkfg"
}
400 insufficient_funds {...}
{
  "error": "insufficient_funds",
  "error_description": "There are not enough funds available to process the requested amount",
  "charge_token": "ch_lfUYEBK14zotCTykezJkfg"
}
400 processing_error {...}
{
  "error": "processing_error",
  "error_description": "An error occurred while processing the card",
  "charge_token": "ch_lfUYEBK14zotCTykezJkfg"
}
400 suspected_fraud {...}
{
  "error": "suspected_fraud",
  "error_description": "The transaction was flagged as possibly fraudulent and subsequently declined",
  "charge_token": "ch_lfUYEBK14zotCTykezJkfg"
}
400 expired_card {...}
{
  "error": "expired_card",
  "error_description": "The card has expired",
  "charge_token": "ch_lfUYEBK14zotCTykezJkfg"
}
502 gateway_error {...}
{
  "error": "gateway_error",
  "error_description": "An upstream error occurred while processing the transaction. Please try again.",
  "charge_token": "ch_lfUYEBK14zotCTykezJkfg"
}

PUT /charges/charge-token/capture

Captures a previously authorised charge and returns its details. Currently, you can only capture the full amount that was originally authorised.

Example

curl https://test-api.pinpayments.com/1/charges/ch_lfUYEBK14zotCTykezJkfg/capture -u your-secret-api-key: -X PUT
201 Created
{
  "response": {
    "token": "ch_lfUYEBK14zotCTykezJkfg",
    "success": true,
    "amount": 400,
    "currency": "AUD",
    "description": "test charge",
    "email": "roland@pinpayments.com",
    "ip_address": "203.192.1.172",
    "created_at": "2012-06-20T03:10:49Z",
    "status_message": "Success",
    "error_message": null,
    "card": {
      "token": "card_pIQJKMs93GsCc9vLSLevbw",
      "scheme": "master",
      "display_number": "XXXX-XXXX-XXXX-0000",
      "issuing_country": "US",
      "expiry_month": 5,
      "expiry_year": 2019,
      "name": "Roland Robot",
      "address_line1": "42 Sevenoaks St",
      "address_line2": "",
      "address_city": "Lathlain",
      "address_postcode": "6454",
      "address_state": "WA",
      "address_country": "Australia",
      "customer_token": null,
      "primary": null
    },
    "transfer": [],
    "amount_refunded": 0,
    "total_fees": 42,
    "merchant_entitlement": 358,
    "refund_pending": false,
    "authorisation_expired": false,
    "captured": true,
    "captured_at": "2012-06-20T03:10:49Z",
    "settlement_currency": "AUD",
    "metadata": {
      "OrderNumber": "123456",
      "CustomerName": "Roland Robot"
    }
  }
}

Error Responses

400 authorisation_expired {...}
{
  "error": "authorisation_expired",
  "error_description": "The authorisation has expired and can not be captured",
  "charge_token": "ch_lfUYEBK14zotCTykezJkfg"
}
400 already_captured {...}
{
  "error": "already_captured",
  "error_description": "This authorisation has already been captured",
  "charge_token": "ch_lfUYEBK14zotCTykezJkfg"
}
400 bad_authorisation {...}
{
  "error": "bad_authorisation",
  "error_description": "The authorisation failed and can not be captured",
  "charge_token": "ch_lfUYEBK14zotCTykezJkfg"
}
400 invalid_capture_amount {...}
{
  "error": "invalid_capture_amount",
  "error_description": "You must capture the full amount that was authorised",
  "charge_token": "ch_lfUYEBK14zotCTykezJkfg"
}

GET /charges

Returns a paginated list of all charges.

Example

curl https://test-api.pinpayments.com/1/charges -u your-secret-api-key:
200 OK
{
  "response": [
    {
      "token": "ch_lfUYEBK14zotCTykezJkfg",
      "success": true,
      "amount": 400,
      "currency": "AUD",
      "description": "test charge",
      "email": "roland@pinpayments.com",
      "ip_address": "203.192.1.172",
      "created_at": "2012-06-20T03:10:49Z",
      "status_message": "Success",
      "error_message": null,
      "card": {
        "token": "card_pIQJKMs93GsCc9vLSLevbw",
        "scheme": "master",
        "display_number": "XXXX-XXXX-XXXX-0000",
        "issuing_country": "US",
        "expiry_month": 5,
        "expiry_year": 2019,
        "name": "Roland Robot",
        "address_line1": "42 Sevenoaks St",
        "address_line2": "",
        "address_city": "Lathlain",
        "address_postcode": "6454",
        "address_state": "WA",
        "address_country": "Australia",
        "customer_token": null,
        "primary": null
      },
      "transfer": [
        {
          "state": "paid",
          "paid_at": "2012-06-27T03:10:49Z",
          "token": "tfer_j_u-Ef7aO0Y4CuLnGh92rg"
        }
      ],
      "amount_refunded": 0,
      "total_fees": 42,
      "merchant_entitlement": 358,
      "refund_pending": false,
      "authorisation_expired": false,
      "captured": true,
      "captured_at": "2012-06-20T03:10:49Z",
      "settlement_currency": "AUD",
      "metadata": {
        "OrderNumber": "123456",
        "CustomerName": "Roland Robot"
      }
    }
  ],
  "count": 1,
  "pagination": {
    "current": 1,
    "previous": null,
    "next": null,
    "per_page": 25,
    "pages": 1,
    "count": 1
  }
}

GET /charges/search

Returns a paginated list of charges matching the search criteria.

Optional query Return only charges whose descriptions contain the query or whose amounts exactly match the query.
Optional start_date Return only charges created on or after this date (e.g. 2012/12/25).
Optional end_date Return only charges created before this date (e.g. 2013/12/25).
Optional sort The field used to sort the charges (created_at or description or amount). Default value is created_at.
Optional direction The direction in which to sort the charges (1 for ascending or -1 for descending). Default value is 1.

Example

curl https://test-api.pinpayments.com/1/charges/search?query=test%20charge -u your-secret-api-key:
200 OK
{
  "response": [
    {
      "token": "ch_lfUYEBK14zotCTykezJkfg",
      "success": true,
      "amount": 400,
      "currency": "AUD",
      "description": "test charge",
      "email": "roland@pinpayments.com",
      "ip_address": "203.192.1.172",
      "created_at": "2012-06-20T03:10:49Z",
      "status_message": "Success",
      "error_message": null,
      "card": {
        "token": "card_pIQJKMs93GsCc9vLSLevbw",
        "scheme": "master",
        "display_number": "XXXX-XXXX-XXXX-0000",
        "issuing_country": "US",
        "expiry_month": 5,
        "expiry_year": 2019,
        "name": "Roland Robot",
        "address_line1": "42 Sevenoaks St",
        "address_line2": "",
        "address_city": "Lathlain",
        "address_postcode": "6454",
        "address_state": "WA",
        "address_country": "Australia",
        "customer_token": null,
        "primary": null
      },
      "transfer": [
        {
          "state": "paid",
          "paid_at": "2012-06-27T03:10:49Z",
          "token": "tfer_j_u-Ef7aO0Y4CuLnGh92rg"
        }
      ],
      "amount_refunded": 0,
      "total_fees": 42,
      "merchant_entitlement": 358,
      "refund_pending": false,
      "authorisation_expired": false,
      "captured": true,
      "captured_at": "2012-06-20T03:10:49Z",
      "settlement_currency": "AUD",
      "metadata": {
        "OrderNumber": "123456",
        "CustomerName": "Roland Robot"
      }
    }
  ],
  "count": 1,
  "pagination": {
    "current": 1,
    "previous": null,
    "next": null,
    "per_page": 25,
    "pages": 1,
    "count": 1
  }
}

GET /charges/charge-token

Returns the details of a charge.

Example

curl https://test-api.pinpayments.com/1/charges/ch_lfUYEBK14zotCTykezJkfg -u your-secret-api-key:
200 OK
{
  "response": {
    "token": "ch_lfUYEBK14zotCTykezJkfg",
    "success": true,
    "amount": 400,
    "currency": "AUD",
    "description": "test charge",
    "email": "roland@pinpayments.com",
    "ip_address": "203.192.1.172",
    "created_at": "2012-06-20T03:10:49Z",
    "status_message": "Success",
    "error_message": null,
    "card": {
      "token": "card_pIQJKMs93GsCc9vLSLevbw",
      "scheme": "master",
      "display_number": "XXXX-XXXX-XXXX-0000",
      "issuing_country": "US",
      "expiry_month": 5,
      "expiry_year": 2019,
      "name": "Roland Robot",
      "address_line1": "42 Sevenoaks St",
      "address_line2": "",
      "address_city": "Lathlain",
      "address_postcode": "6454",
      "address_state": "WA",
      "address_country": "Australia",
      "customer_token": null,
      "primary": null
    },
    "transfer": [
      {
        "state": "paid",
        "paid_at": "2012-06-27T03:10:49Z",
        "token": "tfer_j_u-Ef7aO0Y4CuLnGh92rg"
      }
    ],
    "amount_refunded": 0,
    "total_fees": 42,
    "merchant_entitlement": 358,
    "refund_pending": false,
    "authorisation_expired": false,
    "captured": true,
    "captured_at": "2012-06-20T03:10:49Z",
    "settlement_currency": "AUD",
    "metadata": {
      "OrderNumber": "123456",
      "CustomerName": "Roland Robot"
    }
  }
}

Error Responses

404 not_found {...}
{
  "error": "not_found",
  "error_description": "The requested resource could not be found."
}

Pin Payments is owned and operated by
Southern Payment Systems Pty Ltd
ABN: 46 154 451 582
Level 1, 34 Queen St,
Melbourne VIC 3000

Privacy Policy Terms Security Status

Australia