Skip to content

Payments

Payments

The payment object is structured as follows:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{
  "id": "paym_KIVaaHi7G8QAYMQpQOYBrUQE",
  "amount": 100,
  "currency": "eur",
  "description": "Test Payment Company",
  "order_id": null,
  "unique_id": null,
  "methods_allowed": ["card", "sepa"],
  "method": "card",
  "card": {
    "brand": "mastercard",
    "country": "US",
    "exp_month": 2,
    "exp_year": 2023,
    "id": "card_xognFbZs935LMKJYeHyCAYUd",
    "last4": "4444",
    "name": null,
    "zip_code": null
  },
  "status": "to_capture",
  "capture": true,
  "created": 1538564253,
  "customer": "cust_9Cle7TXKkjhwqcWx4Kl5cQYk",
  "response": "00",
  "live_mode": false
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package Stancer::Payment;

use Moo;
use Stancer::Core::Types qw(:all);

has amount => (is => 'rw', isa => Int);

has auth => (is => 'rw', isa => AnyOf[InstanceOf['Stancer::Auth'], Bool]);

has capture => (is => 'rw', isa => Bool);

has card => (is => 'rw', isa => InstanceOf['Stancer::Card']);

has created => (is => 'ro', isa => InstanceOf['DateTime']);

has currency => (is => 'rw', isa => Enum['EUR', 'GBP', 'USD']);

has customer => (is => 'rw', isa => InstanceOf['Stancer::Customer']);

has description => (is => 'rw', isa => Varchar[3, 64]);

has device => (is => 'rw', isa => InstanceOf['Stancer::Device']);

has id => (is => 'ro', isa => Char[29]);

has method => (is => 'ro', isa => Str);

has order_id => (is => 'rw', isa => Varchar[36]);

has payment_page_url => (is => 'ro', isa => HttpsUrl);

has refundable_amount => (is => 'ro', isa => Int);

has refunds => (is => 'ro', isa => ArrayRef[InstanceOf['Stancer::Refund']]);

has response => (is => 'ro', isa => Varchar[2, 4]);

has return_url => (is => 'rw', isa => HttpsUrl);

has sepa => (is => 'rw', isa => InstanceOf['Stancer::Sepa']);

has status => (is => 'ro', isa => Str);

has unique_id => (is => 'rw', isa => Varchar[36]);

1;
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
namespace Stancer;

use DateTime;

class Payment {
  protected int $amount;
  protected ?Auth $auth;
  protected boolean $capture = true;
  protected ?Card $card;
  protected ?DateTime $created;
  protected string $currency;
  protected ?Customer $customer;
  protected ?string $description;
  protected ?Device $device;
  protected ?string $id;
  protected ?string $method;
  protected ?string $orderId;
  protected ?string $uniqueId;
  protected ?string $paymentPageUrl;
  protected int $refundableAmount;
  protected ?Refund[] $refunds;
  protected ?string $response;
  protected ?string $returnUrl;
  protected ?Sepa $sepa;

  public function __construct(string $id = null) {}
}
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
from datetime import datetime
from stancer import Card, Customer, Sepa

class Payment(object):
  _ENDPOINT = 'checkout'

  @property
  def amount(self) -> int:
    pass

  @amount.setter
  def amount(self, value: int):
    pass

  @property
  def capture(self) -> bool:
    pass

  @capture.setter
  def capture(self, value: bool):
    pass

  @property
  def card(self) -> Card:
    pass

  @card.setter
  def card(self, value: Card):
    pass

  @property
  def created(self) -> datetime:
    pass

  @property
  def currency(self) -> str:
    pass

  @currency.setter
  def currency(self, value: str):
    pass

  @property
  def customer(self) -> Customer:
    pass

  @customer.setter
  def customer(self, value: Customer):
    pass

  @property
  def description(self) -> str:
    pass

  @description.setter
  def description(self, value: str):
    pass

  @property
  def id(self) -> str:
    pass

  @property
  def live_mode(self) -> bool:
    pass

  @property
  def method(self) -> str:
    pass

  @property
  def order_id(self) -> str:
    pass

  @order_id.setter
  def order_id(self, value: str):
    pass

  @property
  def response(self) -> str:
    pass

  @property
  def sepa(self) -> Sepa:
    pass

  @sepa.setter
  def sepa(self, value: Sepa):
    pass

  @property
  def status(self) -> str:
    pass

  @property
  def unique_id(self) -> str:
    pass

  def __init__(self, uid=None):
    pass

Full parameters list and description of the payment object

Parameter Description Type
id Payment's id String, fixed size = 29
amount Transaction amount (in cents) Int, min = 50
currency Processed Payment's currency Enum EUR, USD, GBP
description The payment description String, min = 3, max = 64
order_id Your reference id String, min = 1, max = 36
unique_id Your unicity key String, min = 1, max = 36
methods_allowed The list of payment methods allowed for this payment If null defaults to all methods available
method The payment method used to pay Enum card, sepa
card The card object or id If present, will perform a credit card payment
sepa The sepa object or id If present, will perform a SEPA payment
customer The customer object or id If present, will link payment to customer
refunds Array of refund object Present if the payment was refunded
status The status of the payment See Payment status codes
response The response of the bank processing See Payment response codes
auth Auth object, must be set for 3-D Secure card payments See auth description
device The device object Required if auth is defined, see device description
capture Capture immediately the payment Boolean, default True
created The Unix timestamp representing creation date of the object in local time Int
date_bank Timestamp of the delivery date of the funds traded by the bank Int
return_url An HTTPS URL to redirect back your customer after processing the payment String, max = 2048
live_mode Test or Live mode Boolean, default False

Create a payment

HTTP request

/v1/checkout/

Data parameters

Parameter Field
amount Required
currency Required
description Optional
order_id Optional
unique_id Optional
methods_allowed Optional
auth Conditional

Return parameters

The API will replicate your data in the return parameters and add the following ones:

Parameter Field
id Required
created Required
method Required
auth Conditional
status Required
response Required
card Conditional
sepa Conditional
customer Optional
device Conditional
capture Optional
live_mode Optional

When you provide the unique_id field, we validate the uniqueness of the payment before processing. If this unique_id already exists within our systems, the transaction will then be rejected with a 409 Conflict response, whom body will contains the payment id already associated with this unique_id.

Code examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
curl -X POST "https://api.stancer.com/v1/checkout/" \
  --header "Content-Type: application/json" \
  --data '{
    "description": "Test Payment Company",
    "amount": "100",
    "currency": "eur",
    "card": {
        "number": "5555555555554444",
        "cvc": "123",
        "exp_year": "2023",
        "exp_month": "02"
    },
    "customer": {
        "email": "david@coaster.net",
        "mobile": "+33684858687",
        "name": "David Coaster"
    }
}'
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  #! /bin/perl -w
  use Stancer::Card;
  use Stancer::Customer;
  use Stancer::Payment;

  my $card = Stancer::Card->new();
  my $customer = Stancer::Customer->new();
  my $payment = Stancer::Payment->new();

  $card->number('5555555555554444');
  $card->cvc('123');
  $card->exp_month('02');
  $card->exp_year('2023');

  $customer->email('david@example.net');
  $customer->mobile('+33639980102');
  $customer->name('David Coaster');

  $payment->amount(100);
  $payment->currency('eur');
  $payment->card($card);
  $payment->customer($customer);
  $payment->description('Test Payment Company');

  $payment->send();
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
  <?php
  $card = new Stancer\Card();
  $card->setNumber('5555555555554444');
  $card->setCvc('123');
  $card->setExpirationMonth('02');
  $card->setExpirationYear('2023');

  $customer = new Stancer\Customer();
  $customer->setEmail('david@example.net');
  $customer->setMobile('+33639980102');
  $customer->setName('David Coaster');

  $payment = new Stancer\Payment();
  $payment->setAmount(100);
  $payment->setCard($card);
  $payment->setCurrency('eur');
  $payment->setCustomer($customer);
  $payment->setDescription('Test Payment Company');

  $payment->send();
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
  import stancer

  card = stancer.Card()
  card.number = '5555555555554444'
  card.cvc = '123'
  card.exp_month = 2
  card.exp_year = 2023

  customer = stancer.Customer()
  customer.email = 'david@example.net'
  customer.mobile = '+33639980102'
  customer.name = 'David Coaster'

  payment = stancer.Payment()
  payment.description = 'Test Payment Company'
  payment.amount = 100
  payment.currency = 'eur'
  payment.card = card
  payment.customer = customer

  payment.send()

