NAV navbar
payske
bash ruby python php go java csharp typescript

Introduction

API Reference

The Payske API is organized around REST. Our API has predictable resource-oriented URLs, accepts form-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.

You can use the Payske API in test mode, which does not affect your live data or interact with the banking networks. The API key you use to authenticate the request determines whether the request is live mode or test mode.

The Payske API differs for every account as we release new versions and tailor functionality. Log in to see docs customized to your version of the API, with your test key and data.

Was this section helpful?YesNo

Just getting started?

Check out our development quickstart guide.

Not a developer?

Use apps from our partners to get started with Payske and to do more with your Payske account—no code required.

Base URL

https://api.payske.com

Client libraries

Authentication

Global API key

$payske = new \Payske\PayskeClient("sk_test_4eC39HqLyjWDarjtT1zdp7dc");

Per-request API key

    $ch = $payske->charges->capture(
      'ch_3JwDpJ2eZvKYlo2C1Ut8JRvr',
      [],
      ['api_key' => 'sk_test_4eC39HqLyjWDarjtT1zdp7dc']
    );

Your API Key

A sample test API key is included in all the examples here, so you can test any example right away.

To test requests using your account, replace the sample API key with your actual API key or sign in.

The Payske API uses API keys to authenticate requests. You can view and manage your API keys in the Payske Dashboard.

Test mode secret keys have the prefix sk_test_ and live mode secret keys have the prefix sk_live_. Alternatively, you can use restricted API keys for granular permissions.

Your API keys carry many privileges, so be sure to keep them secure! Do not share your secret API keys in publicly accessible areas such as GitHub, client-side code, and so forth.

Use your API key by setting it in the initial configuration of new \Payske\PayskeClient(). The PHP library will then automatically send this key in each request.

You can also set a per-request key with an option. This is often useful for Connect applications that use multiple API keys during the lifetime of a process. Methods on the returned object reuse the same API key.

All API requests must be made over HTTPS. Calls made over plain HTTP will fail. API requests without authentication will also fail.

Related video: Authentication.

Was this section helpful?YesNo

Errors

The Kittn API uses the following error codes:

Error Code Meaning
400 Bad Request -- The request could not be understood by the server due to malformed syntax.
401 Unauthorized -- Your API key is wrong.
403 Forbidden -- The kitten requested is hidden for administrators only.
404 Not Found -- The specified kitten could not be found.
405 Method Not Allowed -- You tried to access a kitten with an invalid method.
406 Not Acceptable -- You requested a format that isn't JSON.
410 Gone -- The kitten requested has been removed from our servers.
418 I'm a teapot.
429 Too Many Requests -- You're requesting too many kittens! Slow down!
500 Internal Server Error -- We had a problem with our server. Try again later.
503 Service Unavailable -- We're temporarily offline for maintenance. Please try again later.

HTTP status code summary

HTTP status code Description
200 - OK Everything worked as expected.
400 - Bad Request The request was unacceptable, often due to missing a required parameter.
401 - Unauthorized No valid API key provided.
402 - Request Failed The parameters were valid but the request failed.
403 - Forbidden The API key doesn't have permissions to perform the request.
404 - Not Found The requested resource doesn't exist.
409 - Conflict The request conflicts with another request (perhaps due to using the same idempotent key).
429 - Too Many Requests Too many requests hit the API too quickly. We recommend an exponential backoff of your requests.
500, 502, 503, 504 - Server Errors Something went wrong on Payske's end. (These are rare.)

Error types:

