Skip to content

Cards

Credit Card

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
{
  "id": "card_xognFbZs935LMKJYeHyCAYUd",
  "last4": "4444",
  "brand": "mastercard",
  "exp_month": 2,
  "exp_year": 2023,
  "name": null,
  "zip_code": null,
  "tokenize": true
}
 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
package Stancer::Card;

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

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

has cvc => (is => 'rw', isa => Char[3]);

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

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

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

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

has last4 => (is => 'ro', isa => Char[4]);

has name => (is => 'rw', isa => Varchar[4, 64]);

has number => (is => 'rw', isa => CardNumber);

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

1;
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
<?php
namespace Stancer;

use DateTime;

class Card
{
  protected ?string $brand;
  protected ?DateTime $created;
  protected ?string $cvc;
  protected int $expMonth;
  protected int $expYear;
  protected ?string $id;
  protected ?string $last4;
  protected ?string $name;
  protected ?string $number;
  protected ?boolean $tokenize = true;

  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
from datetime import datetime

class Card(object):
  @property
  def brand(self) -> str:
    pass

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

The card object is defined as follows:

Parameter Field Description Type
id Given by the API Card's id String, fixed size = 29
number Required at creation The customer PAN number String, min = 16, max = 19
last4 Given by the API Last 4 PAN number String, fixed size = 4 characters
brand Given by the API Card brand String
exp_month Required at creation Expiration month Int, min = 1, max = 12
exp_year Required at creation Expiration year Int, min = current year, max = 2100
cvc Optional but highly recommanded The card verification code String, fixed size = 3 characters
name Optional Card holder name String, min = 4, max = 64
funding Given by the API Type of funding Enum credit, debit, prepaid, universal, charge or deferred. May be null if the type could not be determined.
nature Given by the API Nature of the card Enum personal or corporate. May be null if the nature could not be determined.
network Given by the API Network used to process payments (may differ from brand) Enum national, mastercard or visa. May be null if the network could not be determined.
zip_code Optional City zip code String, min = 2, max = 8
tokenize Optional If you want the card to be tokenized and reused Boolean, default True
created Given by the API The Unix timestamp representing creation date of the object in local time Int

Create a card

HTTP request
/v1/cards/
Data parameters
Parameter Field
number Required
exp_month Required
exp_year Required
cvc Optional but highly recommanded
name Optional
tokenize Optional
zip_code Optional
Return parameters

The API will replicate your data, except for number and cvc, in the return parameters and add the following ones:

Parameter Field
id Required
created Required
last4 Required
brand Required
funding Required
nature Required
network Required

You may received a 409 Conflict HTTP response if the card already exists, whom body will contain the id of the already-existing card.

Code examples
1
2
3
4
5
6
7
8
curl -X POST "https://api.stancer.com/v1/cards/" \
  --header "Content-Type: application/json" \
  --data '{
    "number": "5555555555554444",
    "cvc": "123",
    "exp_year": "2023",
    "exp_month": "02"
}'

The above command returns JSON structured as follows:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
{
  "brand": "mastercard",
  "country": "US",
  "created": 1579010740,
  "exp_month": 2,
  "exp_year": 2023,
  "funding": "credit",
  "id": "card_ub99idEIFcbK517ZrKBIrt4y",
  "last4": "4444",
  "live_mode": false,
  "name": null,
  "nature": "personal",
  "network": "mastercard",
  "zip_code": null
}

Get card data

HTTP request
/v1/cards/
id_card
Query parameters
Parameter Description
id_card The ID of the card to retrieve
Return parameters

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

Code examples
1
curl "https://api.stancer.com/v1/cards/card_ub99idEIFcbK517ZrKBIrt4y"

The above command returns JSON structured as follows:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
{
  "brand": "mastercard",
  "country": "US",
  "created": 1579010740,
  "exp_month": 2,
  "exp_year": 2023,
  "funding": "credit",
  "id": "card_ub99idEIFcbK517ZrKBIrt4y",
  "last4": "4444",
  "live_mode": false,
  "name": null,
  "nature": "personal",
  "network": "mastercard",
  "zip_code": null
}

Update a card

HTTP request
/v1/cards/
id_card
Query parameters
Parameter Description
id_card Card id
Data parameters
Parameter Field
exp_month Optional
exp_year Optional
name Optional
zip_code Optional
Return parameters

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

Code examples
1
2
3
4
5
curl -X PATCH "https://api.stancer.com/v1/cards/card_ub99idEIFcbK517ZrKBIrt4y" \
  --header "Content-Type: application/json" \
  --data '{
    "name": "Pickle Rick"
}'

Delete a card

HTTP request
/v1/cards/
id_card
Query parameters
Parameter Description
id_card Card id
Return parameters

The above command returns an HTTP 204 code if success or an HTTP 404 code if the card does not exist.

Code examples
1
curl -X DELETE "https://api.stancer.com/v1/cards/card_ub99idEIFcbK517ZrKBIrt4y"