The above command returns a JSON structured as follows:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{
  "amount": 100,
  "auth": true,
  "capture": true,
  "card": {
    "brand": "mastercard",
    "country": "US",
    "exp_month": 2,
    "exp_year": 2023,
    "id": "card_xognFbZs935LMKJYeHyCAYUd",
    "last4": "4444",
    "name": null,
    "zip_code": null
  },
  "created": 1538564253,
  "currency": "eur",
  "customer": "cust_9Cle7TXKkjhwqcWx4Kl5cQYk",
  "description": "Test Payment Company",
  "id": "paym_KIVaaHi7G8QAYMQpQOYBrUQE",
  "live_mode": false,
  "method": "card",
  "order_id": null,
  "response": "00",
  "status": "to_capture"
}

Get payment data

HTTP request

/v1/checkout/
id_payment

Query parameters

Parameter Description
id_payment The ID of the payment to retrieve

Important

Remember — a happy payment is an authenticated payment!

Return parameters

It will return the payment object asssociated with the id_payment you provided. If the id_payment does not exist, the API will return a 404 HTTP response code.

Code examples

1
curl "https://api.stancer.com/v1/checkout/paym_SKMLflt8NBATuiUzgvTYqsw5"
1
2
3
4
#! /bin/perl -w
use Stancer::Payment;

my $payment = Stancer::Payment->new('paym_SKMLflt8NBATuiUzgvTYqsw5');
1
2
<?php
$payment = new Stancer\Payment('paym_SKMLflt8NBATuiUzgvTYqsw5');
1
2
3
import stancer

payment = stancer.Payment('paym_SKMLflt8NBATuiUzgvTYqsw5')