Type Description
api_error API errors cover any other type of problem (e.g., a temporary problem with Payske's servers), and are extremely uncommon.
card_error Card errors are the most common type of error you should expect to handle. They result when the user enters a card that can't be charged for some reason.
idempotency_error Idempotency errors occur when an Idempotency-Key is re-used on a request that does not match the first request's API endpoint and parameters.
invalid_request_error Invalid request errors arise when your request has invalid parameters.

Payske uses conventional HTTP response codes to indicate the success or failure of an API request. In general: Codes in the 2xx range indicate success. Codes in the 4xx range indicate an error that failed given the information provided (e.g., a required parameter was omitted, a charge failed, etc.). Codes in the 5xx range indicate an error with Payske's servers (these are rare).

Some 4xx errors that could be handled programmatically (e.g., a card is declined) include an error code that briefly explains the error reported.

Was this section helpful?YesNo

Attributes
More attributesCollapse all

Handling errors

# Select a client library to see examples of handling different kinds of errors.
try {
  // Use Payske's library to make requests...
} catch(\Payske\Exception\CardException $e) {
  // Since it's a decline, \Payske\Exception\CardException will be caught
  echo 'Status is:' . $e->getHttpStatus() . '\n';
  echo 'Type is:' . $e->getError()->type . '\n';
  echo 'Code is:' . $e->getError()->code . '\n';
  // param is '' in this case
  echo 'Param is:' . $e->getError()->param . '\n';
  echo 'Message is:' . $e->getError()->message . '\n';
} catch (\Payske\Exception\RateLimitException $e) {
  // Too many requests made to the API too quickly
} catch (\Payske\Exception\InvalidRequestException $e) {
  // Invalid parameters were supplied to Payske's API
} catch (\Payske\Exception\AuthenticationException $e) {
  // Authentication with Payske's API failed
  // (maybe you changed API keys recently)
} catch (\Payske\Exception\ApiConnectionException $e) {
  // Network communication with Payske failed
} catch (\Payske\Exception\ApiErrorException $e) {
  // Display a very generic error to the user, and maybe send
  // yourself an email
} catch (Exception $e) {
  // Something else happened, completely unrelated to Payske
}
begin
  # Use Payske's library to make requests...
rescue Payske::CardError => e
  puts "Status is: #{e.http_status}"
  puts "Type is: #{e.error.type}"
  puts "Charge ID is: #{e.error.charge}"
  # The following fields are optional
  puts "Code is: #{e.error.code}" if e.error.code
  puts "Decline code is: #{e.error.decline_code}" if e.error.decline_code
  puts "Param is: #{e.error.param}" if e.error.param
  puts "Message is: #{e.error.message}" if e.error.message
rescue Payske::RateLimitError => e
  # Too many requests made to the API too quickly
rescue Payske::InvalidRequestError => e
  # Invalid parameters were supplied to Payske's API
rescue Payske::AuthenticationError => e
  # Authentication with Payske's API failed
  # (maybe you changed API keys recently)
rescue Payske::APIConnectionError => e
  # Network communication with Payske failed
rescue Payske::PayskeError => e
  # Display a very generic error to the user, and maybe send
  # yourself an email
rescue => e
  # Something else happened, completely unrelated to Payske
end
try:
  # Use Payske's library to make requests...
  pass
except payske.error.CardError as e:
  # Since it's a decline, payske.error.CardError will be caught

  print('Status is: %s' % e.http_status)
  print('Code is: %s' % e.code)
  # param is '' in this case
  print('Param is: %s' % e.param)
  print('Message is: %s' % e.user_message)
except payske.error.RateLimitError as e:
  # Too many requests made to the API too quickly
  pass
except payske.error.InvalidRequestError as e:
  # Invalid parameters were supplied to Payske's API
  pass
except payske.error.AuthenticationError as e:
  # Authentication with Payske's API failed
  # (maybe you changed API keys recently)
  pass
except payske.error.APIConnectionError as e:
  # Network communication with Payske failed
  pass
except payske.error.PayskeError as e:
  # Display a very generic error to the user, and maybe send
  # yourself an email
  pass
except Exception as e:
  # Something else happened, completely unrelated to Payske
  pass
try {
  // Use Payske's library to make requests...
} catch (CardException e) {
  // Since it's a decline, CardException will be caught
  System.out.println("Status is: " + e.getCode());
  System.out.println("Message is: " + e.getMessage());
} catch (RateLimitException e) {
  // Too many requests made to the API too quickly
} catch (InvalidRequestException e) {
  // Invalid parameters were supplied to Payske's API
} catch (AuthenticationException e) {
  // Authentication with Payske's API failed
  // (maybe you changed API keys recently)
} catch (APIConnectionException e) {
  // Network communication with Payske failed
} catch (PayskeException e) {
  // Display a very generic error to the user, and maybe send
  // yourself an email
} catch (Exception e) {
  // Something else happened, completely unrelated to Payske
}
// Note: Node.js API does not throw exceptions, and instead prefers the
// asynchronous style of error handling described below.
//
// An error from the Payske API or an otherwise asynchronous error
// will be available as the first argument of any Payske method's callback:
// E.g. payske.customers.create({...}, function(err, result) {});
//
// Or in the form of a rejected promise.
// E.g. payske.customers.create({...}).then(
//        function(result) {},
//        function(err) {}
//      );

switch (err.type) {
  case 'PayskeCardError':
    // A declined card error
    err.message; // => e.g. "Your card's expiration year is invalid."
    break;
  case 'PayskeRateLimitError':
    // Too many requests made to the API too quickly
    break;
  case 'PayskeInvalidRequestError':
    // Invalid parameters were supplied to Payske's API
    break;
  case 'PayskeAPIError':
    // An error occurred internally with Payske's API
    break;
  case 'PayskeConnectionError':
    // Some kind of error occurred during the HTTPS communication
    break;
  case 'PayskeAuthenticationError':
    // You probably used an incorrect API key
    break;
  default:
    // Handle any other types of unexpected errors
    break;
}
_, err := // Go library call

if err != nil {
  // Try to safely cast a generic error to a payske.Error so that we can get at
  // some additional Payske-specific information about what went wrong.
  if payskeErr, ok := err.(*payske.Error); ok {
    // The Code field will contain a basic identifier for the failure.
    switch payskeErr.Code {
      case payske.ErrorCodeCardDeclined:
      case payske.ErrorCodeExpiredCard:
      case payske.ErrorCodeIncorrectCVC:
      case payske.ErrorCodeIncorrectZip:
      // etc.
    }

    // The Err field can be coerced to a more specific error type with a type
    // assertion. This technique can be used to get more specialized
    // information for certain errors.
    if cardErr, ok := payskeErr.Err.(*payske.CardError); ok {
      fmt.Printf("Card was declined with code: %v\n", cardErr.DeclineCode)
    } else {
      fmt.Printf("Other Payske error occurred: %v\n", payskeErr.Error())
    }
  } else {
    fmt.Printf("Other error occurred: %v\n", err.Error())
  }
}
try {
  // Use Payske's library to make request
} catch (PayskeException e) {
  switch (e.PayskeError.Type)
  {
    case "card_error":
      Console.WriteLine("Code: " + e.PayskeError.Code);
      Console.WriteLine("Message: " + e.PayskeError.Message);
      break;
    case "api_connection_error":
      break;
    case "api_error":
      break;
    case "authentication_error":
      break;
    case "invalid_request_error":
      break;
    case "rate_limit_error":
      break;
    case "validation_error":
      break;
    default:
      // Unknown Error Type
      break;
  }
}

Our Client libraries raise exceptions for many reasons, such as a failed charge, invalid parameters, authentication errors, and network unavailability. We recommend writing code that gracefully handles all possible API exceptions.

Related guide: Error Handling.

Core Resources

Authorization: meowmeowmeow

Charges

To charge a credit or a debit card, you create a Charge object. You can retrieve and refund individual charges as well as list all charges. Charges are identified by a unique, random ID.

Related guide: Accept a payment with the Charges API.

Was this section helpful?YesNo

The charge object

The charge object

{
  "id": "ch_3JwPVP2eZvKYlo2C1TaDkcSv",
  "object": "charge",
  "amount": 100,
  "amount_captured": 0,
  "amount_refunded": 0,
  "application": null,
  "application_fee": null,
  "application_fee_amount": null,
  "balance_transaction": "txn_1032HU2eZvKYlo2CEPtcnUvl",
  "billing_details": {
    "address": {
      "city": null,
      "country": null,
      "line1": null,
      "line2": null,
      "postal_code": null,
      "state": null
    },
    "email": null,
    "name": "Jenny Rosen",
    "phone": null
  },
  "calculated_statement_descriptor": null,
  "captured": false,
  "created": 1637060835,
  "currency": "usd",
  "customer": null,
  "description": "My First Test Charge (created for API docs)",
  "disputed": false,
  "failure_code": null,
  "failure_message": null,
  "fraud_details": {},
  "invoice": null,
  "livemode": false,
  "metadata": {},
  "on_behalf_of": null,
  "order": null,
  "outcome": null,
  "paid": true,
  "payment_intent": null,
  "payment_method": "card_19yUNL2eZvKYlo2CNGsN6EWH",
  "payment_method_details": {
    "card": {
      "brand": "visa",
      "checks": {
        "address_line1_check": null,
        "address_postal_code_check": null,
        "cvc_check": "unchecked"
      },
      "country": "US",
      "exp_month": 12,
      "exp_year": 2020,
      "fingerprint": "Xt5EWLLDS7FJjR1c",
      "funding": "credit",
      "installments": null,
      "last4": "4242",
      "network": "visa",
      "three_d_secure": null,
      "wallet": null
    },
    "type": "card"
  },
  "receipt_email": null,
  "receipt_number": null,
  "receipt_url": "https://pay.payske.com/receipts/acct_1032D82eZvKYlo2C/ch_3JwPVP2eZvKYlo2C1TaDkcSv/rcpt_KbckqQmcfNnj7YmFkMoUXAYkOX4hUJj",
  "refunded": false,
  "refunds": {
    "object": "list",
    "data": [],
    "has_more": false,
    "url": "/v1/charges/ch_3JwPVP2eZvKYlo2C1TaDkcSv/refunds"
  },
  "review": null,
  "shipping": null,
  "source_transfer": null,
  "statement_descriptor": null,
  "statement_descriptor_suffix": null,
  "status": "succeeded",
  "transfer_data": null,
  "transfer_group": null
}
Attributes
More attributesCollapse all

Create a charge

POST    /v1/charges
# `source` is obtained with Payske.js; see https://payske.com/docs/payments/accept-a-payment-charges#web-create-token
curl https://api.payske.com/v1/charges \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
  -d amount=2000 \
  -d currency=usd \
  -d source=tok_mastercard \
  -d description="My First Test Charge (created for API docs)"
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->charges->create([
  'amount' => 2000,
  'currency' => 'usd',
  'source' => 'tok_mastercard',
  'description' => 'My First Test Charge (created for API docs)',
]);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

# `source` is obtained with Payske.js; see https://payske.com/docs/payments/accept-a-payment-charges#web-create-token
Payske::Charge.create({
  amount: 2000,
  currency: 'usd',
  source: 'tok_visa',
  description: 'My First Test Charge (created for API docs)',
})
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

# `source` is obtained with Payske.js; see https://payske.com/docs/payments/accept-a-payment-charges#web-create-token
payske.Charge.create(
  amount=2000,
  currency="usd",
  source="tok_amex",
  description="My First Test Charge (created for API docs)",
)
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

// `source` is obtained with Payske.js; see https://payske.com/docs/payments/accept-a-payment-charges#web-create-token
Map<String, Object> params = new HashMap<>();
params.put("amount", 2000);
params.put("currency", "usd");
params.put("source", "tok_visa");
params.put(
  "description",
  "My First Test Charge (created for API docs)"
);

Charge charge = Charge.create(params);
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

// `source` is obtained with Payske.js; see https://payske.com/docs/payments/accept-a-payment-charges#web-create-token
const charge = await payske.charges.create({
  amount: 2000,
  currency: 'usd',
  source: 'tok_mastercard',
  description: 'My First Test Charge (created for API docs)',
});
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

// `source` is obtained with Payske.js; see https://payske.com/docs/payments/accept-a-payment-charges#web-create-token
params := &payske.ChargeParams{
  Amount: payske.Int64(2000),
  Currency: payske.String(string(payske.CurrencyUSD)),
  Description: payske.String("My First Test Charge (created for API docs)"),
  Source: &payske.SourceParams{Token: payske.String("tok_amex")},
}
c, _ := charge.New(params)
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

// `source` is obtained with Payske.js; see https://payske.com/docs/payments/accept-a-payment-charges#web-create-token
var options = new ChargeCreateOptions
{
  Amount = 2000,
  Currency = "usd",
  Source = "tok_mastercard",
  Description = "My First Test Charge (created for API docs)",
};
var service = new ChargeService();
service.Create(options);

Response

    {
      "id": "ch_3JwRFc2eZvKYlo2C0zD9agb3",
      "object": "charge",
      "amount": 2000,
      "amount_captured": 0,
      "amount_refunded": 0,
      "application": null,
      "application_fee": null,
      "application_fee_amount": null,
      "balance_transaction": "txn_1032HU2eZvKYlo2CEPtcnUvl",
      "billing_details": {
        "address": {
          "city": null,
          "country": null,
          "line1": null,
          "line2": null,
          "postal_code": null,
          "state": null
        },
        "email": null,
        "name": "Jenny Rosen",
        "phone": null
      },
      "calculated_statement_descriptor": null,
      "captured": false,
      "created": 1637067544,
      "currency": "usd",
      "customer": null,
      "description": "My First Test Charge (created for API docs)",
      "disputed": false,
      "failure_code": null,
      "failure_message": null,
      "fraud_details": {},
      "invoice": null,
      "livemode": false,
      "metadata": {},
      "on_behalf_of": null,
      "order": null,
      "outcome": null,
      "paid": true,
      "payment_intent": null,
      "payment_method": "card_19yUNL2eZvKYlo2CNGsN6EWH",
      "payment_method_details": {
        "card": {
          "brand": "visa",
          "checks": {
            "address_line1_check": null,
            "address_postal_code_check": null,
            "cvc_check": "unchecked"
          },
          "country": "US",
          "exp_month": 12,
          "exp_year": 2020,
          "fingerprint": "Xt5EWLLDS7FJjR1c",
          "funding": "credit",
          "installments": null,
          "last4": "4242",
          "network": "visa",
          "three_d_secure": null,
          "wallet": null
        },
        "type": "card"
      },
      "receipt_email": null,
      "receipt_number": null,
      "receipt_url": "https://pay.payske.com/receipts/acct_1032D82eZvKYlo2C/ch_3JwRFc2eZvKYlo2C0zD9agb3/rcpt_KbeYCzGc3dPHaCuLoK8TsVSXg7b3wVW",
      "refunded": false,
      "refunds": {
        "object": "list",
        "data": [],
        "has_more": false,
        "url": "/v1/charges/ch_3JwRFc2eZvKYlo2C0zD9agb3/refunds"
      },
      "review": null,
      "shipping": null,
      "source_transfer": null,
      "statement_descriptor": null,
      "statement_descriptor_suffix": null,
      "status": "succeeded",
      "transfer_data": null,
      "transfer_group": null,
      "source": "tok_amex"
    }

To charge a credit card or other payment source, you create a Charge object. If your API key is in test mode, the supplied payment source (e.g., card) won’t actually be charged, although everything else will occur as if in live mode. (Payske assumes that the charge would have completed successfully).

Parameters
More parametersCollapse all

Returns

Returns the charge object if the charge succeeded. This call will throw an error if something goes wrong. A common source of error is an invalid or expired card, or a valid card with insufficient available balance.

Verification responses

If the cvc parameter is provided, Payske will attempt to check the correctness of the CVC, and will return this check's result. Similarly, if address_line1 or address_zip are provided, Payske will try to check the validity of those parameters.

Some card issuers do not support checking one or more of these parameters, in which case Payske will return an unavailable result.

Also note that, depending on the card issuer, charges can succeed even when passed incorrect CVC and address information.

CVC payment_method_details.card.checks.cvc_check

pass The CVC provided is correct.
fail The CVC provided is incorrect.
unavailable The customer's card issuer did not check the CVC provided.
unchecked The CVC was provided but hasn't been checked yet. Checks are typically performed when attaching a card to a Customer object, or when creating a charge. For more details, see Check if a card is valid without a charge.

Address line payment_method_details.card.checks.address_line1_check

pass The first address line provided is correct.
fail The first address line provided is incorrect.
unavailable The customer's card issuer did not check the first address line provided.
unchecked The first address line was provided but hasn't been checked yet. Checks are typically performed when attaching a card to a Customer object, or when creating a charge. For more details, see Check if a card is valid without a charge.

Address ZIP payment_method_details.card.checks.address_zip_check

pass The ZIP code provided is correct.
fail The ZIP code provided is incorrect.
unavailable The customer's card issuer did not check the ZIP code.
unchecked The ZIP code was provided but hasn't been checked yet. Checks are typically performed when attaching a card to a Customer object, or when creating a charge. For more details, see Check if a card is valid without a charge.

Retrieve a charge

GET    /v1/charges/:id
curl https://api.payske.com/v1/charges/ch_3JwRFp2eZvKYlo2C0KiI8eEP \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc:
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Charge.retrieve(
  'ch_3JwRMJ2eZvKYlo2C1tf0y5IY',
)
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Charge.retrieve(
  "ch_3JwRMl2eZvKYlo2C0YOAvqAr",
)
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->charges->retrieve(
  'ch_3JwRNG2eZvKYlo2C07PwDCbQ',
  []
);
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Charge charge =
  Charge.retrieve("ch_3JwRNf2eZvKYlo2C1E60srVy");
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const charge = await payske.charges.retrieve(
  'ch_3JwRO22eZvKYlo2C1pprtk0S'
);
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

c, _ := charge.Get(
  "ch_3JwRP32eZvKYlo2C1eIYPv3p",
  nil,
)
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var service = new ChargeService();
service.Get("ch_3JwRFc2eZvKYlo2C0zD9agb3");

Response


    {
      "id": "ch_3JwRFc2eZvKYlo2C0zD9agb3",
      "object": "charge",
      "amount": 100,
      "amount_captured": 0,
      "amount_refunded": 0,
      "application": null,
      "application_fee": null,
      "application_fee_amount": null,
      "balance_transaction": "txn_1032HU2eZvKYlo2CEPtcnUvl",
      "billing_details": {
        "address": {
          "city": null,
          "country": null,
          "line1": null,
          "line2": null,
          "postal_code": null,
          "state": null
        },
        "email": null,
        "name": "Jenny Rosen",
        "phone": null
      },
      "calculated_statement_descriptor": null,
      "captured": false,
      "created": 1637067544,
      "currency": "usd",
      "customer": null,
      "description": "My First Test Charge (created for API docs)",
      "disputed": false,
      "failure_code": null,
      "failure_message": null,
      "fraud_details": {},
      "invoice": null,
      "livemode": false,
      "metadata": {},
      "on_behalf_of": null,
      "order": null,
      "outcome": null,
      "paid": true,
      "payment_intent": null,
      "payment_method": "card_19yUNL2eZvKYlo2CNGsN6EWH",
      "payment_method_details": {
        "card": {
          "brand": "visa",
          "checks": {
            "address_line1_check": null,
            "address_postal_code_check": null,
            "cvc_check": "unchecked"
          },
          "country": "US",
          "exp_month": 12,
          "exp_year": 2020,
          "fingerprint": "Xt5EWLLDS7FJjR1c",
          "funding": "credit",
          "installments": null,
          "last4": "4242",
          "network": "visa",
          "three_d_secure": null,
          "wallet": null
        },
        "type": "card"
      },
      "receipt_email": null,
      "receipt_number": null,
      "receipt_url": "https://pay.payske.com/receipts/acct_1032D82eZvKYlo2C/ch_3JwRFc2eZvKYlo2C0zD9agb3/rcpt_KbeYCzGc3dPHaCuLoK8TsVSXg7b3wVW",
      "refunded": false,
      "refunds": {
        "object": "list",
        "data": [],
        "has_more": false,
        "url": "/v1/charges/ch_3JwRFc2eZvKYlo2C0zD9agb3/refunds"
      },
      "review": null,
      "shipping": null,
      "source_transfer": null,
      "statement_descriptor": null,
      "statement_descriptor_suffix": null,
      "status": "succeeded",
      "transfer_data": null,
      "transfer_group": null
    }

Retrieves the details of a charge that has previously been created. Supply the unique charge ID that was returned from your previous request, and Payske will return the corresponding charge information. The same information is returned when creating or refunding the charge.

Parameters

Returns


Returns a charge if a valid identifier was provided, and throws an error otherwise.

Update a charge

POST    /v1/charges/:id
curl https://api.payske.com/v1/charges/ch_3JwR0o2eZvKYlo2C0H9Yk2mB \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
  -d "metadata[order_id]"=6735
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Charge.update(
  'ch_3JwRWR2eZvKYlo2C0czCivpw',
  {metadata: {order_id: '6735'}},
)
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Charge.modify(
  "ch_3JwRWp2eZvKYlo2C0qnwD72c",
  metadata={"order_id": "6735"},
)
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->charges->update(
  'ch_3JwRXD2eZvKYlo2C0rYiUbE3',
  ['metadata' => ['order_id' => '6735']]
);
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Charge charge =
  Charge.retrieve("ch_3JwRXZ2eZvKYlo2C1tVBZbhd");

Map<String, Object> metadata = new HashMap<>();
metadata.put("order_id", "6735");
Map<String, Object> params = new HashMap<>();
params.put("metadata", metadata);

Charge updatedCharge = charge.update(params);
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const charge = await payske.charges.update(
  'ch_3JwRXx2eZvKYlo2C0aoxADAV',
  {metadata: {order_id: '6735'}}
);
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

params := &payske.ChargeParams{}
params.AddMetadata("order_id", "6735")
c, _ := charge.Update(
  "ch_3JwRYn2eZvKYlo2C18JrMOJ1",
  params,
)
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var options = new ChargeUpdateOptions
{
  Metadata = new Dictionary<string, string>
  {
    { "order_id", "6735" },
  },
};
var service = new ChargeService();
service.Update(
  "ch_3JwRZH2eZvKYlo2C1rS58zMi",
  options
);

Response


    {
      "id": "ch_3JwRP32eZvKYlo2C1eIYPv3p",
      "object": "charge",
      "amount": 100,
      "amount_captured": 0,
      "amount_refunded": 0,
      "application": null,
      "application_fee": null,
      "application_fee_amount": null,
      "balance_transaction": "txn_1032HU2eZvKYlo2CEPtcnUvl",
      "billing_details": {
        "address": {
          "city": null,
          "country": null,
          "line1": null,
          "line2": null,
          "postal_code": null,
          "state": null
        },
        "email": null,
        "name": "Jenny Rosen",
        "phone": null
      },
      "calculated_statement_descriptor": null,
      "captured": false,
      "created": 1637068129,
      "currency": "usd",
      "customer": null,
      "description": "My First Test Charge (created for API docs)",
      "disputed": false,
      "failure_code": null,
      "failure_message": null,
      "fraud_details": {},
      "invoice": null,
      "livemode": false,
      "metadata": {
        "order_id": "6735"
      },
      "on_behalf_of": null,
      "order": null,
      "outcome": null,
      "paid": true,
      "payment_intent": null,
      "payment_method": "card_19yUNL2eZvKYlo2CNGsN6EWH",
      "payment_method_details": {
        "card": {
          "brand": "visa",
          "checks": {
            "address_line1_check": null,
            "address_postal_code_check": null,
            "cvc_check": "unchecked"
          },
          "country": "US",
          "exp_month": 12,
          "exp_year": 2020,
          "fingerprint": "Xt5EWLLDS7FJjR1c",
          "funding": "credit",
          "installments": null,
          "last4": "4242",
          "network": "visa",
          "three_d_secure": null,
          "wallet": null
        },
        "type": "card"
      },
      "receipt_email": null,
      "receipt_number": null,
      "receipt_url": "https://pay.payske.com/receipts/acct_1032D82eZvKYlo2C/ch_3JwRP32eZvKYlo2C1eIYPv3p/rcpt_KbeiEa9wdyA1m0RhrX7mK0pAhwYgvVF",
      "refunded": false,
      "refunds": {
        "object": "list",
        "data": [],
        "has_more": false,
        "url": "/v1/charges/ch_3JwRP32eZvKYlo2C1eIYPv3p/refunds"
      },
      "review": null,
      "shipping": null,
      "source_transfer": null,
      "statement_descriptor": null,
      "statement_descriptor_suffix": null,
      "status": "succeeded",
      "transfer_data": null,
      "transfer_group": null
    }

Updates the specified charge by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

Parameters
More parametersCollapse all

Returns


Returns the charge object if the update succeeded. This call will return an an error if update parameters are invalid.

Capture a charge

POST    /v1/charges/:id/capture
curl https://api.payske.com/v1/charges/ch_3JwRox2eZvKYlo2C0zGTuUem/capture \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
  -X POST
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Charge.capture(
  'ch_3JwRpV2eZvKYlo2C107WpW1r',
)
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Charge.capture(
  "ch_3JwRus2eZvKYlo2C0JbFdiHA",
)
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->charges->capture(
  'ch_3JwRfK2eZvKYlo2C1niOjt6m',
  []
);
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Charge charge =
  Charge.retrieve("ch_3JwRrl2eZvKYlo2C0FLQF4GQ");

Charge updatedCharge = charge.capture();
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const charge = await payske.charges.capture(
  'ch_3JwRvA2eZvKYlo2C0hgR94fo'
);
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

c, _ := charge.Capture(
  "ch_3JwRvH2eZvKYlo2C1zfYTkf1",
  nil,
)
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var service = new ChargeService();
service.Capture("ch_3JwRZH2eZvKYlo2C1rS58zMi");

Response


    {
      "id": "ch_3JwRZH2eZvKYlo2C1rS58zMi",
      "object": "charge",
      "amount": 100,
      "amount_captured": 0,
      "amount_refunded": 0,
      "application": null,
      "application_fee": null,
      "application_fee_amount": null,
      "balance_transaction": "txn_1032HU2eZvKYlo2CEPtcnUvl",
      "billing_details": {
        "address": {
          "city": null,
          "country": null,
          "line1": null,
          "line2": null,
          "postal_code": null,
          "state": null
        },
        "email": null,
        "name": "Jenny Rosen",
        "phone": null
      },
      "calculated_statement_descriptor": null,
      "captured": false,
      "created": 1637068763,
      "currency": "usd",
      "customer": null,
      "description": "My First Test Charge (created for API docs)",
      "disputed": false,
      "failure_code": null,
      "failure_message": null,
      "fraud_details": {},
      "invoice": null,
      "livemode": false,
      "metadata": {},
      "on_behalf_of": null,
      "order": null,
      "outcome": null,
      "paid": true,
      "payment_intent": null,
      "payment_method": "card_19yUNL2eZvKYlo2CNGsN6EWH",
      "payment_method_details": {
        "card": {
          "brand": "visa",
          "checks": {
            "address_line1_check": null,
            "address_postal_code_check": null,
            "cvc_check": "unchecked"
          },
          "country": "US",
          "exp_month": 12,
          "exp_year": 2020,
          "fingerprint": "Xt5EWLLDS7FJjR1c",
          "funding": "credit",
          "installments": null,
          "last4": "4242",
          "network": "visa",
          "three_d_secure": null,
          "wallet": null
        },
        "type": "card"
      },
      "receipt_email": null,
      "receipt_number": null,
      "receipt_url": "https://pay.payske.com/receipts/acct_1032D82eZvKYlo2C/ch_3JwRZH2eZvKYlo2C1rS58zMi/rcpt_KbetCQn5fJJlJcTj2XRKrBGbXevbnL6",
      "refunded": false,
      "refunds": {
        "object": "list",
        "data": [],
        "has_more": false,
        "url": "/v1/charges/ch_3JwRZH2eZvKYlo2C1rS58zMi/refunds"
      },
      "review": null,
      "shipping": null,
      "source_transfer": null,
      "statement_descriptor": null,
      "statement_descriptor_suffix": null,
      "status": "succeeded",
      "transfer_data": null,
      "transfer_group": null
    }

Capture the payment of an existing, uncaptured, charge. This is the second half of the two-step payment flow, where first you created a charge with the capture option set to false.

Uncaptured payments expire a set number of days after they are created (7 by default). If they are not captured by that point in time, they will be marked as refunded and will no longer be capturable.

Parameters
More parametersCollapse all

Returns

Returns the charge object, with an updated captured property (set to true). Capturing a charge will always succeed, unless the charge is already refunded, expired, captured, or an invalid capture amount is specified, in which case this method will throw an error.

List all charges

GET    /v1/charges
curl https://api.payske.com/v1/charges \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
  -d limit=3 \
  -G
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Charge.list({limit: 3})
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Charge.list(limit=3)
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->charges->all(['limit' => 3]);
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Map<String, Object> params = new HashMap<>();
params.put("limit", 3);

ChargeCollection charges = Charge.list(params);
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const charges = await payske.charges.list({
  limit: 3,
});
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

params := &payske.ChargeListParams{}
params.Filters.AddFilter("limit", "", "3")
i := charge.List(params)
for i.Next() {
  c := i.Charge()
}
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var options = new ChargeListOptions { Limit = 3 };
var service = new ChargeService();
PayskeList<Charge> charges = service.List(
  options
);

Response


    {
      "object": "list",
      "url": "/v1/charges",
      "has_more": false,
      "data": [
        {
          "id": "ch_3JwRvl2eZvKYlo2C0EOCHQ2f",
          "object": "charge",
          "amount": 100,
          "amount_captured": 0,
          "amount_refunded": 0,
          "application": null,
          "application_fee": null,
          "application_fee_amount": null,
          "balance_transaction": "txn_1032HU2eZvKYlo2CEPtcnUvl",
          "billing_details": {
            "address": {
              "city": null,
              "country": null,
              "line1": null,
              "line2": null,
              "postal_code": null,
              "state": null
            },
            "email": null,
            "name": "Jenny Rosen",
            "phone": null
          },
          "calculated_statement_descriptor": null,
          "captured": false,
          "created": 1637070157,
          "currency": "usd",
          "customer": null,
          "description": "My First Test Charge (created for API docs)",
          "disputed": false,
          "failure_code": null,
          "failure_message": null,
          "fraud_details": {},
          "invoice": null,
          "livemode": false,
          "metadata": {},
          "on_behalf_of": null,
          "order": null,
          "outcome": null,
          "paid": true,
          "payment_intent": null,
          "payment_method": "card_19yUNL2eZvKYlo2CNGsN6EWH",
          "payment_method_details": {
            "card": {
              "brand": "visa",
              "checks": {
                "address_line1_check": null,
                "address_postal_code_check": null,
                "cvc_check": "unchecked"
              },
              "country": "US",
              "exp_month": 12,
              "exp_year": 2020,
              "fingerprint": "Xt5EWLLDS7FJjR1c",
              "funding": "credit",
              "installments": null,
              "last4": "4242",
              "network": "visa",
              "three_d_secure": null,
              "wallet": null
            },
            "type": "card"
          },
          "receipt_email": null,
          "receipt_number": null,
          "receipt_url": "https://pay.payske.com/receipts/acct_1032D82eZvKYlo2C/ch_3JwRvl2eZvKYlo2C0EOCHQ2f/rcpt_KbfGc9g9vMhHYreOFSi16yKoScxkdMk",
          "refunded": false,
          "refunds": {
            "object": "list",
            "data": [],
            "has_more": false,
            "url": "/v1/charges/ch_3JwRvl2eZvKYlo2C0EOCHQ2f/refunds"
          },
          "review": null,
          "shipping": null,
          "source_transfer": null,
          "statement_descriptor": null,
          "statement_descriptor_suffix": null,
          "status": "succeeded",
          "transfer_data": null,
          "transfer_group": null
        },
        {...},
        {...}
      ]
    }Response

    {
      "object": "list",
      "url": "/v1/charges",
      "has_more": false,
      "data": [
        {
          "id": "ch_3JwRvl2eZvKYlo2C0EOCHQ2f",
          "object": "charge",
          "amount": 100,
          "amount_captured": 0,
          "amount_refunded": 0,
          "application": null,
          "application_fee": null,
          "application_fee_amount": null,
          "balance_transaction": "txn_1032HU2eZvKYlo2CEPtcnUvl",
          "billing_details": {
            "address": {
              "city": null,
              "country": null,
              "line1": null,
              "line2": null,
              "postal_code": null,
              "state": null
            },
            "email": null,
            "name": "Jenny Rosen",
            "phone": null
          },
          "calculated_statement_descriptor": null,
          "captured": false,
          "created": 1637070157,
          "currency": "usd",
          "customer": null,
          "description": "My First Test Charge (created for API docs)",
          "disputed": false,
          "failure_code": null,
          "failure_message": null,
          "fraud_details": {},
          "invoice": null,
          "livemode": false,
          "metadata": {},
          "on_behalf_of": null,
          "order": null,
          "outcome": null,
          "paid": true,
          "payment_intent": null,
          "payment_method": "card_19yUNL2eZvKYlo2CNGsN6EWH",
          "payment_method_details": {
            "card": {
              "brand": "visa",
              "checks": {
                "address_line1_check": null,
                "address_postal_code_check": null,
                "cvc_check": "unchecked"
              },
              "country": "US",
              "exp_month": 12,
              "exp_year": 2020,
              "fingerprint": "Xt5EWLLDS7FJjR1c",
              "funding": "credit",
              "installments": null,
              "last4": "4242",
              "network": "visa",
              "three_d_secure": null,
              "wallet": null
            },
            "type": "card"
          },
          "receipt_email": null,
          "receipt_number": null,
          "receipt_url": "https://pay.payske.com/receipts/acct_1032D82eZvKYlo2C/ch_3JwRvl2eZvKYlo2C0EOCHQ2f/rcpt_KbfGc9g9vMhHYreOFSi16yKoScxkdMk",
          "refunded": false,
          "refunds": {
            "object": "list",
            "data": [],
            "has_more": false,
            "url": "/v1/charges/ch_3JwRvl2eZvKYlo2C0EOCHQ2f/refunds"
          },
          "review": null,
          "shipping": null,
          "source_transfer": null,
          "statement_descriptor": null,
          "statement_descriptor_suffix": null,
          "status": "succeeded",
          "transfer_data": null,
          "transfer_group": null
        },
        {...},
        {...}
      ]
    }

Returns a list of charges you’ve previously created. The charges are returned in sorted order, with the most recent charges appearing first.

Parameters
More parametersCollapse all

Returns

A Dictionary with a data property that contains an array of up to limit charges, starting after charge starting_after. Each entry in the array is a separate charge object. If no more charges are available, the resulting array will be empty. If you provide a non-existent customer ID, this call throws an error.

Customers

Customer objects allow you to perform recurring charges, and to track multiple charges, that are associated with the same customer. The API allows you to create, delete, and update your customers. You can retrieve individual customers as well as a list of all your customers.

Related guide: Save a card during payment.

Was this section helpful? Yes No

The customer object

The customer object

    {
      "id": "cus_KbfOzdKQ3UK2Fe",
      "object": "customer",
      "address": null,
      "balance": 0,
      "created": 1637070678,
      "currency": "usd",
      "default_source": null,
      "delinquent": false,
      "description": null,
      "discount": null,
      "email": null,
      "invoice_prefix": "3D1D2FB",
      "invoice_settings": {
        "custom_fields": null,
        "default_payment_method": null,
        "footer": null
      },
      "livemode": false,
      "metadata": {},
      "name": null,
      "next_invoice_sequence": 1,
      "phone": null,
      "preferred_locales": [],
      "shipping": null,
      "tax_exempt": "none"
    }
Attributes
More attributesCollapse all

Create a customer

POST     /v1/customers
curl https://api.payske.com/v1/customers \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
  -d description="My First Test Customer (created for API docs)"
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->customers->create([
  'description' => 'My First Test Customer (created for API docs)',
]);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Customer.create({
  description: 'My First Test Customer (created for API docs)',
})
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Customer.create(
  description="My First Test Customer (created for API docs)",
)
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Map<String, Object> params = new HashMap<>();
params.put(
  "description",
  "My First Test Customer (created for API docs)"
);

Customer customer = Customer.create(params);
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const customer = await payske.customers.create({
  description: 'My First Test Customer (created for API docs)',
});
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

params := &payske.CustomerParams{
  Description: payske.String("My First Test Customer (created for API docs)"),
}
c, _ := customer.New(params)
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var options = new CustomerCreateOptions
{
  Description = "My First Test Customer (created for API docs)",
};
var service = new CustomerService();
service.Create(options);

Response

    {
      "id": "cus_KbfOzdKQ3UK2Fe",
      "object": "customer",
      "address": null,
      "balance": 0,
      "created": 1637070678,
      "currency": "usd",
      "default_source": null,
      "delinquent": false,
      "description": "My First Test Customer (created for API docs)",
      "discount": null,
      "email": null,
      "invoice_prefix": "3D1D2FB",
      "invoice_settings": {
        "custom_fields": null,
        "default_payment_method": null,
        "footer": null
      },
      "livemode": false,
      "metadata": {},
      "name": null,
      "next_invoice_sequence": 1,
      "phone": null,
      "preferred_locales": [],
      "shipping": null,
      "tax_exempt": "none"
    }
Parameters
More parametersCollapse all

Returns

Returns the customer object if the update succeeded. Returns an error if create parameters are invalid (e.g. specifying an invalid coupon or an invalid source).

Retrieve a customer

GET     /v1/customers/:id
curl https://api.payske.com/v1/customers/cus_AJ6yA7mRH34mJT \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc:
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->customers->retrieve(
  'cus_AJ6yA7mRH34mJT',
  []
);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Customer.retrieve('cus_AJ6yA7mRH34mJT')
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Customer.retrieve("cus_AJ6yA7mRH34mJT")
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Customer customer =
  Customer.retrieve("cus_AJ6yA7mRH34mJT");
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const customer = await payske.customers.retrieve(
  'cus_AJ6yA7mRH34mJT'
);
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

c, _ := customer.Get("cus_AJ6yA7mRH34mJT", nil)
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var service = new CustomerService();
service.Get("cus_AJ6yA7mRH34mJT");

Response

    {
      "id": "cus_KbfOzdKQ3UK2Fe",
      "object": "customer",
      "address": null,
      "balance": 0,
      "created": 1637070678,
      "currency": "usd",
      "default_source": null,
      "delinquent": false,
      "description": null,
      "discount": null,
      "email": null,
      "invoice_prefix": "3D1D2FB",
      "invoice_settings": {
        "custom_fields": null,
        "default_payment_method": null,
        "footer": null
      },
      "livemode": false,
      "metadata": {},
      "name": null,
      "next_invoice_sequence": 1,
      "phone": null,
      "preferred_locales": [],
      "shipping": null,
      "tax_exempt": "none"
    }

Retrieves the details of an existing customer. You need only supply the unique customer identifier that was returned upon customer creation.

Parameters

Returns

Returns a customer object if a valid identifier was provided. When requesting the ID of a customer that has been deleted, a subset of the customer’s information will be returned, including a deleted property, which will be true.

Update a customer

POST     /v1/customers/:id
curl https://api.payske.com/v1/customers/cus_AJ6yA7mRH34mJT \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
  -d "metadata[order_id]"=6735
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->customers->update(
  'cus_AJ6yA7mRH34mJT',
  ['metadata' => ['order_id' => '6735']]
);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Customer.update(
  'cus_AJ6yA7mRH34mJT',
  {metadata: {order_id: '6735'}},
)
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Customer.modify(
  "cus_AJ6yA7mRH34mJT",
  metadata={"order_id": "6735"},
)
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Customer customer =
  Customer.retrieve("cus_AJ6yA7mRH34mJT");

Map<String, Object> metadata = new HashMap<>();
metadata.put("order_id", "6735");
Map<String, Object> params = new HashMap<>();
params.put("metadata", metadata);

Customer updatedCustomer =
  customer.update(params);
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const customer = await payske.customers.update(
  'cus_AJ6yA7mRH34mJT',
  {metadata: {order_id: '6735'}}
);
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

params := &payske.CustomerParams{}
params.AddMetadata("order_id", "6735")
c, _ := customer.Update(
  "cus_AJ6yA7mRH34mJT",
  params,
)
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var options = new CustomerUpdateOptions
{
  Metadata = new Dictionary<string, string>
  {
    { "order_id", "6735" },
  },
};
var service = new CustomerService();
service.Update("cus_AJ6yA7mRH34mJT", options);

Response

    {
      "id": "cus_KbfOzdKQ3UK2Fe",
      "object": "customer",
      "address": null,
      "balance": 0,
      "created": 1637070678,
      "currency": "usd",
      "default_source": null,
      "delinquent": false,
      "description": null,
      "discount": null,
      "email": null,
      "invoice_prefix": "3D1D2FB",
      "invoice_settings": {
        "custom_fields": null,
        "default_payment_method": null,
        "footer": null
      },
      "livemode": false,
      "metadata": {
        "order_id": "6735"
      },
      "name": null,
      "next_invoice_sequence": 1,
      "phone": null,
      "preferred_locales": [],
      "shipping": null,
      "tax_exempt": "none"
    }

Updates the specified customer by setting the values of the parameters passed. Any parameters not provided will be left unchanged. For example, if you pass the source parameter, that becomes the customer’s active source (e.g., a card) to be used for all charges in the future. When you update a customer to a new valid card source by passing the source parameter: for each of the customer’s current subscriptions, if the subscription bills automatically and is in the past_due state, then the latest open invoice for the subscription with automatic collection enabled will be retried. This retry will not count as an automatic retry, and will not affect the next regularly scheduled payment for the invoice. Changing the default_source for a customer will not trigger this behavior.

This request accepts mostly the same arguments as the customer creation call.

Parameters
More parametersCollapse all

Returns

Returns the customer object if the update succeeded. Returns an error if update parameters are invalid (e.g. specifying an invalid coupon or an invalid source).

Delete a customer

DELETE     /v1/customers/:id
curl https://api.payske.com/v1/customers/cus_KbfOzdKQ3UK2Fe \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
  -X DELETE
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Customer.delete('cus_AJ6yA7mRH34mJT')
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Customer.delete("cus_AJ6yA7mRH34mJT")
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->customers->delete(
  'cus_AJ6yA7mRH34mJT',
  []
);
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Customer customer =
  Customer.retrieve("cus_AJ6yA7mRH34mJT");

Customer deletedCustomer = customer.delete();
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const deleted = await payske.customers.del(
  'cus_AJ6yA7mRH34mJT'
);
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

c, _ := customer.Del("cus_AJ6yA7mRH34mJT", nil)
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var service = new CustomerService();
service.Delete("cus_AJ6yA7mRH34mJT");

Response

    {
      "id": "cus_Kc344PP3X2o0IA",
      "object": "customer",
      "deleted": true
    }

Permanently deletes a customer. It cannot be undone. Also immediately cancels any active subscriptions on the customer.

Parameters

Returns

Returns an object with a deleted parameter on success. If the customer ID does not exist, this call returns an error.

Unlike other objects, deleted customers can still be retrieved through the API, in order to be able to track the history of customers while still removing their credit card details and preventing any further operations to be performed (such as adding a new subscription).

List all customers

GET     /v1/customers
curl https://api.payske.com/v1/customers \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
  -d limit=3 \
  -G
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->customers->all(['limit' => 3]);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Customer.list({limit: 3})
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Customer.list(limit=3)
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Map<String, Object> params = new HashMap<>();
params.put("limit", 3);

CustomerCollection customers =
  Customer.list(params);
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const customers = await payske.customers.list({
  limit: 3,
});
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

params := &payske.CustomerListParams{}
params.Filters.AddFilter("limit", "", "3")
i := customer.List(params)
for i.Next() {
  c := i.Customer()
}
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var options = new CustomerListOptions
{
  Limit = 3,
};
var service = new CustomerService();
PayskeList<Customer> customers = service.List(
  options
);

Response

    {
      "object": "list",
      "url": "/v1/customers",
      "has_more": false,
      "data": [
        {
          "id": "cus_Kc344PP3X2o0IA",
          "object": "customer",
          "address": null,
          "balance": 0,
          "created": 1637158746,
          "currency": "usd",
          "default_source": null,
          "delinquent": false,
          "description": null,
          "discount": null,
          "email": null,
          "invoice_prefix": "B24281E",
          "invoice_settings": {
            "custom_fields": null,
            "default_payment_method": null,
            "footer": null
          },
          "livemode": false,
          "metadata": {},
          "name": null,
          "next_invoice_sequence": 1,
          "phone": null,
          "preferred_locales": [],
          "shipping": null,
          "tax_exempt": "none"
        },
        {...},
        {...}
      ]
    }

Returns a list of your customers. The customers are returned sorted by creation date, with the most recent customers appearing first.

Parameters
More parametersCollapse all

Returns

A dictionary with a data property that contains an array of up to limit customers, starting after customer starting_after. Passing an optional email will result in filtering to customers with only that exact email address. Each entry in the array is a separate customer object. If no more customers are available, the resulting array will be empty. This request should never return an error.

Refunds

Refund objects allow you to refund a charge that has previously been created but not yet refunded. Funds will be refunded to the credit or debit card that was originally charged.

Related guide: Refunds.

Was this section helpful? Yes No

The refund object

The refund object

    {
      "id": "re_3Jwoyw2eZvKYlo2C0j0W7b25",
      "object": "refund",
      "amount": 100,
      "balance_transaction": null,
      "charge": "ch_3Jwoyw2eZvKYlo2C0rAzmt9u",
      "created": 1637158767,
      "currency": "usd",
      "metadata": {},
      "payment_intent": null,
      "reason": null,
      "receipt_number": null,
      "source_transfer_reversal": null,
      "status": "succeeded",
      "transfer_reversal": null
    }

Attributes

More attributesCollapse all

Create a refund

POST    /v1/refunds
curl https://api.payske.com/v1/refunds \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
  -d charge=ch_3Jwoyw2eZvKYlo2C0rAzmt9u
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->refunds->create([
  'charge' => 'ch_3Jx9xt2eZvKYlo2C1gE6In53',
]);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Refund.create({
  charge: 'ch_3JxAEM2eZvKYlo2C1pR4wQkK',
})
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Refund.create(
  charge="ch_3JxAYt2eZvKYlo2C0i3NLUgg",
)
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Map<String, Object> params = new HashMap<>();
params.put(
  "charge",
  "ch_3JxAnQ2eZvKYlo2C0dYcNQ2j"
);

Refund refund = Refund.create(params);
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const refund = await payske.refunds.create({
  charge: 'ch_3JxAxn2eZvKYlo2C0fPqYpEL',
});
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

params := &payske.RefundParams{
  Charge: payske.String("ch_3JxB9E2eZvKYlo2C1Y7trE7d"),
}
r, _ := refund.New(params)
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var options = new RefundCreateOptions
{
  Charge = "ch_3JxX3a2eZvKYlo2C0PIuCt1c",
};
var service = new RefundService();
service.Create(options);

Response

    {
      "id": "re_3Jwoyw2eZvKYlo2C0j0W7b25",
      "object": "refund",
      "amount": 100,
      "balance_transaction": null,
      "charge": "ch_3Jwoyw2eZvKYlo2C0rAzmt9u",
      "created": 1637158767,
      "currency": "usd",
      "metadata": {},
      "payment_intent": null,
      "reason": null,
      "receipt_number": null,
      "source_transfer_reversal": null,
      "status": "succeeded",
      "transfer_reversal": null
    }

When you create a new refund, you must specify a Charge or a PaymentIntent object on which to create it.

Creating a new refund will refund a charge that has previously been created but not yet refunded. Funds will be refunded to the credit or debit card that was originally charged.

You can optionally refund only part of a charge. You can do so multiple times, until the entire charge has been refunded.

Once entirely refunded, a charge can’t be refunded again. This method will return an error when called on an already-refunded charge, or when trying to refund more money than is left on a charge.

Parameters

Returns

Returns the Refund object if the refund succeeded. Returns an error if the Charge/PaymentIntent has already been refunded, or if an invalid identifier was provided.

Retrieve a refund

GET    /v1/refunds/:id
curl https://api.payske.com/v1/refunds/re_3Jwoyw2eZvKYlo2C0j0W7b25 \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc:
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->refunds->retrieve(
  're_3Jx9xt2eZvKYlo2C1Ue24oub',
  []
);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Refund.retrieve(
  're_3JxAEM2eZvKYlo2C1BdXHYbZ',
)
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Refund.retrieve(
  "re_3JxAYt2eZvKYlo2C013QN07e",
)
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Refund refund =
  Refund.retrieve("re_3JxAnQ2eZvKYlo2C0yobhsNO");
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const refund = await payske.refunds.retrieve(
  're_3JxAxn2eZvKYlo2C0M0kr493'
);
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

r, _ := refund.Get(
  "re_3JxB9E2eZvKYlo2C13CYbVxh",
  nil,
)
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var service = new RefundService();
service.Get("re_3JxX3a2eZvKYlo2C075EWPso");

Response

    {
      "id": "re_3Jwoyw2eZvKYlo2C0j0W7b25",
      "object": "refund",
      "amount": 100,
      "balance_transaction": null,
      "charge": "ch_3Jwoyw2eZvKYlo2C0rAzmt9u",
      "created": 1637158767,
      "currency": "usd",
      "metadata": {},
      "payment_intent": null,
      "reason": null,
      "receipt_number": null,
      "source_transfer_reversal": null,
      "status": "succeeded",
      "transfer_reversal": null
    }

Retrieves the details of an existing refund.

Parameters

Returns

Returns a refund if a valid ID was provided. Returns an error otherwise.

Update a refund

POST    /v1/refunds/:id
curl https://api.payske.com/v1/refunds/re_3Jwoyw2eZvKYlo2C0j0W7b25 \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
  -d "metadata[order_id]"=6735
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->refunds->update(
  're_3Jx9xt2eZvKYlo2C1Ue24oub',
  ['metadata' => ['order_id' => '6735']]
);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Refund.update(
  're_3JxAEM2eZvKYlo2C1BdXHYbZ',
  {metadata: {order_id: '6735'}},
)
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Refund.modify(
  "re_3JxAYt2eZvKYlo2C013QN07e",
  metadata={"order_id": "6735"},
)
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Refund refund =
  Refund.retrieve("re_3JxAnQ2eZvKYlo2C0yobhsNO");

Map<String, Object> metadata = new HashMap<>();
metadata.put("order_id", "6735");
Map<String, Object> params = new HashMap<>();
params.put("metadata", metadata);

Refund updatedRefund = refund.update(params);
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const refunds = await payske.refunds.list({
  limit: 3,
});
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

params := &payske.RefundParams{}
params.AddMetadata("order_id", "6735")
r, _ := refund.Update(
  "re_3JxB9E2eZvKYlo2C13CYbVxh",
  params,
)
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var service = new RefundService();
service.Get("re_3JxX3a2eZvKYlo2C075EWPso");

Response

    {
      "id": "re_3Jwoyw2eZvKYlo2C0j0W7b25",
      "object": "refund",
      "amount": 100,
      "balance_transaction": null,
      "charge": "ch_3Jwoyw2eZvKYlo2C0rAzmt9u",
      "created": 1637158767,
      "currency": "usd",
      "metadata": {
        "order_id": "6735"
      },
      "payment_intent": null,
      "reason": null,
      "receipt_number": null,
      "source_transfer_reversal": null,
      "status": "succeeded",
      "transfer_reversal": null
    }Response

    {
      "id": "re_3Jwoyw2eZvKYlo2C0j0W7b25",
      "object": "refund",
      "amount": 100,
      "balance_transaction": null,
      "charge": "ch_3Jwoyw2eZvKYlo2C0rAzmt9u",
      "created": 1637158767,
      "currency": "usd",
      "metadata": {
        "order_id": "6735"
      },
      "payment_intent": null,
      "reason": null,
      "receipt_number": null,
      "source_transfer_reversal": null,
      "status": "succeeded",
      "transfer_reversal": null
    }

Updates the specified refund by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

This request only accepts metadata as an argument.

Parameters

Returns

Returns the refund object if the update succeeded. This call will return an error if update parameters are invalid.

List all refunds

GET    /v1/refunds
curl https://api.payske.com/v1/refunds \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
  -d limit=3 \
  -G
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->refunds->all(['limit' => 3]);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Refund.list({limit: 3})
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Refund.list(limit=3)
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Map<String, Object> params = new HashMap<>();
params.put("limit", 3);

RefundCollection refunds = Refund.list(params);
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const refunds = await payske.refunds.list({
  limit: 3,
});
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

params := &payske.RefundListParams{}
params.Filters.AddFilter("limit", "", "3")
i := refund.List(params)
for i.Next() {
  r := i.Refund()
}
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var options = new RefundListOptions { Limit = 3 };
var service = new RefundService();
PayskeList<Refund> refunds = service.List(
  options
);

Response

    {
      "object": "list",
      "url": "/v1/refunds",
      "has_more": false,
      "data": [
        {
          "id": "re_3Jwoyw2eZvKYlo2C0j0W7b25",
          "object": "refund",
          "amount": 100,
          "balance_transaction": null,
          "charge": "ch_3Jwoyw2eZvKYlo2C0rAzmt9u",
          "created": 1637158767,
          "currency": "usd",
          "metadata": {},
          "payment_intent": null,
          "reason": null,
          "receipt_number": null,
          "source_transfer_reversal": null,
          "status": "succeeded",
          "transfer_reversal": null
        },
        {...},
        {...}
      ]
    }

Returns a list of all refunds you’ve previously created. The refunds are returned in sorted order, with the most recent refunds appearing first. For convenience, the 10 most recent refunds are always available by default on the charge object.

Parameters

More parametersCollapse all

Returns

A dictionary with a data property that contains an array of up to limit refunds, starting after refund starting_after. Each entry in the array is a separate refund object. If no more refunds are available, the resulting array will be empty. If you provide a non-existent charge ID, this call returns an error.List all refunds

Tokens

Tokenization is the process Payske uses to collect sensitive card or bank account details, or personally identifiable information (PII), directly from your customers in a secure manner. A token representing this information is returned to your server to use. You should use our recommended payments integrations to perform this process client-side. This ensures that no sensitive card data touches your server, and allows your integration to operate in a PCI-compliant way.

If you cannot use client-side tokenization, you can also create tokens using the API with either your publishable or secret API key. Keep in mind that if your integration uses this method, you are responsible for any PCI compliance that may be required, and you must keep your secret API key safe. Unlike with client-side tokenization, your customer's information is not sent directly to Payske, so we cannot determine how it is handled or stored.

Tokens cannot be stored or used more than once. To store card or bank account information for later use, you can create Customer objects or Custom accounts. Note that Radar, our integrated solution for automatic fraud protection, performs best with integrations that use client-side tokenization.

Related guide: Accept a payment

Was this section helpful?YesNo

The token object

The token object

    {
      "id": "tok_1Jwoyx2eZvKYlo2Cst4eQ7CX",
      "object": "token",
      "card": {
        "id": "card_1Jwoyx2eZvKYlo2CzoY3eYaj",
        "object": "card",
        "address_city": null,
        "address_country": null,
        "address_line1": null,
        "address_line1_check": null,
        "address_line2": null,
        "address_state": null,
        "address_zip": null,
        "address_zip_check": null,
        "brand": "Visa",
        "country": "US",
        "cvc_check": "pass",
        "dynamic_last4": null,
        "exp_month": 8,
        "exp_year": 2022,
        "fingerprint": "Xt5EWLLDS7FJjR1c",
        "funding": "credit",
        "last4": "4242",
        "metadata": {},
        "name": null,
        "tokenization_method": null
      },
      "client_ip": null,
      "created": 1637158767,
      "livemode": false,
      "type": "card",
      "used": false
    }
Attributes
More attributesCollapse all

Create a card token

POST    /v1/tokens
curl https://api.payske.com/v1/tokens \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
  -d "card[number]"=4242424242424242 \
  -d "card[exp_month]"=11 \
  -d "card[exp_year]"=2022 \
  -d "card[cvc]"=314
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->tokens->create([
  'card' => [
    'number' => '4242424242424242',
    'exp_month' => 11,
    'exp_year' => 2022,
    'cvc' => '314',
  ],
]);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Token.create({
  card: {
    number: '4242424242424242',
    exp_month: 11,
    exp_year: 2022,
    cvc: '314',
  },
})
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Token.create(
  card={
    "number": "4242424242424242",
    "exp_month": 11,
    "exp_year": 2022,
    "cvc": "314",
  },
)
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Map<String, Object> card = new HashMap<>();
card.put("number", "4242424242424242");
card.put("exp_month", 11);
card.put("exp_year", 2022);
card.put("cvc", "314");
Map<String, Object> params = new HashMap<>();
params.put("card", card);

Token token = Token.create(params);
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const token = await payske.tokens.create({
  card: {
    number: '4242424242424242',
    exp_month: 11,
    exp_year: 2022,
    cvc: '314',
  },
});
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

params := &payske.TokenParams{
  Card: &payske.CardParams{
    Number: payske.String("4242424242424242"),
    ExpMonth: payske.String("12"),
    ExpYear: payske.String("2022"),
    CVC: payske.String("123"),
  },
}
t, err := token.New(params)
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var options = new TokenCreateOptions
{
  Card = new TokenCardOptions
  {
    Number = "4242424242424242",
    ExpMonth = 11,
    ExpYear = 2022,
    Cvc = "314",
  },
};
var service = new TokenService();
service.Create(options);

Response

    {
      "id": "tok_1Jwoyx2eZvKYlo2Cst4eQ7CX",
      "object": "token",
      "card": {
        "id": "card_1Jwoyx2eZvKYlo2CzoY3eYaj",
        "object": "card",
        "address_city": null,
        "address_country": null,
        "address_line1": null,
        "address_line1_check": null,
        "address_line2": null,
        "address_state": null,
        "address_zip": null,
        "address_zip_check": null,
        "brand": "Visa",
        "country": "US",
        "cvc_check": "pass",
        "dynamic_last4": null,
        "exp_month": 8,
        "exp_year": 2022,
        "fingerprint": "Xt5EWLLDS7FJjR1c",
        "funding": "credit",
        "last4": "4242",
        "metadata": {},
        "name": null,
        "tokenization_method": null
      },
      "client_ip": null,
      "created": 1637158767,
      "livemode": false,
      "type": "card",
      "used": false
    }

Creates a single-use token that represents a credit card’s details. This token can be used in place of a credit card dictionary with any API method. These tokens can be used only once: by creating a new Charge object, or by attaching them to a Customer object.

In most cases, you should use our recommended payments integrations instead of using the API.

Parameters

More parameters

Returns

Returns the created card token if successful. Otherwise, this call raises an error.

Create a bank account token

POST    /v1/tokens
curl https://api.payske.com/v1/tokens \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
  -d "bank_account[country]"=US \
  -d "bank_account[currency]"=usd \
  -d "bank_account[account_holder_name]"="Jenny Rosen" \
  -d "bank_account[account_holder_type]"=individual \
  -d "bank_account[routing_number]"=110000000 \
  -d "bank_account[account_number]"=000123456789
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->tokens->create([
  'bank_account' => [
    'country' => 'US',
    'currency' => 'usd',
    'account_holder_name' => 'Jenny Rosen',
    'account_holder_type' => 'individual',
    'routing_number' => '110000000',
    'account_number' => '000123456789',
  ],
]);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Token.create({
  bank_account: {
    country: 'US',
    currency: 'usd',
    account_holder_name: 'Jenny Rosen',
    account_holder_type: 'individual',
    routing_number: '110000000',
    account_number: '000123456789',
  },
})
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Token.create(
  bank_account={
    "country": "US",
    "currency": "usd",
    "account_holder_name": "Jenny Rosen",
    "account_holder_type": "individual",
    "routing_number": "110000000",
    "account_number": "000123456789",
  },
)
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Map<String, Object> bankAccount = new HashMap<>();
bankAccount.put("country", "US");
bankAccount.put("currency", "usd");
bankAccount.put(
  "account_holder_name",
  "Jenny Rosen"
);
bankAccount.put(
  "account_holder_type",
  "individual"
);
bankAccount.put("routing_number", "110000000");
bankAccount.put("account_number", "000123456789");
Map<String, Object> params = new HashMap<>();
params.put("bank_account", bankAccount);

Token token = Token.create(params);
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const token = await payske.tokens.create({
  bank_account: {
    country: 'US',
    currency: 'usd',
    account_holder_name: 'Jenny Rosen',
    account_holder_type: 'individual',
    routing_number: '110000000',
    account_number: '000123456789',
  },
});
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

t, err := token.New(&payske.TokenParams{
  BankAccount: &payske.BankAccountParams{
    Country: payske.String("US"),
    Currency: payske.String(string(payske.CurrencyUSD)),
    AccountHolderName: payske.String("Jenny Rosen"),
    AccountHolderType: payske.String(string(payske.BankAccountAccountHolderTypeIndividual)),
    RoutingNumber: payske.String("110000000"),
    AccountNumber: payske.String("000123456789"),
  },
})
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var options = new TokenCreateOptions
{
  BankAccount = new TokenBankAccountOptions
  {
    Country = "US",
    Currency = "usd",
    AccountHolderName = "Jenny Rosen",
    AccountHolderType = "individual",
    RoutingNumber = "110000000",
    AccountNumber = "000123456789",
  },
};
var service = new TokenService();
service.Create(options);

Response

    {
      "id": "btok_1Jwoyx2eZvKYlo2CeuW0logQ",
      "object": "token",
      "bank_account": {
        "id": "ba_1Jwoyx2eZvKYlo2CylNVcYhE",
        "object": "bank_account",
        "account_holder_name": "Jane Austen",
        "account_holder_type": "individual",
        "account_type": null,
        "bank_name": "PAYSKE TEST BANK",
        "country": "US",
        "currency": "usd",
        "fingerprint": "1JWtPxqbdX5Gamtz",
        "last4": "6789",
        "routing_number": "110000000",
        "status": "new"
      },
      "client_ip": null,
      "created": 1637158767,
      "livemode": false,
      "type": "bank_account",
      "used": false
    }Response

    {
      "id": "btok_1Jwoyx2eZvKYlo2CeuW0logQ",
      "object": "token",
      "bank_account": {
        "id": "ba_1Jwoyx2eZvKYlo2CylNVcYhE",
        "object": "bank_account",
        "account_holder_name": "Jane Austen",
        "account_holder_type": "individual",
        "account_type": null,
        "bank_name": "PAYSKE TEST BANK",
        "country": "US",
        "currency": "usd",
        "fingerprint": "1JWtPxqbdX5Gamtz",
        "last4": "6789",
        "routing_number": "110000000",
        "status": "new"
      },
      "client_ip": null,
      "created": 1637158767,
      "livemode": false,
      "type": "bank_account",
      "used": false
    }

Creates a single-use token that represents a bank account’s details. This token can be used with any API method in place of a bank account dictionary. This token can be used only once, by attaching it to a Custom account.

Parameters

More parameters

Returns

Returns the created bank account token if successful. Otherwise, this call returns an error.

Retrieve a token

GET    /v1/tokens/:id
curl https://api.payske.com/v1/tokens/tok_1Jwoyx2eZvKYlo2Cst4eQ7CX \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc:
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->tokens->retrieve(
  'tok_1Jx9xv2eZvKYlo2CiSvqBeAh',
  []
);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Token.retrieve(
  'tok_1JxAEN2eZvKYlo2CVVxeiATk',
)
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Token.retrieve(
  "tok_1JxAYu2eZvKYlo2CxGJgJScw",
)
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Token token =
  Token.retrieve("tok_1JxAnS2eZvKYlo2C3KpgVswv");
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const token = await payske.tokens.retrieve(
  'tok_1JxAxp2eZvKYlo2CBXY5bfaO'
);
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

t, _ := token.Get(
  "tok_1JxB9F2eZvKYlo2Ck8XdmmD3",
  nil,
)
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var service = new TokenService();
service.Get("tok_1JxX3c2eZvKYlo2CnSyVWRfc");

Response

    {
      "id": "tok_1Jwoyx2eZvKYlo2Cst4eQ7CX",
      "object": "token",
      "card": {
        "id": "card_1Jwoyx2eZvKYlo2CzoY3eYaj",
        "object": "card",
        "address_city": null,
        "address_country": null,
        "address_line1": null,
        "address_line1_check": null,
        "address_line2": null,
        "address_state": null,
        "address_zip": null,
        "address_zip_check": null,
        "brand": "Visa",
        "country": "US",
        "cvc_check": "pass",
        "dynamic_last4": null,
        "exp_month": 8,
        "exp_year": 2022,
        "fingerprint": "Xt5EWLLDS7FJjR1c",
        "funding": "credit",
        "last4": "4242",
        "metadata": {},
        "name": null,
        "tokenization_method": null
      },
      "client_ip": null,
      "created": 1637158767,
      "livemode": false,
      "type": "card",
      "used": false
    }

Retrieves the token with the given ID.

Parameters

Returns

Returns a token if a valid ID was provided. Returns an error otherwise.

Update Token

not allow update token after creation

List all tokens

Not applicable

_______________

PaymentMethods

PaymentMethod objects represent your customer's payment instruments. They can be used with PaymentIntents to collect payments or saved to Customer objects to store instrument details for future payments.

Related guides: Payment Methods and More Payment Scenarios.

Was this section helpful?YesNo

Sources

Source objects allow you to accept a variety of payment methods. They represent a customer's payment instrument, and can be used with the Payske API just like a Card object: once chargeable, they can be charged, or can be attached to customers.

Related guides: Sources API and Sources & Customers.

Was this section helpful? Yes No

The source object

The source object

    {
      "id": "src_1Jwvg92eZvKYlo2CeGmNMtVB",
      "object": "source",
      "ach_credit_transfer": {
        "account_number": "test_52796e3294dc",
        "routing_number": "110000000",
        "fingerprint": "ecpwEzmBOSMOqQTL",
        "bank_name": "TEST BANK",
        "swift_code": "TSTEZ122"
      },
      "amount": null,
      "client_secret": "src_client_secret_nT8WVTNQnmzFxfOTy3E4KNyo",
      "created": 1637184509,
      "currency": "usd",
      "flow": "receiver",
      "livemode": false,
      "metadata": {},
      "owner": {
        "address": null,
        "email": "jenny.rosen@example.com",
        "name": null,
        "phone": null,
        "verified_address": null,
        "verified_email": null,
        "verified_name": null,
        "verified_phone": null
      },
      "receiver": {
        "address": "121042882-38381234567890123",
        "amount_charged": 0,
        "amount_received": 0,
        "amount_returned": 0,
        "refund_attributes_method": "email",
        "refund_attributes_status": "missing"
      },
      "statement_descriptor": null,
      "status": "pending",
      "type": "ach_credit_transfer",
      "usage": "reusable"
    }

Attributes

More attributesCollapse all

Create a source

POST    /v1/sources
curl https://api.payske.com/v1/sources \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
  -d type=ach_credit_transfer \
  -d currency=usd \
  -d "owner[email]"="jenny.rosen@example.com"
$payske = new \Payske\PayskeClient("sk_test_4eC39HqLyjWDarjtT1zdp7dc");
$payske->sources->create([
  "type" => "ach_credit_transfer",
  "currency" => "usd",
  "owner" => [
    "email" => "jenny.rosen@example.com"
  ]
]);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Source.create({
  type: 'ach_credit_transfer',
  currency: 'usd',
  owner: {
    email: 'jenny.rosen@example.com',
  },
})
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Source.create(
  type='ach_credit_transfer',
  currency='usd',
  owner={
    'email': 'jenny.rosen@example.com'
  }
)
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Map<String, Object> sourceParams = new HashMap<>();
sourceParams.put("type", "ach_credit_transfer");
sourceParams.put("currency", "usd");
Map<String, Object> ownerParams = new HashMap<>();
ownerParams.put("email", "jenny.rosen@example.com");
sourceParams.put("owner", ownerParams);

Source.create(sourceParams);
const Payske = require('payske');
const payske = Payske('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
payske.sources.create({
  type: 'ach_credit_transfer',
  currency: 'usd',
  owner: {
    email: 'jenny.rosen@example.com'
  }
}, function(err, source) {
  // asynchronously called
});
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

params := &payske.SourceObjectParams{
  Type: payske.String("ach_credit_transfer"),
  Currency: payske.String(string(payske.CurrencyUSD)),
  Owner: &payske.SourceOwnerParams{
    Email: payske.String("jenny.rosen@example.com"),
  },
}
s, err := source.New(params)
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var options = new SourceCreateOptions {
  Type = SourceType.AchCreditTransfer,
  Currency = "usd",
  Owner = new SourceOwnerOptions {
    Email = "jenny.rosen@example.com"
  }
};

var service = new SourceService();
Source source = service.Create(options);

Response

    {
      "id": "src_1Jwvg92eZvKYlo2CeGmNMtVB",
      "object": "source",
      "ach_credit_transfer": {
        "account_number": "test_52796e3294dc",
        "routing_number": "110000000",
        "fingerprint": "ecpwEzmBOSMOqQTL",
        "bank_name": "TEST BANK",
        "swift_code": "TSTEZ122"
      },
      "amount": null,
      "client_secret": "src_client_secret_nT8WVTNQnmzFxfOTy3E4KNyo",
      "created": 1637184509,
      "currency": "usd",
      "flow": "receiver",
      "livemode": false,
      "metadata": {},
      "owner": {
        "address": null,
        "email": "jenny.rosen@example.com",
        "name": null,
        "phone": null,
        "verified_address": null,
        "verified_email": null,
        "verified_name": null,
        "verified_phone": null
      },
      "receiver": {
        "address": "121042882-38381234567890123",
        "amount_charged": 0,
        "amount_received": 0,
        "amount_returned": 0,
        "refund_attributes_method": "email",
        "refund_attributes_status": "missing"
      },
      "statement_descriptor": null,
      "status": "pending",
      "type": "ach_credit_transfer",
      "usage": "reusable"
    }

Creates a new source object.

Parameters

More parametersCollapse all

Returns

Returns a newly created source.

Retrieve a source

GET    /v1/sources/:id
curl https://api.payske.com/v1/sources/src_1JwwRo2eZvKYlo2CZnVjJKlC \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc:
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->sources->retrieve(
  'src_1Jx9xt2eZvKYlo2CRdyvKklA',
  []
);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Source.retrieve(
  'src_1JxAEO2eZvKYlo2CxpWstPxA',
)
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Source.retrieve(
  "src_1JxAYu2eZvKYlo2C4YvOJ3Ad",
)
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Source source =
  Source.retrieve("src_1JxAnS2eZvKYlo2CuLrl9mm1");
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const source = await payske.sources.retrieve(
  'src_1JxAxp2eZvKYlo2CDti7eaHx'
);
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

s, _ := source.Get(
  "src_1JxB9F2eZvKYlo2CkP36Z4dl",
  nil,
)
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var service = new SourceService();
service.Get("src_1JxX3c2eZvKYlo2CXU7KrTqR");

Response

    {
      "id": "src_1Jwvg92eZvKYlo2CeGmNMtVB",
      "object": "source",
      "ach_credit_transfer": {
        "account_number": "test_52796e3294dc",
        "routing_number": "110000000",
        "fingerprint": "ecpwEzmBOSMOqQTL",
        "bank_name": "TEST BANK",
        "swift_code": "TSTEZ122"
      },
      "amount": null,
      "client_secret": "src_client_secret_nT8WVTNQnmzFxfOTy3E4KNyo",
      "created": 1637184509,
      "currency": "usd",
      "flow": "receiver",
      "livemode": false,
      "metadata": {},
      "owner": {
        "address": null,
        "email": "jenny.rosen@example.com",
        "name": null,
        "phone": null,
        "verified_address": null,
        "verified_email": null,
        "verified_name": null,
        "verified_phone": null
      },
      "receiver": {
        "address": "121042882-38381234567890123",
        "amount_charged": 0,
        "amount_received": 0,
        "amount_returned": 0,
        "refund_attributes_method": "email",
        "refund_attributes_status": "missing"
      },
      "statement_descriptor": null,
      "status": "pending",
      "type": "ach_credit_transfer",
      "usage": "reusable"
    }

Retrieves an existing source object. Supply the unique source ID from a source creation request and Payske will return the corresponding up-to-date source object information.

ParametersCollapse all

Returns

Returns a source if a valid identifier was provided.

Update a source

POST    /v1/sources/:id
curl https://api.payske.com/v1/sources/src_1JwwRo2eZvKYlo2CZnVjJKlC \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
  -d "metadata[order_id]"=6735
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->sources->update(
  'src_1Jx9xt2eZvKYlo2CRdyvKklA',
  ['metadata' => ['order_id' => '6735']]
);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Source.update(
  'src_1JxAEO2eZvKYlo2CxpWstPxA',
  {metadata: {order_id: '6735'}},
)
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Source.modify(
  "src_1JxAYu2eZvKYlo2C4YvOJ3Ad",
  metadata={"order_id": "6735"},
)
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Source source =
  Source.retrieve("src_1JxAnS2eZvKYlo2CuLrl9mm1");

Map<String, Object> metadata = new HashMap<>();
metadata.put("order_id", "6735");
Map<String, Object> params = new HashMap<>();
params.put("metadata", metadata);

Source updatedSource = source.update(params);
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const source = await payske.sources.update(
  'src_1JxAxp2eZvKYlo2CDti7eaHx',
  {metadata: {order_id: '6735'}}
);
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

params := &payske.SourceObjectParams{}
params.AddMetadata("order_id", "6735")
s, _ := source.Update(
  "src_1JxB9F2eZvKYlo2CkP36Z4dl",
  params,
)
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var options = new SourceUpdateOptions
{
  Metadata = new Dictionary<string, string>
  {
    { "order_id", "6735" },
  },
};
var service = new SourceService();
service.Update(
  "src_1JxX3c2eZvKYlo2CXU7KrTqR",
  options
);

Response

    {
      "id": "src_1JwwRo2eZvKYlo2CZnVjJKlC",
      "object": "source",
      "ach_credit_transfer": {
        "account_number": "test_52796e3294dc",
        "routing_number": "110000000",
        "fingerprint": "ecpwEzmBOSMOqQTL",
        "bank_name": "TEST BANK",
        "swift_code": "TSTEZ122"
      },
      "amount": null,
      "client_secret": "src_client_secret_pv0r2LJ9ceAUZWHFP7sMFUGa",
      "created": 1637187464,
      "currency": "usd",
      "flow": "receiver",
      "livemode": false,
      "metadata": {
        "order_id": "6735"
      },
      "owner": {
        "address": null,
        "email": "jenny.rosen@example.com",
        "name": null,
        "phone": null,
        "verified_address": null,
        "verified_email": null,
        "verified_name": null,
        "verified_phone": null
      },
      "receiver": {
        "address": "121042882-38381234567890123",
        "amount_charged": 0,
        "amount_received": 0,
        "amount_returned": 0,
        "refund_attributes_method": "email",
        "refund_attributes_status": "missing"
      },
      "statement_descriptor": null,
      "status": "pending",
      "type": "ach_credit_transfer",
      "usage": "reusable"
    }

Updates the specified source by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

This request accepts the metadata and owner as arguments. It is also possible to update type specific information for selected payment methods. Please refer to our payment method guides for more detail.

Parameters

More parametersCollapse all

Returns

Returns the source object if the update succeeded. This call will throw an error if update parameters are invalid.

Attach a source

POST    /v1/customers/:id/sources
curl https://api.payske.com/v1/customers/cus_AJ6yA7mRH34mJT/sources \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
  -d source=src_1JwwRo2eZvKYlo2CZnVjJKlC
$payske = new \Payske\PayskeClient("sk_test_4eC39HqLyjWDarjtT1zdp7dc");
$payske->customers->createSource(
  'cus_AJ6yA7mRH34mJT',
  [
    'source' => 'src_1Jx9xt2eZvKYlo2CRdyvKklA',
  ]
);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Customer.create_source(
  'cus_AJ6yA7mRH34mJT',
  {
    source: 'src_1JxAEO2eZvKYlo2CxpWstPxA',
  }
)
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

source = payske.Customer.create_source(
  'cus_AJ6yA7mRH34mJT',
  source='src_1JxAYu2eZvKYlo2C4YvOJ3Ad'
)
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

List<String> expandList = new ArrayList<>();
expandList.add("sources");

Map<String, Object> retrieveParams = new HashMap<>();
retrieveParams.put("expand", expandList);

Customer customer =
  Customer.retrieve(
    "cus_AJ6yA7mRH34mJT",
    retrieveParams,
    null
  );
Map<String, Object> params = new HashMap<>();
params.put("source", "src_1JxAnS2eZvKYlo2CuLrl9mm1");
customer.getSources().create(params);
const Payske = require('payske');
const payske = Payske('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
payske.customers.createSource(
  'cus_AJ6yA7mRH34mJT',
  {
    source: 'src_1JxAxp2eZvKYlo2CDti7eaHx',
  },
  function(err, source) {
    // asynchronously called
  }
);
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

params := &payske.CustomerSourceParams{
  Customer: payske.String("cus_AJ6yA7mRH34mJT"),
  Source: &payske.SourceParams{
    Token: payske.String("src_1JxB9F2eZvKYlo2CkP36Z4dl"),
  },
}
s, err := paymentsource.New(params)
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var options = new SourceAttachOptions
{
  Source = "src_1JxX3c2eZvKYlo2CXU7KrTqR",
};
var service = new SourceService();
var source = service.Attach('cus_AJ6yA7mRH34mJT', options);

Response

    {
      "id": "src_1JwwRo2eZvKYlo2CZnVjJKlC",
      "object": "source",
      "ach_credit_transfer": {
        "account_number": "test_52796e3294dc",
        "routing_number": "110000000",
        "fingerprint": "ecpwEzmBOSMOqQTL",
        "bank_name": "TEST BANK",
        "swift_code": "TSTEZ122"
      },
      "amount": 1000,
      "client_secret": "src_client_secret_pv0r2LJ9ceAUZWHFP7sMFUGa",
      "created": 1637187464,
      "currency": "usd",
      "flow": "receiver",
      "livemode": false,
      "metadata": {},
      "owner": {
        "address": null,
        "email": "jenny.rosen@example.com",
        "name": null,
        "phone": null,
        "verified_address": null,
        "verified_email": null,
        "verified_name": null,
        "verified_phone": null
      },
      "receiver": {
        "address": "121042882-38381234567890123",
        "amount_received": 1000,
        "amount_charged": 0,
        "amount_returned": 0,
        "refund_attributes_status": "missing",
        "refund_attributes_method": "email"
      },
      "statement_descriptor": null,
      "status": "chargeable",
      "type": "ach_credit_transfer",
      "usage": "reusable",
      "customer": "cus_AJ6yA7mRH34mJT"
    }

Attaches a Source object to a Customer. The source must be in a chargeable or pending state.

Parameters

Returns

Returns the attached Source object.

Detach a source

DELETE    /v1/customers/:id/sources/:id
curl https://api.payske.com/v1/customers/cus_AJ6yA7mRH34mJT/sources/src_1JwwRo2eZvKYlo2CZnVjJKlC \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
  -X DELETE
$payske = new \Payske\PayskeClient("sk_test_4eC39HqLyjWDarjtT1zdp7dc");
$payske->customers->deleteSource(
  'cus_AJ6yA7mRH34mJT',
  'src_1JxXtD2eZvKYlo2CZ8wOZpcJ'
);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Customer.detach_source(
  'cus_AJ6yA7mRH34mJT',
  'src_1JxAEO2eZvKYlo2CxpWstPxA'
)
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Customer.delete_source(
  'cus_AJ6yA7mRH34mJT',
  'src_1JxAYu2eZvKYlo2C4YvOJ3Ad'
)
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Source source = Source.retrieve("src_1JxAnS2eZvKYlo2CuLrl9mm1");
source.detach();
const Payske = require('payske');
const payske = Payske('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
payske.customers.deleteSource(
  'cus_AJ6yA7mRH34mJT',
  'src_1JxAxp2eZvKYlo2CDti7eaHx',
  function(err, confirmation) {
    // asynchronously called
  }
);
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

params := &payske.SourceObjectDetachParams{
  Customer: payske.String("cus_AJ6yA7mRH34mJT"),
}
s, err := source.Detach("src_1JxB9F2eZvKYlo2CkP36Z4dl", params)payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

params := &payske.SourceObjectDetachParams{
  Customer: payske.String("cus_AJ6yA7mRH34mJT"),
}
s, err := source.Detach("src_1JxB9F2eZvKYlo2CkP36Z4dl", params)
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var service = new SourceService();
var source = service.Detach("cus_AJ6yA7mRH34mJT", "src_1JxX3c2eZvKYlo2CXU7KrTqR");

Response


    {
      "id": "src_1JwwRo2eZvKYlo2CZnVjJKlC",
      "object": "source",
      "ach_credit_transfer": {
        "account_number": "test_52796e3294dc",
        "routing_number": "110000000",
        "fingerprint": "ecpwEzmBOSMOqQTL",
        "bank_name": "TEST BANK",
        "swift_code": "TSTEZ122"
      },
      "amount": 0,
      "client_secret": "src_client_secret_pv0r2LJ9ceAUZWHFP7sMFUGa",
      "created": 1637187464,
      "currency": "usd",
      "flow": "receiver",
      "livemode": false,
      "metadata": {},
      "owner": {
        "address": null,
        "email": "jenny.rosen@example.com",
        "name": null,
        "phone": null,
        "verified_address": null,
        "verified_email": null,
        "verified_name": null,
        "verified_phone": null
      },
      "receiver": {
        "address": "121042882-38381234567890123",
        "amount_received": 1000,
        "amount_charged": 1000,
        "amount_returned": 0,
        "refund_attributes_status": "missing",
        "refund_attributes_method": "email"
      },
      "statement_descriptor": null,
      "status": "consumed",
      "type": "ach_credit_transfer",
      "usage": "reusable",
      "customer": "cus_AJ6yA7mRH34mJT"
    }

Detaches a Source object from a Customer. The status of a source is changed to consumed when it is detached and it can no longer be used to create a charge.

Parameters

Returns

Returns the detached Source object.

Cards

You can store multiple cards on a customer in order to charge the customer later. You can also store multiple debit cards on a recipient in order to transfer to those cards later.

Related guide: Card Payments with Sources.

Was this section helpful? Yes No

The card object

The card object

    {
      "id": "card_1Jwvx22eZvKYlo2C7q732luw",
      "object": "card",
      "address_city": null,
      "address_country": null,
      "address_line1": null,
      "address_line1_check": null,
      "address_line2": null,
      "address_state": null,
      "address_zip": null,
      "address_zip_check": null,
      "brand": "Visa",
      "country": "US",
      "customer": null,
      "cvc_check": "pass",
      "dynamic_last4": null,
      "exp_month": 8,
      "exp_year": 2022,
      "fingerprint": "Xt5EWLLDS7FJjR1c",
      "funding": "credit",
      "last4": "4242",
      "metadata": {},
      "name": null,
      "tokenization_method": null
    }

Attributes

More attributesCollapse all

Create a card

POST    /v1/customers/:id/sources
curl https://api.payske.com/v1/customers/cus_AJ6yA7mRH34mJT/sources \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
  -d source=tok_amex
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->customers->createSource(
  'cus_AJ6yA7mRH34mJT',
  ['source' => 'tok_amex']
);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Customer.create_source(
  'cus_AJ6yA7mRH34mJT',
  {source: 'tok_mastercard'},
)
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Customer.create_source(
  "cus_AJ6yA7mRH34mJT",
  source="tok_visa",
)
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Map<String, Object> retrieveParams =
  new HashMap<>();
List<String> expandList = new ArrayList<>();
expandList.add("sources");
retrieveParams.put("expand", expandList);
Customer customer =
  Customer.retrieve(
    "cus_AJ6yA7mRH34mJT",
    retrieveParams,
    null
  );

Map<String, Object> params = new HashMap<>();
params.put("source", "tok_amex");

Card card =
  (Card) customer.getSources().create(params);
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const card = await payske.customers.createSource(
  'cus_AJ6yA7mRH34mJT',
  {source: 'tok_mastercard'}
);
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

params := &payske.CardParams{
  Customer: payske.String("cus_AJ6yA7mRH34mJT"),
  Token: payske.String("tok_amex"),
}
c, err := card.New(params)
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var options = new CardCreateOptions
{
  Source = "tok_visa",
};
var service = new CardService();
service.Create("cus_AJ6yA7mRH34mJT", options);

Response

    {
      "id": "card_1Jwvx22eZvKYlo2C7q732luw",
      "object": "card",
      "address_city": null,
      "address_country": null,
      "address_line1": null,
      "address_line1_check": null,
      "address_line2": null,
      "address_state": null,
      "address_zip": null,
      "address_zip_check": null,
      "brand": "Visa",
      "country": "US",
      "customer": "cus_AJ6yA7mRH34mJT",
      "cvc_check": "pass",
      "dynamic_last4": null,
      "exp_month": 8,
      "exp_year": 2022,
      "fingerprint": "Xt5EWLLDS7FJjR1c",
      "funding": "credit",
      "last4": "4242",
      "metadata": {},
      "name": null,
      "tokenization_method": null
    }

When you create a new credit card, you must specify a customer or recipient on which to create it.

If the card’s owner has no default card, then the new card will become the default. However, if the owner already has a default, then it will not change. To change the default, you should update the customer to have a new default_source.

Parameters

Returns

Returns the Card object.

Retrieve a card

GET    /v1/customers/:id/sources/:id
curl https://api.payske.com/v1/customers/cus_AJ6yA7mRH34mJT/sources/card_1Jwvx22eZvKYlo2C7q732luw \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc:
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->customers->retrieveSource(
  'cus_AJ6yA7mRH34mJT',
  'card_1Jx9xt2eZvKYlo2CmDZcDDHY',
  []
);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Customer.retrieve_source(
  'cus_AJ6yA7mRH34mJT',
  'card_1JxAEM2eZvKYlo2CaqgYB2xk',
)
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Customer.retrieve_source(
  "cus_AJ6yA7mRH34mJT",
  "card_1JxAYt2eZvKYlo2CTZUNIqGY",
)
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Map<String, Object> retrieveParams =
  new HashMap<>();
List<String> expandList = new ArrayList<>();
expandList.add("sources");
retrieveParams.put("expand", expandList);
Customer customer =
  Customer.retrieve(
    "cus_AJ6yA7mRH34mJT",
    retrieveParams,
    null
  );

Card card =
  (Card) customer.getSources().retrieve(
    "card_1JxAnQ2eZvKYlo2CSHJgfO7D"
  );
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const card = await payske.customers.retrieveSource(
  'cus_AJ6yA7mRH34mJT',
  'card_1JxAxn2eZvKYlo2CKrTu5IxA'
);
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

params := &payske.CardParams{
  Customer: payske.String("cus_AJ6yA7mRH34mJT"),
}
c, _ := card.Get(
  "card_1JxB9E2eZvKYlo2C1dC8gPvE",
  params,
)
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var service = new CardService();
service.Get(
  "cus_AJ6yA7mRH34mJT",
  "card_1JxX3a2eZvKYlo2CAgnJq5yN"
);

Response

    {
      "id": "card_1Jwvx22eZvKYlo2C7q732luw",
      "object": "card",
      "address_city": null,
      "address_country": null,
      "address_line1": null,
      "address_line1_check": null,
      "address_line2": null,
      "address_state": null,
      "address_zip": null,
      "address_zip_check": null,
      "brand": "Visa",
      "country": "US",
      "customer": "cus_AJ6yA7mRH34mJT",
      "cvc_check": "pass",
      "dynamic_last4": null,
      "exp_month": 8,
      "exp_year": 2022,
      "fingerprint": "Xt5EWLLDS7FJjR1c",
      "funding": "credit",
      "last4": "4242",
      "metadata": {},
      "name": null,
      "tokenization_method": null
    }

You can always see the 10 most recent cards directly on a customer; this method lets you retrieve details about a specific card stored on the customer.

Parameters

Returns

Returns the Card object.

Update a card

POST    /v1/customers/:id/sources/:id
curl https://api.payske.com/v1/customers/cus_AJ6yA7mRH34mJT/sources/card_1JxXlk2eZvKYlo2CxxLhecjw \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
  -d name="Jenny Rosen"
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->customers->updateSource(
  'cus_AJ6yA7mRH34mJT',
  'card_1Jx9xt2eZvKYlo2CmDZcDDHY',
  ['name' => 'Jenny Rosen']
);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Customer.update_source(
  'cus_AJ6yA7mRH34mJT',
  'card_1JxAEM2eZvKYlo2CaqgYB2xk',
  {name: 'Jenny Rosen'},
)
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Customer.modify_source(
  "cus_AJ6yA7mRH34mJT",
  "card_1JxAYt2eZvKYlo2CTZUNIqGY",
  name="Jenny Rosen",
)
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Map<String, Object> retrieveParams =
  new HashMap<>();
List<String> expandList = new ArrayList<>();
expandList.add("sources");
retrieveParams.put("expand", expandList);
Customer customer =
  Customer.retrieve(
    "cus_AJ6yA7mRH34mJT",
    retrieveParams,
    null
  );

Card card =
  customer.getSources().retrieve(
    "card_1JxAnQ2eZvKYlo2CSHJgfO7D"
  );

Map<String, Object> params = new HashMap<>();
params.put("name", "Jenny Rosen");

Card updatedCard = (Card) card.update(params);
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const card = await payske.customers.updateSource(
  'cus_AJ6yA7mRH34mJT',
  'card_1JxAxn2eZvKYlo2CKrTu5IxA',
  {name: 'Jenny Rosen'}
);
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

params := &payske.CardParams{
  Customer: payske.String("cus_AJ6yA7mRH34mJT"),
  Name: payske.String("Jenny Rosen"),
}
c, _ := card.Update(
  "card_1JxB9E2eZvKYlo2C1dC8gPvE",
  params,
)
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var options = new CardUpdateOptions
{
  Name = "Jenny Rosen",
};
var service = new CardService();
service.Update(
  "cus_AJ6yA7mRH34mJT",
  "card_1JxX3a2eZvKYlo2CAgnJq5yN",
  options
);

Response

    {
      "id": "card_1Jwvx22eZvKYlo2C7q732luw",
      "object": "card",
      "address_city": null,
      "address_country": null,
      "address_line1": null,
      "address_line1_check": null,
      "address_line2": null,
      "address_state": null,
      "address_zip": null,
      "address_zip_check": null,
      "brand": "Visa",
      "country": "US",
      "customer": "cus_AJ6yA7mRH34mJT",
      "cvc_check": "pass",
      "dynamic_last4": null,
      "exp_month": 8,
      "exp_year": 2022,
      "fingerprint": "Xt5EWLLDS7FJjR1c",
      "funding": "credit",
      "last4": "4242",
      "metadata": {},
      "name": "Jenny Rosen",
      "tokenization_method": null
    }

If you need to update only some card details, like the billing address or expiration date, you can do so without having to re-enter the full card details. Also, Payske works directly with card networks so that your customers can continue using your service without interruption.

When you update a card, Payske typically validates the card automatically. For more details, see Check if a card is valid without a charge.

Parameters

Returns

Returns the Card object.

Delete a card

DELETE    /v1/customers/:id/sources/:id
curl https://api.payske.com/v1/customers/cus_AJ6yA7mRH34mJT/sources/card_1Jwvx22eZvKYlo2C7q732luw \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
  -X DELETE
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->customers->deleteSource(
  'cus_AJ6yA7mRH34mJT',
  'card_1Jx9xt2eZvKYlo2CmDZcDDHY',
  []
);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Customer.delete_source(
  'cus_AJ6yA7mRH34mJT',
  'card_1JxAEM2eZvKYlo2CaqgYB2xk',
)
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Customer.delete_source(
  "cus_AJ6yA7mRH34mJT",
  "card_1JxAYt2eZvKYlo2CTZUNIqGY",
)
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Map<String, Object> retrieveParams =
  new HashMap<>();
List<String> expandList = new ArrayList<>();
expandList.add("sources");
retrieveParams.put("expand", expandList);
Customer customer =
  Customer.retrieve(
    "cus_AJ6yA7mRH34mJT",
    retrieveParams,
    null
  );

Card card =
  customer.getSources().retrieve(
    "card_1JxAnQ2eZvKYlo2CSHJgfO7D"
  );

Card deletedCard = (Card) card.delete();
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const deleted = await payske.customers.deleteSource(
  'cus_AJ6yA7mRH34mJT',
  'card_1JxAxn2eZvKYlo2CKrTu5IxA'
);
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

params := &payske.CardParams{
  Customer: payske.String("cus_AJ6yA7mRH34mJT"),
}
c, _ := card.Del(
  "card_1JxB9E2eZvKYlo2C1dC8gPvE",
  params,
)
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var service = new CardService();
service.Delete(
  "cus_AJ6yA7mRH34mJT",
  "card_1JxX3a2eZvKYlo2CAgnJq5yN"
);

Response

    {
      "id": "card_1Jwvx22eZvKYlo2C7q732luw",
      "object": "card",
      "deleted": true
    }

You can delete cards from a customer.

If you delete a card that is currently the default source, then the most recently added source will become the new default. If you delete a card that is the last remaining source on the customer, then the default_source attribute will become null.

For recipients: if you delete the default card, then the most recently added card will become the new default. If you delete the last remaining card on a recipient, then the default_card attribute will become null.

Note that for cards belonging to customers, you might want to prevent customers on paid subscriptions from deleting all cards on file, so that there is at least one default card for the next invoice payment attempt.

Parameters

Returns

Returns the deleted Card object.

List all cards

GET    /v1/customers/:id/sources?object=card
curl https://api.payske.com/v1/customers/cus_AJ6yA7mRH34mJT/sources \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
  -d object=card \
  -d limit=3 \
  -G
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->customers->allSources(
  'cus_AJ6yA7mRH34mJT',
  ['object' => 'card', 'limit' => 3]
);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Customer.list_sources(
  'cus_AJ6yA7mRH34mJT',
  {object: 'card', limit: 3},
)
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Customer.list_sources(
  "cus_AJ6yA7mRH34mJT",
  object="card",
  limit=3,
)
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

List<String> expandList = new ArrayList<>();
expandList.add("sources");

Map<String, Object> retrieveParams = new HashMap<>();
retrieveParams.put("expand", expandList);

Customer customer =
  Customer.retrieve(
    "cus_AJ6yA7mRH34mJT",
    retrieveParams,
    null
  );

Map<String, Object> params = new HashMap<>();
params.put("object", "card");
params.put("limit", 3);

PaymentSourceCollection cards =
  customer.getSources().list(params);
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const cards = await payske.customers.listSources(
  'cus_AJ6yA7mRH34mJT',
  {object: 'card', limit: 3}
);
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

params := &payske.CardListParams{
  Customer: payske.String("cus_AJ6yA7mRH34mJT"),
}
params.Filters.AddFilter("limit", "", "3")
i := card.List(params)
for i.Next() {
  c := i.Card()
}
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var service = new CardService();
var options = new CardListOptions
{
  Limit = 3,
};
var cards = service.List("cus_AJ6yA7mRH34mJT", options);

Response

    {
      "object": "list",
      "url": "/v1/customers/cus_AJ6yA7mRH34mJT/sources",
      "has_more": false,
      "data": [
        {
          "id": "card_1Jwvx22eZvKYlo2C7q732luw",
          "object": "card",
          "address_city": null,
          "address_country": null,
          "address_line1": null,
          "address_line1_check": null,
          "address_line2": null,
          "address_state": null,
          "address_zip": null,
          "address_zip_check": null,
          "brand": "Visa",
          "country": "US",
          "customer": "cus_AJ6yA7mRH34mJT",
          "cvc_check": "pass",
          "dynamic_last4": null,
          "exp_month": 8,
          "exp_year": 2022,
          "fingerprint": "Xt5EWLLDS7FJjR1c",
          "funding": "credit",
          "last4": "4242",
          "metadata": {},
          "name": null,
          "tokenization_method": null
        },
        {...},
        {...}
      ]
    }

You can see a list of the cards belonging to a customer. Note that the 10 most recent sources are always available on the Customer object. If you need more than those 10, you can use this API method and the limit and starting_after parameters to page through additional cards.

ParametersCollapse all

Returns

Returns a list of the cards stored on the customer.

Bank Accounts

These bank accounts are payment methods on Customer objects.

On the other hand External Accounts are transfer destinations on Account objects for Custom accounts. They can be bank accounts or debit cards as well, and are documented in the links above.

Related guide: Bank Debits and Transfers.

Was this section helpful?YesNo

The bank account object

The bank account object

    {
      "id": "ba_1Jw9mB2eZvKYlo2Crly03Iir",
      "object": "bank_account",
      "account_holder_name": "Test",
      "account_holder_type": "individual",
      "account_type": null,
      "bank_name": "PAYSKE TEST BANK",
      "country": "US",
      "currency": "usd",
      "customer": null,
      "fingerprint": "OHMI60oSIPAmj91c",
      "last4": "9991",
      "metadata": {},
      "routing_number": "110000000",
      "status": "new"
    }

Attributes

More attributesCollapse all

Create a bank account

POST    /v1/customers/:id/sources
curl https://api.payske.com/v1/customers/cus_AJ6yA7mRH34mJT/sources \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
  -d source=btok_1JxXll2eZvKYlo2CLhqmB5Vy
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->customers->createSource(
  'cus_AJ6yA7mRH34mJT',
  ['source' => 'btok_1Jx9xv2eZvKYlo2C4JOF8wog']
);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Customer.create_source(
  'cus_AJ6yA7mRH34mJT',
  {source: 'btok_1JxAEN2eZvKYlo2C7wybqDU9'},
)
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Customer.create_source(
  "cus_AJ6yA7mRH34mJT",
  source="btok_1JxAYu2eZvKYlo2CrWCWPacg",
)
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Map<String, Object> retrieveParams =
  new HashMap<>();
List<String> expandList = new ArrayList<>();
expandList.add("sources");
retrieveParams.put("expand", expandList);
Customer customer =
  Customer.retrieve(
    "cus_AJ6yA7mRH34mJT",
    retrieveParams,
    null
  );

Map<String, Object> params = new HashMap<>();
params.put(
  "source",
  "btok_1JxAnS2eZvKYlo2CEKl2cZsq"
);

BankAccount bankAccount =
  (BankAccount) customer.getSources().create(
    params
  );
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const bankAccount = await payske.customers.createSource(
  'cus_AJ6yA7mRH34mJT',
  {source: 'btok_1JxAxp2eZvKYlo2CvoWN3QYC'}
);
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

params := &payske.BankAccountParams{
  Customer: payske.String("cus_AJ6yA7mRH34mJT"),
  Token: payske.String("btok_1JxB9F2eZvKYlo2CTkTlVpHt"),
}
ba, err := bankaccount.New(params)
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var options = new BankAccountCreateOptions
{
  Source = "btok_1JxX3c2eZvKYlo2COQEIreia",
};
var service = new BankAccountService();
service.Create("cus_AJ6yA7mRH34mJT", options);

Response

    {
      "id": "ba_1Jw9mB2eZvKYlo2Crly03Iir",
      "object": "bank_account",
      "account_holder_name": "Test",
      "account_holder_type": "individual",
      "account_type": null,
      "bank_name": "PAYSKE TEST BANK",
      "country": "US",
      "currency": "usd",
      "customer": "cus_AJ6yA7mRH34mJT",
      "fingerprint": "OHMI60oSIPAmj91c",
      "last4": "9991",
      "metadata": {},
      "routing_number": "110000000",
      "status": "new"
    }

When you create a new bank account, you must specify a Customer object on which to create it.

Parameters

Returns

Returns the bank account object.

Retrieve a bank account

GET    /v1/customers/:id/sources/:id
curl https://api.payske.com/v1/customers/cus_AJ6yA7mRH34mJT/sources/ba_1JxV1W2eZvKYlo2CZurl1Ki6 \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc:
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->customers->retrieveSource(
  'cus_AJ6yA7mRH34mJT',
  'ba_1Jx9a92eZvKYlo2CqCR7gerB',
  []
);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Customer.retrieve_source(
  'cus_AJ6yA7mRH34mJT',
  'ba_1Jx9a92eZvKYlo2CqCR7gerB',
)
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Customer.retrieve_source(
  "cus_AJ6yA7mRH34mJT",
  "ba_1Jx9a92eZvKYlo2CqCR7gerB",
)
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Map<String, Object> retrieveParams =
  new HashMap<>();
List<String> expandList = new ArrayList<>();
expandList.add("sources");
retrieveParams.put("expand", expandList);
Customer customer =
  Customer.retrieve(
    "cus_AJ6yA7mRH34mJT",
    retrieveParams,
    null
  );

BankAccount bankAccount =
  (BankAccount) customer.getSources().retrieve(
    "ba_1Jx9a92eZvKYlo2CqCR7gerB"
  );
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const bankAccount = await payske.customers.retrieveSource(
  'cus_AJ6yA7mRH34mJT',
  'ba_1Jx9a92eZvKYlo2CqCR7gerB'
);
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

params := &payske.BankAccountParams{
  Customer: payske.String("cus_AJ6yA7mRH34mJT"),
}
ba, _ := bankaccount.Get(
  "ba_1JxB8R2eZvKYlo2CqSBL9hKS",
  params,
)
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var service = new BankAccountService();
service.Get(
  "cus_AJ6yA7mRH34mJT",
  "ba_1JxV1W2eZvKYlo2CZurl1Ki6"
);

Response

    {
      "id": "ba_1Jw9mB2eZvKYlo2Crly03Iir",
      "object": "bank_account",
      "account_holder_name": "Test",
      "account_holder_type": "individual",
      "account_type": null,
      "bank_name": "PAYSKE TEST BANK",
      "country": "US",
      "currency": "usd",
      "customer": "cus_AJ6yA7mRH34mJT",
      "fingerprint": "OHMI60oSIPAmj91c",
      "last4": "9991",
      "metadata": {},
      "routing_number": "110000000",
      "status": "new"
    }

By default, you can see the 10 most recent sources stored on a Customer directly on the object, but you can also retrieve details about a specific bank account stored on the Payske account.

Parameters

Returns

Returns the bank account object.

Update a bank account

POST    /v1/customers/:id/sources/:id
curl https://api.payske.com/v1/customers/cus_AJ6yA7mRH34mJT/sources/ba_1JxV1W2eZvKYlo2CZurl1Ki6 \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
  -d "metadata[order_id]"=6735
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->customers->updateSource(
  'cus_AJ6yA7mRH34mJT',
  'ba_1Jx9a92eZvKYlo2CqCR7gerB',
  ['metadata' => ['order_id' => '6735']]
);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Customer.update_source(
  'cus_AJ6yA7mRH34mJT',
  'ba_1Jx9a92eZvKYlo2CqCR7gerB',
  {metadata: {order_id: '6735'}},
)
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Customer.modify_source(
  "cus_AJ6yA7mRH34mJT",
  "ba_1Jx9a92eZvKYlo2CqCR7gerB",
  metadata={"order_id": "6735"},
)
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Map<String, Object> retrieveParams =
  new HashMap<>();
List<String> expandList = new ArrayList<>();
expandList.add("sources");
retrieveParams.put("expand", expandList);
Customer customer =
  Customer.retrieve(
    "cus_AJ6yA7mRH34mJT",
    retrieveParams,
    null
  );

BankAccount bankAccount =
  customer.getSources().retrieve(
    "ba_1Jx9a92eZvKYlo2CqCR7gerB"
  );

Map<String, Object> metadata = new HashMap<>();
metadata.put("order_id", "6735");
Map<String, Object> params = new HashMap<>();
params.put("metadata", metadata);

BankAccount updatedBankAccount =
  (BankAccount) bankAccount.update(params);
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const bankAccount = await payske.customers.updateSource(
  'cus_AJ6yA7mRH34mJT',
  'ba_1Jx9a92eZvKYlo2CqCR7gerB',
  {metadata: {order_id: '6735'}}
);
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

params := &payske.BankAccountParams{
  Customer: payske.String("cus_AJ6yA7mRH34mJT"),
}
params.AddMetadata("order_id", "6735")
ba, _ := bankaccount.Update(
  "ba_1JxB8R2eZvKYlo2CqSBL9hKS",
  params,
)
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var options = new BankAccountUpdateOptions
{
  Metadata = new Dictionary<string, string>
  {
    { "order_id", "6735" },
  },
};
var service = new BankAccountService();
service.Update(
  "cus_AJ6yA7mRH34mJT",
  "ba_1JxV1W2eZvKYlo2CZurl1Ki6",
  options
);

Response

    {
      "id": "ba_1Jw9mB2eZvKYlo2Crly03Iir",
      "object": "bank_account",
      "account_holder_name": "Test",
      "account_holder_type": "individual",
      "account_type": null,
      "bank_name": "PAYSKE TEST BANK",
      "country": "US",
      "currency": "usd",
      "customer": "cus_AJ6yA7mRH34mJT",
      "fingerprint": "OHMI60oSIPAmj91c",
      "last4": "9991",
      "metadata": {
        "order_id": "6735"
      },
      "routing_number": "110000000",
      "status": "new"
    }

Updates the account_holder_name, account_holder_type, and metadata of a bank account belonging to a customer. Other bank account details are not editable, by design.

Parameters

Returns

Returns the bank account object.

List all bank accounts

GET    /v1/customers/:id/sources?object=bank_account
curl https://api.payske.com/v1/customers/cus_AJ6yA7mRH34mJT/sources \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
  -d object=bank_account \
  -d limit=3 \
  -G
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->customers->allSources(
  'cus_AJ6yA7mRH34mJT',
  ['object' => 'bank_account', 'limit' => 3]
);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Customer.list_sources(
  'cus_AJ6yA7mRH34mJT',
  {object: 'bank_account', limit: 3},
)
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Customer.list_sources(
  "cus_AJ6yA7mRH34mJT",
  object="bank_account",
  limit=3,
)
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Map<String, Object> retrieveParams =
  new HashMap<>();
List<String> expandList = new ArrayList<>();
expandList.add("sources");
retrieveParams.put("expand", expandList);
Customer customer =
  Customer.retrieve(
    "cus_AJ6yA7mRH34mJT",
    retrieveParams,
    null
  );

Map<String, Object> params = new HashMap<>();
params.put("object", "bank_account");
params.put("limit", 3);

PaymentSourceCollection bankAccounts =
  customer.getSources().list(params);
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const bankAccounts = await payske.customers.listSources(
  'cus_AJ6yA7mRH34mJT',
  {object: 'bank_account', limit: 3}
);
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

params := &payske.BankAccountListParams{
  Customer: payske.String("cus_AJ6yA7mRH34mJT"),
}
params.Filters.AddFilter("limit", "", "3")
i := bankaccount.List(params)
for i.Next() {
  ba := i.BankAccount()
}
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var options = new BankAccountListOptions
{
  Limit = 3,
};

var service = new BankAccountService();
var bankAccounts = service.List("cus_AJ6yA7mRH34mJT", options);

Response

    {
      "object": "list",
      "url": "/v1/customers/cus_AJ6yA7mRH34mJT/sources",
      "has_more": false,
      "data": [
        {
          "id": "ba_1Jw9mB2eZvKYlo2Crly03Iir",
          "object": "bank_account",
          "account_holder_name": "Test",
          "account_holder_type": "individual",
          "account_type": null,
          "bank_name": "PAYSKE TEST BANK",
          "country": "US",
          "currency": "usd",
          "customer": "cus_AJ6yA7mRH34mJT",
          "fingerprint": "OHMI60oSIPAmj91c",
          "last4": "9991",
          "metadata": {},
          "routing_number": "110000000",
          "status": "new"
        },
        {...},
        {...}
      ]
    }

You can see a list of the bank accounts belonging to a Customer. Note that the 10 most recent sources are always available by default on the Customer. If you need more than those 10, you can use this API method and the limit and starting_after parameters to page through additional bank accounts.

Parameters

Returns

Returns a list of the bank accounts stored on the customer.

Sessions

A Checkout Session represents your customer's session as they pay for one-time purchases or subscriptions through Checkout or Payment Links. We recommend creating a new Session each time your customer attempts to pay.

Once payment is successful, the Checkout Session will contain a reference to the Customer, and either the successful PaymentIntent or an active Subscription.

You can create a Checkout Session on your server and pass its ID to the client to begin Checkout.

Related guide: Checkout Server Quickstart.

Was this section helpful? Yes No

The Session object

The Session object

    {
      "id": "cs_test_9JAHiKx2kgFg2Snc5Gnop1iNIgawrLGBlo3XBXfWfEicPzx9oXBcytyz",
      "object": "checkout.session",
      "after_expiration": null,
      "allow_promotion_codes": null,
      "amount_subtotal": null,
      "amount_total": null,
      "automatic_tax": {
        "enabled": false,
        "status": null
      },
      "billing_address_collection": null,
      "cancel_url": "https://example.com/cancel",
      "client_reference_id": null,
      "consent": null,
      "consent_collection": null,
      "currency": null,
      "customer": null,
      "customer_details": null,
      "customer_email": null,
      "expires_at": 1637227692,
      "livemode": false,
      "locale": null,
      "metadata": {},
      "mode": "payment",
      "payment_intent": "pi_1DpdOt2eZvKYlo2CFOGrwsj4",
      "payment_method_options": {},
      "payment_method_types": [
        "card"
      ],
      "payment_status": "unpaid",
      "phone_number_collection": {
        "enabled": false
      },
      "recovered_from": null,
      "setup_intent": null,
      "shipping": null,
      "shipping_address_collection": null,
      "shipping_options": [],
      "shipping_rate": null,
      "status": "expired",
      "submit_type": null,
      "subscription": null,
      "success_url": "https://example.com/success",
      "total_details": null,
      "url": null
    }

Attributes

More attributesCollapse all

Create a Session

POST    /v1/checkout/sessions
curl https://api.payske.com/v1/checkout/sessions \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
  -d success_url="https://example.com/success" \
  -d cancel_url="https://example.com/cancel" \
  -d "line_items[0][price]"=price_H5ggYwtDq4fbrJ \
  -d "line_items[0][quantity]"=2 \
  -d mode=payment
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->checkout->sessions->create([
  'success_url' => 'https://example.com/success',
  'cancel_url' => 'https://example.com/cancel',
  'line_items' => [
    [
      'price' => 'price_H5ggYwtDq4fbrJ',
      'quantity' => 2,
    ],
  ],
  'mode' => 'payment',
]);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Checkout::Session.create({
  success_url: 'https://example.com/success',
  cancel_url: 'https://example.com/cancel',
  line_items: [
    {price: 'price_H5ggYwtDq4fbrJ', quantity: 2},
  ],
  mode: 'payment',
})
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.checkout.Session.create(
  success_url="https://example.com/success",
  cancel_url="https://example.com/cancel",
  line_items=[
    {
      "price": "price_H5ggYwtDq4fbrJ",
      "quantity": 2,
    },
  ],
  mode="payment",
)
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

List<Object> lineItems = new ArrayList<>();
Map<String, Object> lineItem1 = new HashMap<>();
lineItem1.put("price", "price_H5ggYwtDq4fbrJ");
lineItem1.put("quantity", 2);
lineItems.add(line_item1);
Map<String, Object> params = new HashMap<>();
params.put(
  "success_url",
  "https://example.com/success"
);
params.put(
  "cancel_url",
  "https://example.com/cancel"
);
params.put("line_items", lineItems);
params.put("mode", "payment");

Session session = Session.create(params);
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const session = await payske.checkout.sessions.create({
  success_url: 'https://example.com/success',
  cancel_url: 'https://example.com/cancel',
  line_items: [
    {price: 'price_H5ggYwtDq4fbrJ', quantity: 2},
  ],
  mode: 'payment',
});
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

params := &payske.CheckoutSessionParams{
  SuccessURL: payske.String("https://example.com/success"),
  CancelURL: payske.String("https://example.com/cancel"),
  LineItems: []*payske.CheckoutSessionLineItemParams{
    &payske.CheckoutSessionLineItemParams{
      Price: payske.String("price_H5ggYwtDq4fbrJ"),
      Quantity: payske.Int64(2),
    },
  },
  Mode: payske.String(string(payske.CheckoutSessionModePayment)),
}
s, _ := session.New(params)
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var options = new SessionCreateOptions
{
  SuccessUrl = "https://example.com/success",
  CancelUrl = "https://example.com/cancel",
  LineItems = new List<SessionLineItemOptions>
  {
    new SessionLineItemOptions
    {
      Price = "price_H5ggYwtDq4fbrJ",
      Quantity = 2,
    },
  },
  Mode = "payment",
};
var service = new SessionService();
service.Create(options);

Response

    {
      "id": "cs_test_9JAHiKx2kgFg2Snc5Gnop1iNIgawrLGBlo3XBXfWfEicPzx9oXBcytyz",
      "object": "checkout.session",
      "after_expiration": null,
      "allow_promotion_codes": null,
      "amount_subtotal": null,
      "amount_total": null,
      "automatic_tax": {
        "enabled": false,
        "status": null
      },
      "billing_address_collection": null,
      "cancel_url": "https://example.com/cancel",
      "client_reference_id": null,
      "consent": null,
      "consent_collection": null,
      "currency": null,
      "customer": null,
      "customer_details": null,
      "customer_email": null,
      "expires_at": 1637227692,
      "livemode": false,
      "locale": null,
      "metadata": {},
      "mode": "payment",
      "payment_intent": "pi_1DpdOt2eZvKYlo2CFOGrwsj4",
      "payment_method_options": {},
      "payment_method_types": [
        "card"
      ],
      "payment_status": "unpaid",
      "phone_number_collection": {
        "enabled": false
      },
      "recovered_from": null,
      "setup_intent": null,
      "shipping": null,
      "shipping_address_collection": null,
      "shipping_options": [],
      "shipping_rate": null,
      "status": "expired",
      "submit_type": null,
      "subscription": null,
      "success_url": "https://example.com/success",
      "total_details": null,
      "url": "https://checkout.payske.com/pay/..."
    }

Creates a Session object.

Parameters

More parametersCollapse all
* ### [](#create_checkout_session-subscription_data-trial_end)subscription_data.trial_end optional
    
    Unix timestamp representing the end of the trial period the customer will get before being charged for the first time. Has to be at least 48 hours in the future.
    
* ### [](#create_checkout_session-subscription_data-trial_period_days)subscription_data.trial_period_days optional
    
    Integer representing the number of trial period days before the customer is charged for the first time. Has to be at least 1.
    

Returns

Returns a Session object.

Retrieve a Session

GET    /v1/checkout/sessions/:id
curl https://api.payske.com/v1/checkout/sessions/cs_test_9JAHiKx2kgFg2Snc5Gnop1iNIgawrLGBlo3XBXfWfEicPzx9oXBcytyz \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc:
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->checkout->sessions->retrieve(
  'cs_test_HtdVzy0CBBG68eeDutxDrA8FoU25FtztpVXKvzOkP5fCngfIaz2bYzVN',
  []
);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Checkout::Session.retrieve(
  'cs_test_KxdpuZ9PZJSS1KZjY89L0oxsCA1gf8COrUZXpLnul35pSVjsCFAQQZdf',
)
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.checkout.Session.retrieve(
  "cs_test_NXhuXNGmYxwLMHvMYNxceHm5Awd23bcqQkT0rwm5O4w6GgD3MiH6Er6W",
)
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Session session =
  Session.retrieve(
    "cs_test_L60TbUHmymAA4ob0L8k7YcHWDmccKbxIjik7DVUit1CRSw5msT6fKgju"
  );
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const session = await payske.checkout.sessions.retrieve(
  'cs_test_gg0MZ8zY1fhRdYxMdEheLX0IMMnPQ54PKuhxpovGj4V6mKmWFaPOas6g'
);
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

s, _ := session.Get(
  "cs_test_Z1DSZumlvoAbBgAuRXGNQ3Yk3RQ4E81FRYKG5itV4XIIoXn3wk97p9Y7",
  nil,
)
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var service = new SessionService();
service.Get(
  "cs_test_TOI0autYW2TkIaPQZsXnEB2Qj2iijA6qWL3NqGLcU1PDvmkYQvNc9r8Z"
);

Response

    {
      "id": "cs_test_9JAHiKx2kgFg2Snc5Gnop1iNIgawrLGBlo3XBXfWfEicPzx9oXBcytyz",
      "object": "checkout.session",
      "after_expiration": null,
      "allow_promotion_codes": null,
      "amount_subtotal": null,
      "amount_total": null,
      "automatic_tax": {
        "enabled": false,
        "status": null
      },
      "billing_address_collection": null,
      "cancel_url": "https://example.com/cancel",
      "client_reference_id": null,
      "consent": null,
      "consent_collection": null,
      "currency": null,
      "customer": null,
      "customer_details": null,
      "customer_email": null,
      "expires_at": 1637227692,
      "livemode": false,
      "locale": null,
      "metadata": {},
      "mode": "payment",
      "payment_intent": "pi_1DpdOt2eZvKYlo2CFOGrwsj4",
      "payment_method_options": {},
      "payment_method_types": [
        "card"
      ],
      "payment_status": "unpaid",
      "phone_number_collection": {
        "enabled": false
      },
      "recovered_from": null,
      "setup_intent": null,
      "shipping": null,
      "shipping_address_collection": null,
      "shipping_options": [],
      "shipping_rate": null,
      "status": "expired",
      "submit_type": null,
      "subscription": null,
      "success_url": "https://example.com/success",
      "total_details": null,
      "url": null
    }

Retrieves a Session object.

Parameters

Returns

Returns a Session object.

List all Checkout Sessions

GET    /v1/checkout/sessions
curl https://api.payske.com/v1/checkout/sessions \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
  -d limit=3 \
  -G
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->checkout->sessions->all(['limit' => 3]);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Checkout::Session.list({limit: 3})
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.checkout.Session.list(limit=3)
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Map<String, Object> params = new HashMap<>();
params.put("limit", 3);

SessionCollection sessions = Session.list(params);
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const sessions = await payske.checkout.sessions.list({
  limit: 3,
});
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

params := &payske.CheckoutSessionListParams{}
params.Filters.AddFilter("limit", "", "3")
i := session.List(params)
for i.Next() {
  s := i.CheckoutSession()
}
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var options = new SessionListOptions
{
  Limit = 3,
};
var service = new SessionService();
PayskeList<Session> sessions = service.List(
  options
);

Response

    {
      "object": "list",
      "url": "/v1/checkout/sessions",
      "has_more": false,
      "data": [
        {
          "id": "cs_test_9JAHiKx2kgFg2Snc5Gnop1iNIgawrLGBlo3XBXfWfEicPzx9oXBcytyz",
          "object": "checkout.session",
          "after_expiration": null,
          "allow_promotion_codes": null,
          "amount_subtotal": null,
          "amount_total": null,
          "automatic_tax": {
            "enabled": false,
            "status": null
          },
          "billing_address_collection": null,
          "cancel_url": "https://example.com/cancel",
          "client_reference_id": null,
          "consent": null,
          "consent_collection": null,
          "currency": null,
          "customer": null,
          "customer_details": null,
          "customer_email": null,
          "expires_at": 1637227692,
          "livemode": false,
          "locale": null,
          "metadata": {},
          "mode": "payment",
          "payment_intent": "pi_1DpdOt2eZvKYlo2CFOGrwsj4",
          "payment_method_options": {},
          "payment_method_types": [
            "card"
          ],
          "payment_status": "unpaid",
          "phone_number_collection": {
            "enabled": false
          },
          "recovered_from": null,
          "setup_intent": null,
          "shipping": null,
          "shipping_address_collection": null,
          "shipping_options": [],
          "shipping_rate": null,
          "status": "expired",
          "submit_type": null,
          "subscription": null,
          "success_url": "https://example.com/success",
          "total_details": null,
          "url": null
        },
        {...},
        {...}
      ]
    }

Returns a list of Checkout Sessions.

Parameters

More parametersCollapse all

Returns

A dictionary with a data property that contains an array of up to limit Checkout Sessions, starting after Checkout Session starting_after. Each entry in the array is a separate Checkout Session object. If no more Checkout Sessions are available, the resulting array will be empty.

Retrieve a Session's line items

Retrieve a Checkout Session's line items

GET    /v1/checkout/sessions/:id/line_items
curl https://api.payske.com/v1/checkout/sessions/cs_test_9JAHiKx2kgFg2Snc5Gnop1iNIgawrLGBlo3XBXfWfEicPzx9oXBcytyz/line_items?limit=5 \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc:
$payske = new \Payske\PayskeClient("sk_test_4eC39HqLyjWDarjtT1zdp7dc");
$line_items = $payske->checkout->sessions->allLineItems('cs_test_HtdVzy0CBBG68eeDutxDrA8FoU25FtztpVXKvzOkP5fCngfIaz2bYzVN', ['limit' => 5]);
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

line_items = Payske::Checkout::Session.list_line_items('cs_test_bQgFMROfjn5l0Jc2wSm9V5HQ1odVn7YkOGgRfdTHt4JoUKOAlinq9vws', {limit: 5})
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

line_items = payske.checkout.Session.list_line_items('cs_test_NXhuXNGmYxwLMHvMYNxceHm5Awd23bcqQkT0rwm5O4w6GgD3MiH6Er6W', limit=5)
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Session session = Session.retrieve("cs_test_L60TbUHmymAA4ob0L8k7YcHWDmccKbxIjik7DVUit1CRSw5msT6fKgju");
Map<String, Object> params = new HashMap<>();
params.put("limit", 5);
LineItemCollection lineItems = session.listLineItems(params);
const Payske = require('payske');
const payske = Payske('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
payske.checkout.sessions.listLineItems(
  'cs_test_gg0MZ8zY1fhRdYxMdEheLX0IMMnPQ54PKuhxpovGj4V6mKmWFaPOas6g',
  { limit: 5 },
  function(err, lineItems) {
    // asynchronously called
  }
);
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

params := &payske.CheckoutSessionListLineItemParams{
  ID: payske.String("cs_test_Z1DSZumlvoAbBgAuRXGNQ3Yk3RQ4E81FRYKG5itV4XIIoXn3wk97p9Y7"),
}
params.Filters.AddFilter("limit", "", "5")
i := session.ListLineItems(params)
for i.Next() {
  li := i.LineItem()
}
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var options = new SessionListLineItemsOptions
{
  Limit = 5,
};
var service = new SessionService();
PayskeList<LineItem> = service.ListLineItems("cs_test_TOI0autYW2TkIaPQZsXnEB2Qj2iijA6qWL3NqGLcU1PDvmkYQvNc9r8Z", options);

Response

    {
      "object": "list",
      "url": "/v1/checkout/sessions/cs_test_9JAHiKx2kgFg2Snc5Gnop1iNIgawrLGBlo3XBXfWfEicPzx9oXBcytyz/line_items",
      "has_more": false,
      "data": [
        {
          "id": "li_1Jx6ue2eZvKYlo2CPmEdYb2N",
          "object": "item",
          "amount_subtotal": 0,
          "amount_total": 0,
          "currency": "usd",
          "description": "Tin of Cookies",
          "price": {
            "id": "price_1Jx64D2eZvKYlo2C5cws8LZD",
            "object": "price",
            "active": true,
            "billing_scheme": "per_unit",
            "created": 1637224441,
            "currency": "usd",
            "livemode": false,
            "lookup_key": null,
            "metadata": {},
            "nickname": null,
            "product": "prod_KcKjmOkvbeSdpk",
            "recurring": null,
            "tax_behavior": "unspecified",
            "tiers_mode": null,
            "transform_quantity": null,
            "type": "one_time",
            "unit_amount": 299,
            "unit_amount_decimal": "299"
          },
          "quantity": 1
        },
        {...},
        {...}
      ]
    }

When retrieving a Checkout Session, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.

Parameters

Returns

A dictionary with a data property that contains an array of up to limit Checkout Session line items, starting after Line Item starting_after. Each entry in the array is a separate Line Item object. If no more line items are available, the resulting array will be empty.

Events

Events are our way of letting you know when something interesting happens in your account. When an interesting event occurs, we create a new Event object. For example, when a charge succeeds, we create a charge.succeeded event; and when an invoice payment attempt fails, we create an invoice.payment_failed event. Note that many API requests may cause multiple events to be created. For example, if you create a new subscription for a customer, you will receive both a customer.subscription.created event and a charge.succeeded event.

Events occur when the state of another API resource changes. The state of that resource at the time of the change is embedded in the event's data field. For example, a charge.succeeded event will contain a charge, and an invoice.payment_failed event will contain an invoice.

As with other API resources, you can use endpoints to retrieve an individual event or a list of events from the API. We also have a separate webhooks system for sending the Event objects directly to an endpoint on your server. Webhooks are managed in your account settings, and our Using Webhooks guide will help you get set up.

When using Connect, you can also receive notifications of events that occur in connected accounts. For these events, there will be an additional account attribute in the received Event object.

NOTE: Right now, access to events through the Retrieve Event API is guaranteed only for 30 days.

Was this section helpful? Yes No

The event object

The event object

    {
      "id": "evt_1CiPtv2eZvKYlo2CcUZsDcO6",
      "object": "event",
      "api_version": "2018-05-21",
      "created": 1530291411,
      "data": {
        "object": {
          "id": "src_1CiPsl2eZvKYlo2CVVyt3LKy",
          "object": "source",
          "amount": 1000,
          "client_secret": "src_client_secret_D8hHhtdrGWQyK8bLM4M3uFQ6",
          "created": 1530291339,
          "currency": "eur",
          "flow": "redirect",
          "livemode": false,
          "metadata": {},
          "owner": {
            "address": null,
            "email": null,
            "name": null,
            "phone": null,
            "verified_address": null,
            "verified_email": null,
            "verified_name": "Jenny Rosen",
            "verified_phone": null
          },
          "redirect": {
            "failure_reason": null,
            "return_url": "https://minkpolice.com",
            "status": "succeeded",
            "url": "https://hooks.payske.com/redirect/authenticate/src_1CiPsl2eZvKYlo2CVVyt3LKy?client_secret=src_client_secret_D8hHhtdrGWQyK8bLM4M3uFQ6"
          },
          "sofort": {
            "country": "DE",
            "bank_code": "DEUT",
            "bank_name": "Deutsche Bank",
            "bic": "DEUTDE2H",
            "iban_last4": "3000",
            "statement_descriptor": null,
            "preferred_language": null
          },
          "statement_descriptor": null,
          "status": "chargeable",
          "type": "sofort",
          "usage": "single_use"
        }
      },
      "livemode": false,
      "pending_webhooks": 0,
      "request": {
        "id": null,
        "idempotency_key": null
      },
      "type": "source.chargeable"
    }
Attributes
More attributesCollapse all

Retrieve an event

GET    /v1/events/:id
curl https://api.payske.com/v1/events/evt_1CiPtv2eZvKYlo2CcUZsDcO6 \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc:
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Event.retrieve(
  'evt_1CiPtv2eZvKYlo2CcUZsDcO6',
)
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Event.retrieve(
  "evt_1CiPtv2eZvKYlo2CcUZsDcO6",
)
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->events->retrieve(
  'evt_1CiPtv2eZvKYlo2CcUZsDcO6',
  []
);
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Event event =
  Event.retrieve("evt_1CiPtv2eZvKYlo2CcUZsDcO6");
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const event = await payske.events.retrieve(
  'evt_1CiPtv2eZvKYlo2CcUZsDcO6'
);
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

e, _ := event.Get(
  "evt_1CiPtv2eZvKYlo2CcUZsDcO6",
  nil,
)
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var service = new EventService();
service.Get("evt_1CiPtv2eZvKYlo2CcUZsDcO6");

Response

    {
      "id": "evt_1CiPtv2eZvKYlo2CcUZsDcO6",
      "object": "event",
      "api_version": "2018-05-21",
      "created": 1530291411,
      "data": {
        "object": {
          "id": "src_1CiPsl2eZvKYlo2CVVyt3LKy",
          "object": "source",
          "amount": 1000,
          "client_secret": "src_client_secret_D8hHhtdrGWQyK8bLM4M3uFQ6",
          "created": 1530291339,
          "currency": "eur",
          "flow": "redirect",
          "livemode": false,
          "metadata": {},
          "owner": {
            "address": null,
            "email": null,
            "name": null,
            "phone": null,
            "verified_address": null,
            "verified_email": null,
            "verified_name": "Jenny Rosen",
            "verified_phone": null
          },
          "redirect": {
            "failure_reason": null,
            "return_url": "https://minkpolice.com",
            "status": "succeeded",
            "url": "https://hooks.payske.com/redirect/authenticate/src_1CiPsl2eZvKYlo2CVVyt3LKy?client_secret=src_client_secret_D8hHhtdrGWQyK8bLM4M3uFQ6"
          },
          "sofort": {
            "country": "DE",
            "bank_code": "DEUT",
            "bank_name": "Deutsche Bank",
            "bic": "DEUTDE2H",
            "iban_last4": "3000",
            "statement_descriptor": null,
            "preferred_language": null
          },
          "statement_descriptor": null,
          "status": "chargeable",
          "type": "sofort",
          "usage": "single_use"
        }
      },
      "livemode": false,
      "pending_webhooks": 0,
      "request": {
        "id": null,
        "idempotency_key": null
      },
      "type": "source.chargeable"
    }

Retrieves the details of an event. Supply the unique identifier of the event, which you might have received in a webhook.

Parameters

Returns

Returns an event object if a valid identifier was provided. All events share a common structure, detailed to the right. The only property that will differ is the data property.

In each case, the data dictionary will have an attribute called object and its value will be the same as retrieving the same object directly from the API. For example, a customer.created event will have the same information as retrieving the relevant customer would.

In cases where the attributes of an object have changed, data will also contain a dictionary containing the changes.

List all events

GET    /v1/events
curl https://api.payske.com/v1/events \
  -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
  -d limit=3 \
  -G
require 'payske'
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

Payske::Event.list({limit: 3})
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

payske.Event.list(limit=3)
$payske = new \Payske\PayskeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$payske->events->all(['limit' => 3]);
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

Map<String, Object> params = new HashMap<>();
params.put("limit", 3);

EventCollection events = Event.list(params);
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

const events = await payske.events.list({
  limit: 3,
});
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

params := &payske.EventListParams{}
params.Filters.AddFilter("limit", "", "3")
i := event.List(params)
for i.Next() {
  e := i.Event()
}
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

var options = new EventListOptions { Limit = 3 };
var service = new EventService();
PayskeList<Event> events = service.List(options);

Response

    {
      "object": "list",
      "url": "/v1/events",
      "has_more": false,
      "data": [
        {
          "id": "evt_1CiPtv2eZvKYlo2CcUZsDcO6",
          "object": "event",
          "api_version": "2018-05-21",
          "created": 1530291411,
          "data": {
            "object": {
              "id": "src_1CiPsl2eZvKYlo2CVVyt3LKy",
              "object": "source",
              "amount": 1000,
              "client_secret": "src_client_secret_D8hHhtdrGWQyK8bLM4M3uFQ6",
              "created": 1530291339,
              "currency": "eur",
              "flow": "redirect",
              "livemode": false,
              "metadata": {},
              "owner": {
                "address": null,
                "email": null,
                "name": null,
                "phone": null,
                "verified_address": null,
                "verified_email": null,
                "verified_name": "Jenny Rosen",
                "verified_phone": null
              },
              "redirect": {
                "failure_reason": null,
                "return_url": "https://minkpolice.com",
                "status": "succeeded",
                "url": "https://hooks.payske.com/redirect/authenticate/src_1CiPsl2eZvKYlo2CVVyt3LKy?client_secret=src_client_secret_D8hHhtdrGWQyK8bLM4M3uFQ6"
              },
              "sofort": {
                "country": "DE",
                "bank_code": "DEUT",
                "bank_name": "Deutsche Bank",
                "bic": "DEUTDE2H",
                "iban_last4": "3000",
                "statement_descriptor": null,
                "preferred_language": null
              },
              "statement_descriptor": null,
              "status": "chargeable",
              "type": "sofort",
              "usage": "single_use"
            }
          },
          "livemode": false,
          "pending_webhooks": 0,
          "request": {
            "id": null,
            "idempotency_key": null
          },
          "type": "source.chargeable"
        },
        {...},
        {...}
      ]
    }

List events, going back up to 30 days. Each event data is rendered according to Payske API version at its creation time, specified in event object api_version attribute (not according to your current Payske API version or Payske-Version header).

Parameters
More parametersCollapse all

Returns

A dictionary with a data property that contains an array of up to limit events, starting after event starting_after. Each entry in the array is a separate event object. If no more events are available, the resulting array will be empty. This request should never return an error.

Types of events

This is a list of all the types of events we currently send. We may add more at any time, so in developing and maintaining your code, you should not assume that only these types exist.

You'll notice that these events follow a pattern: resource.event. Our goal is to design a consistent system that makes things easier to anticipate and code against. NOTE: Events that occur on subresources like customer.subscription do not trigger the parent's update event.

Events marked as selection required are only created when a webhook has been configured to listen for that type of event specifically. A webhook set to listen to all events will not receive an event requiring explicit selection.

Was this section helpful?YesNo

Event