1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Srmklive\PayPal\Traits\PayPalAPI; |
4
|
|
|
|
5
|
|
|
trait PaymentCaptures |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* Show details for a captured payment. |
9
|
|
|
* |
10
|
|
|
* @param string $capture_id |
11
|
|
|
* |
12
|
|
|
* @throws \Throwable |
13
|
|
|
* |
14
|
|
|
* @return array|\Psr\Http\Message\StreamInterface|string |
15
|
|
|
* |
16
|
|
|
* @see https://developer.paypal.com/docs/api/payments/v2/#captures_get |
17
|
|
|
*/ |
18
|
|
|
public function showCapturedPaymentDetails(string $capture_id) |
19
|
|
|
{ |
20
|
|
|
$this->apiEndPoint = "v2/payments/captures/{$capture_id}"; |
21
|
|
|
|
22
|
|
|
$this->verb = 'get'; |
23
|
|
|
|
24
|
|
|
return $this->doPayPalRequest(); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Refund a captured payment. |
29
|
|
|
* |
30
|
|
|
* @param string $capture_id |
31
|
|
|
* @param string $invoice_id |
32
|
|
|
* @param float $amount |
33
|
|
|
* @param string $note |
34
|
|
|
* |
35
|
|
|
* @throws \Throwable |
36
|
|
|
* |
37
|
|
|
* @return array|\Psr\Http\Message\StreamInterface|string |
38
|
|
|
* |
39
|
|
|
* @see https://developer.paypal.com/docs/api/payments/v2/#captures_refund |
40
|
|
|
*/ |
41
|
|
|
public function refundCapturedPayment(string $capture_id, string $invoice_id, float $amount, string $note) |
42
|
|
|
{ |
43
|
|
|
$this->apiEndPoint = "v2/payments/captures/{$capture_id}/refund"; |
44
|
|
|
|
45
|
|
|
$this->options['json'] = [ |
46
|
|
|
'amount' => [ |
47
|
|
|
'value' => $amount, |
48
|
|
|
'currency_code' => $this->currency, |
49
|
|
|
], |
50
|
|
|
'invoice_id' => $invoice_id, |
51
|
|
|
'note_to_payer' => $note, |
52
|
|
|
]; |
53
|
|
|
|
54
|
|
|
$this->verb = 'post'; |
55
|
|
|
|
56
|
|
|
return $this->doPayPalRequest(); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Refund full captured payment |
61
|
|
|
* |
62
|
|
|
* @param string $capture_id |
63
|
|
|
* |
64
|
|
|
* @throws \Throwable |
65
|
|
|
* |
66
|
|
|
* @return array|\Psr\Http\Message\StreamInterface|string |
67
|
|
|
* |
68
|
|
|
* @see https://developer.paypal.com/docs/api/payments/v2/#captures_refund |
69
|
|
|
*/ |
70
|
|
|
public function refundFullCapturedPayment(string $capture_id) |
71
|
|
|
{ |
72
|
|
|
$this->apiEndPoint = "v2/payments/captures/{$capture_id}/refund"; |
73
|
|
|
|
74
|
|
|
$this->verb = 'post'; |
75
|
|
|
|
76
|
|
|
return $this->doPayPalRequest(); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|