Skip to content

Refunds

waqastanoli10 edited this page Feb 12, 2020 · 1 revision

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

Full refund

A full refund returns the total amount of the transaction to the customer — it can only be performed once.

Partial refund

A partial refund returns a sum less than the captured amount. A payment can be refunded multiple times, but cannot exceed the original payment amount.

Create a Refund

When you create a new refund, you must specify a charge to create it on.

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

You can optionally refund only part of a charge. You can do so as many times as you wish until the entire charge has been refunded.

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

$refund_created = GoSell\Refunds::create([
  "charge_id"=> "chg_86dfjghadfuda7ft",
  "amount"=> 2,
  "currency"=> "KWD",
  "description"=> "Test Description",
  "reason"=> "requested_by_customer",
  "reference"=> [
    "merchant"=> "txn_0001"
  ],
  "metadata"=> [
    "udf1"=> "test1",
    "udf2"=> "test2"
  ],
  "post"=> [
    "url"=> "http://your_url.com/post"
  ]
]);

echo '<pre>';var_dump($refund_created);

Retrieve a Refund

Retrieves the details of an existing refund.

$retrieved_refund = GoSell\Refunds::retrieve('re_g4RZ2920201036p9X50502366');

Update a Refund

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.

$updated_refund = GoSell\Refunds::update($retrieved_refund->id,[
  "metadata"=> [
    "OrderNumber"=> "test update"
  ]
]);

List all Refunds

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

$all_Refunds = GoSell\Refunds::all(new stdClass());

var_dump($all_Refunds);