-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRefund.php
More file actions
103 lines (95 loc) · 2.67 KB
/
Copy pathRefund.php
File metadata and controls
103 lines (95 loc) · 2.67 KB
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
101
102
103
<?php
namespace Leaf\Billing\Paystack;
/**
* PayStack Refund
* ----
* API wrapper for PayStack Refund API
*/
class Refund
{
public Transaction $transaction;
public $integration;
public $deducted_amount;
public $channel;
public $currency;
public $amount;
public $fully_deducted;
public $refunded_by;
public $expected_at;
public $merchant_note;
public $customer_note;
public $id;
public $status;
public $createdAt;
public $updatedAt;
public function __construct(array $refund)
{
$this->transaction = $refund['transaction'];
$this->integration = $refund['integration'];
$this->deducted_amount = $refund['deducted_amount'];
$this->channel = $refund['channel'];
$this->currency = $refund['currency'];
$this->amount = $refund['amount'];
$this->fully_deducted = $refund['fully_deducted'];
$this->refunded_by = $refund['refunded_by'];
$this->expected_at = $refund['expected_at'];
$this->merchant_note = $refund['merchant_note'];
$this->customer_note = $refund['customer_note'];
$this->id = $refund['id'];
$this->status = $refund['status'];
$this->createdAt = $refund['createdAt'];
$this->updatedAt = $refund['updatedAt'];
}
/**
* Refund initiated?
* @return bool
*/
public function isPending(): bool
{
return $this->status === 'pending';
}
/**
* Refund received by bank?
* @return bool
*/
public function isProcessing(): bool
{
return $this->status === 'processing';
}
/**
* Refund successful?
* @return bool
*/
public function isSuccessful(): bool
{
return $this->status === 'success';
}
/**
* Refund failed?
* @return bool
*/
public function isFailed(): bool
{
return $this->status === 'failed';
}
public function toArray()
{
return [
'id' => $this->id,
'transaction' => $this->transaction->toArray(),
'integration' => $this->integration,
'deducted_amount' => $this->deducted_amount,
'channel' => $this->channel,
'currency' => $this->currency,
'amount' => $this->amount,
'fully_deducted' => $this->fully_deducted,
'refunded_by' => $this->refunded_by,
'expected_at' => $this->expected_at,
'merchant_note' => $this->merchant_note,
'customer_note' => $this->customer_note,
'status' => $this->status,
'createdAt' => $this->createdAt,
'updatedAt' => $this->updatedAt,
];
}
}