Skip to content

Refunds

Refunds

1
2
3
4
5
6
7
8
{
  "id": "refd_o6Y1oZinbl9lErB24OSQCAKl",
  "payment": "paym_sS1sXwDuaqGTjuQ7DY4BBNaI",
  "amount": 50,
  "currency": "eur",
  "created": 1540231459,
  "live_mode": false
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
package Stancer::Refund;

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

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

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

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

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

has payment => (is => 'ro', isa => InstanceOf['Stancer::Payment']);

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

use DateTime;

class Refund
{
  protected int $amount;
  protected DateTime $created;
  protected string $currency;
  protected string $id;
  protected Payment $payment;

  public function __construct(string $id = null) {}
}
1
Not available for the moment

The refund object is defined as follows:

Parameter Description Type
id Refund's id String, fixed size = 29
payment Refunded payment id String, fixed size = 29
amount Amount to refund in cents, if omitted will refund the the whole payment Int, have to be =< to the original amount of the payment
currency Processed currency Enum EUR, USD, GBP
status Refund status See refund status codes
created Refund creation's timestamp Int
date_refund Timestamp of the date when the API sent the refund request to the bank Int
date_bank Timestamp of the delivery date of the funds by the bank Int
live_mode Whatever if the refund is in live mode Boolean

Create a refund

1
2
3
4
5
6
curl -X POST "https://api.stancer.com/v1/refunds/" \
  --header "Content-Type: application/json" \
  --data '{
    "payment": "paym_sS1sXwDuaqGTjuQ7DY4BBNaI",
    "amount": 50
}'
1
2
3
4
5
6
#! /bin/perl -w
use Stancer::Payment;

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

$payment->refund(50); # Amount is optional
1
2
3
4
<?php
$payment = new Stancer\Payment('paym_sS1sXwDuaqGTjuQ7DY4BBNaI');

$payment->refund(50); // Amount is optional
1
Not available for the moment

The above command returns JSON structured as follows:

1
2
3
4
5
6
7
8
{
  "amount": 50,
  "created": 1540231459,
  "currency": "eur",
  "id": "refd_o6Y1oZinbl9lErB24OSQCAKl",
  "live_mode": false,
  "payment": "paym_sS1sXwDuaqGTjuQ7DY4BBNaI"
}

HTTP request

/v1/refunds/

Data parameters

Parameter Field
payment Required
amount Optional

Return parameters

The request returns a refund object as previously defined.

Get refund data

1
curl "https://api.stancer.com/v1/refunds/refd_o6Y1oZinbl9lErB24OSQCAKl"
1
2
3
4
#! /bin/perl -w
use Stancer::Refund;

my $refund = Stancer::Refund->new('refd_o6Y1oZinbl9lErB24OSQCAKl');
1
2
<?php
$payment = new Stancer\Refund('refd_o6Y1oZinbl9lErB24OSQCAKl');
1
Not available for the moment

The above command returns JSON structured as follows:

1
2
3
4
5
6
7
8
{
  "amount": 50,
  "created": 1540231459,
  "currency": "eur",
  "id": "refd_o6Y1oZinbl9lErB24OSQCAKl",
  "live_mode": false,
  "payment": "paym_sS1sXwDuaqGTjuQ7DY4BBNaI"
}

HTTP request

/v1/refunds/
id_refund

Query parameters

Parameter Field
id_refund Required

Return parameters

The request returns a refund object as previously defined.