The above command returns JSON structured as follows:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{
  "amount": 3406,
  "card": {
    "brand": "visa",
    "country": "US",
    "exp_month": 3,
    "exp_year": 2021,
    "id": "card_jSmaDq5t5lMnz6H8tCZ0AbRG",
    "last4": "4242",
    "name": null,
    "zip_code": null
  },
  "country": "FR",
  "created": 1538492150,
  "currency": "eur",
  "description": null,
  "id": "paym_SKMLflt8NBATuiUzgvTYqsw5",
  "customer": null,
  "live_mode": false,
  "method": "card",
  "order_id": "815730837",
  "response": "00",
  "status": "to_capture"
}

Update a payment

HTTP request

/v1/checkout/
id_payment

Query parameters

Parameter Description
id_payment Payment id

Data parameters

Parameter Field
amount Optional
currency Optional
order_id Optional
description Optional
return_url Optional
customer Optional
card Optional
sepa Optional
device Optional
status Optional
auth Conditional

Return parameters

The above command returns an HTTP 200 / 204 code if correctly processed or an HTTP 404 code if the payment does not exist.

Code examples

1
2
3
4
5
curl -X PATCH "https://api.stancer.com/v1/checkout/paym_qcWx4Kl5c9Cle7TXKkjhwQYk" \
  --header "Content-Type: application/json" \
  --data '{
    "status": "capture"
}'
1
2
3
4
5
6
7
8
#! /bin/perl -w
use Stancer::Payment;

my $payment = Stancer::Payment->new('paym_SKMLflt8NBATuiUzgvTYqsw5');

$payment->amount(500);

$payment->send();
1
2
3
4
5
6
<?php
$payment = new Stancer\Payment('paym_SKMLflt8NBATuiUzgvTYqsw5');

$payment->setAmount(500);

$payment->send();
1
2
3
4
5
import stancer

payment = stancer.Payment('paym_SKMLflt8NBATuiUzgvTYqsw5')
payment.amount = 500
payment.save()

List all payments

HTTP request

/v1/checkout/
?created=
created
&start=
start
&limit=
limit
/v1/checkout/
?order_id=
order_id
/v1/checkout/
?unique_id=
unique_id

Query parameters

Parameter Field Description
created Optional A Unix timestamp filtering payments whom timestamps are equal to or greater
limit Optional An integer value limiting the number of objects to be returned
order_id Optional Fetches payments corresponding to the order_id you specified in your inital payment request
start Optional An integer cursor you can use for pagination starting at index 0
unique_id Optional Fetches payments corresponding to the unique_id you specified in your inital payment request

Every parameters can be used together, when you do so, they are treated as union.

Return parameters

Parameter Description
live_mode Whatever if you are in live mode
payments An array of payment objects
range Details of your request and pagination. If has_more is true, you will need to move the start cursor ahead to fetch more objects

Code examples

1
curl "https://api.stancer.com/v1/checkout/?created=1541586411&limit=2"
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#! /bin/perl -w
use Stancer::Payment;

my $list = Stancer::Payment->list({order_id => '822386023', limit => 2});

while (my $payment = $list->next()) {
  # Do some stuff with $payment
}

# `list` method allow `hash` or `hashref`.
# `created` allow `integer` or a `DateTime` instance.
1
2
3
4
5
6
7
8
9
<?php
$list = Stancer\Payment::list(['order_id' => '822386023', 'limit' => 2]);

foreach ($list as $payment) {
  // Do some stuff with $payment
}

// `list` method return a generator.
// `created` allow `integer` or a `DateTime` instance.
1
    Not available for the moment.

The above command returns JSON structured as follows:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
{
  "live_mode": true,
  "payments": [
    {
      "amount": 3021,
      "card": {
        "brand": "mastercard",
        "country": "FR",
        "created": 1541586412,
        "exp_month": 9,
        "exp_year": 2019,
        "id": "card_acn1TKrqViXWVyK88GjnIUxd",
        "last4": "7354",
        "name": null,
        "zip_code": null
      },
      "country": "FR",
      "currency": "eur",
      "date_bank": null,
      "date_paym": 1541586411,
      "description": null,
      "fee": 5,
      "customer": null,
      "method": "card",
      "order_id": "822386023",
      "id": "paym_JnU7xyTGJvxRWZuxvj78qz7e",
      "response": "75",
      "status": null
    },
    {
      "amount": 3021,
      "card": {
        "brand": "visa",
        "country": "FR",
        "created": 1541586569,
        "exp_month": 11,
        "exp_year": 2023,
        "id": "card_690TS4zmux1I7fnLAB1Jt3yE",
        "last4": "1435",
        "name": null,
        "zip_code": null
      },
      "country": "FR",
      "currency": "eur",
      "date_bank": 1541631600,
      "date_paym": 1541586568,
      "description": null,
      "fee": 5,
      "customer": null,
      "method": "card",
      "order_id": "822386023",
      "id": "paym_p5tjCrXHy93xtVtVqvEJoC1c",
      "response": "00",
      "status": 2
    }
  ],
  "range": {
    "end": 1,
    "has_more": true,
    "limit": 2,
    "start": 0
  }
}