Payment Sources API Beta

The payment sources API allows you to securely store payment source details in exchange for a payment source token. This token can then be used to create a single charge with the charges API.

A payment source token can only be used once, to create either a charge or an authorisation. If no charge or authorisation is created within one month, the token will automatically expire.

There are two ways of authenticating when using this API to store payment source details:

  1. Using a secret API key and HTTP basic access authentication in your secure environment.
  2. Using a publishable API key in an insecure environment, such as a web browser or mobile application.

This API supports JSONP.

POST /payment_sources

Securely stores a payment source’s details and returns its token and other information.

Optional publishable_api_key Your publishable API key, if requesting from an insecure environment.
type The type of payment source that should be created. card, googlepay and network_token are currently supported. The format for the source parameter is dependant on the type supplied.

source
{
  "number": "5520000000000000",
  "expiry_month": "05",
  "expiry_year": "2022",
  "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.
source
{
  "protocolVersion": "ECv1",
  "signature": "TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ",
  "signedMessage": "{\"encryptedMessage\": \"ZW5jcnlwdGVkTWVzc2FnZQ==\", \"ephemeralPublicKey\": \"ZXBoZW1lcmFsUHVibGljS2V5\", \"tag\": \"c2lnbmF0dXJl\"}"
}
source
{
  "number": "5520000000000000",
  "token_type": "googlepay",
  "expiry_month": "05",
  "expiry_year": "2022",
  "eci": "06",
  "cryptogram": "AgAAAAAAAIR8CQrXcIhbQAAAAAA"
}

Example

curl https://test-api.pinpayments.com/1/payment_sources -d "publishable_api_key=your-publishable-api-key" \
 -d "type=card" \
 -d "source[number]=5520000000000000" \
 -d "source[expiry_month]=05" \
 -d "source[expiry_year]=2022" \
 -d "source[cvc]=123" \
 -d "source[name]=Roland Robot" \
 -d "source[address_line1]=42 Sevenoaks St" \
 -d "source[address_line2]=" \
 -d "source[address_city]=Lathlain" \
 -d "source[address_postcode]=6454" \
 -d "source[address_state]=WA" \
 -d "source[address_country]=Australia"
201 Created
{
  "response": {
    "token": "ps_38KhC82RhpupmeV4pqw6cw",
    "type": "card",
    "source": {
      "token": "card_BXQoEjTRxEEAdBz59D--zw",
      "scheme": "master",
      "display_number": "XXXX-XXXX-XXXX-0000",
      "issuing_country": "US",
      "expiry_month": 5,
      "expiry_year": 2022,
      "name": "Roland Robot",
      "address_line1": "42 Sevenoaks St",
      "address_line2": null,
      "address_city": "Lathlain",
      "address_postcode": "6454",
      "address_state": "WA",
      "address_country": "Australia",
      "customer_token": null,
      "primary": null,
      "network_type": null
    }
  },
  "ip_address": "192.0.2.42"
}

Example

curl https://test-api.pinpayments.com/1/payment_sources -d "publishable_api_key=your-publishable-api-key" \
 -d "type=googlepay" \
 -d "source[protocolVersion]=ECv1" \
 -d "source[signature]=TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ" \
 -d "source[signedMessage]={\"encryptedMessage\": \"ZW5jcnlwdGVkTWVzc2FnZQ==\", \"ephemeralPublicKey\": \"ZXBoZW1lcmFsUHVibGljS2V5\", \"tag\": \"c2lnbmF0dXJl\"}"
201 Created
{
  "response": {
    "token": "ps_UKOm94HHNcYliozFVfpdTw",
    "type": "googlepay",
    "source": {
      "token": "card_BJC5kA-rP9QesNJu8P6_kw",
      "scheme": "master",
      "display_number": "XXXX-XXXX-XXXX-0000",
      "issuing_country": "US",
      "expiry_month": 5,
      "expiry_year": 2022,
      "name": null,
      "address_line1": null,
      "address_line2": null,
      "address_city": null,
      "address_postcode": null,
      "address_state": null,
      "address_country": null,
      "customer_token": null,
      "primary": null,
      "network_type": "googlepay"
    }
  },
  "ip_address": "192.0.2.42"
}

Example

curl https://test-api.pinpayments.com/1/payment_sources -d "publishable_api_key=your-publishable-api-key" \
 -d "type=network_token" \
 -d "source[number]=5520000000000000" \
 -d "source[token_type]=googlepay" \
 -d "source[expiry_month]=05" \
 -d "source[expiry_year]=2022" \
 -d "source[eci]=06" \
 -d "source[cryptogram]=AgAAAAAAAIR8CQrXcIhbQAAAAAA"
201 Created
{
  "response": {
    "token": "ps_MV7zVxpamEriVlUVLLAHWg",
    "type": "network_token",
    "source": {
      "token": "card_RZriFDPF3JKAKEb_ICS2eg",
      "scheme": "master",
      "display_number": "XXXX-XXXX-XXXX-0000",
      "issuing_country": "US",
      "expiry_month": 5,
      "expiry_year": 2022,
      "name": null,
      "address_line1": null,
      "address_line2": null,
      "address_city": null,
      "address_postcode": null,
      "address_state": null,
      "address_country": null,
      "customer_token": null,
      "primary": null,
      "network_type": "googlepay"
    }
  },
  "ip_address": "192.0.2.42"
}

Error Responses

422 invalid_resource {...}
{
  "error": "invalid_resource",
  "error_description": "One or more parameters were missing or invalid",
  "messages": [
    {
      "code": "source_number_invalid",
      "message": "Source number can't be blank",
      "param": "source.number"
    }
  ]
}

Southern Payment Systems Pty Ltd
t/a Pin Payments
ABN: 46 154 451 582
Level 4, 356 Collins St,
Melbourne VIC 3000

A Checkout.com company

Privacy Policy Terms Security Status

Australia