-
Notifications
You must be signed in to change notification settings - Fork 20
Refund
Shabab Haider Siddique edited this page May 25, 2021
·
2 revisions
class Refund
extends ResultObject
To process a refund you have to create a new Refund object. You can retrieve individual refund for a specific payment as well as a list of all refunds for a specific payment. Refunds are identified by a UUID.
| Name | Modifier & Type | Description |
|---|---|---|
| id | private string | Unique ID of payment |
| amount | private float | Amount charged |
| currency | private string | Three letter ISO currency code |
| type | private string | Can be either "authorization" or "purchase" |
| created | private string | Payment creation time as defined in RFC 3339 Section 5.6. UTC timezone. |
| live | private boolean | True if payment made in live mode. False if test mode. |
| parentId | private string | ID of parent payment |
| status | private string | Can be either "pending" , "approved" or "declined" |
| error | private string | Returned only if status is declined. Provide human readable information on cause of fail. |
| orderId | private string | Must be between 2 and 50 character. Provided by merchant. |
| description | private string | Maximum 255 characters |
| Name | Return Type | Description |
|---|---|---|
| getId() | public string | Returns payment ID |
| getAmount() | public double | Returns Amount |
| getCurrency() | public double | Returns currency of payment |
| getCreated() | public string | Gets created date of payment |
| getType() | public string | Gets type of payment |
| getLive() | public boolean | Return true if payment is live. False if test |
| getParentId() | public string | Get ID of parent Payment |
| getStatus() | public string | Return status of payment. (Can be either "pending" , "approved" or "declined" ) |
| getError() | public string | Human readable error if any |
| getOrderId() | public string | |
| getDescription() | public string | |
| isApproved() | public boolean | Return true if payment approved |
| isDeclined() | public boolean | Return true if payment rejected |
Creating refund
<?php
use Cardinity\Client;
use Cardinity\Method\Refund;
$client = Client::create([
'consumerKey' => 'YOUR_CONSUMER_KEY',
'consumerSecret' => 'YOUR_CONSUMER_SECRET',
]);
$method = new Refund\Create(
$payment->getId(),
10.00,
'my description'
);
/** @type Cardinity\Method\Refund\Refund */
$refund = $client->call($method);
?>Get existing refund
<?php
use Cardinity\Client;
use Cardinity\Method\Refund;
$client = Client::create([
'consumerKey' => 'YOUR_CONSUMER_KEY',
'consumerSecret' => 'YOUR_CONSUMER_SECRET',
]);
$method = new Refund\Get(
$payment->getId(),
$refund->getId()
);
/** @type Cardinity\Method\Refund\Refund */
$refund = $client->call($method);Get all refunds
<?php
use Cardinity\Client;
use Cardinity\Method\Refund;
$client = Client::create([
'consumerKey' => 'YOUR_CONSUMER_KEY',
'consumerSecret' => 'YOUR_CONSUMER_SECRET',
]);
$method = new Refund\GetAll(
$payment->getId()
);
$result = $client->call($method);
/** @type Cardinity\Method\Refund\Refund */
$refund = $result[0];