/
Payment.php
87 lines (82 loc) · 2.69 KB
/
Payment.php
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
<?php
namespace Payplug;
/**
* The Payment DAO simplifies the access to most useful methods
**/
class Payment
{
/**
* Retrieves a Payment.
*
* @param string $paymentId the payment ID
* @param Payplug $payplug the client configuration
*
* @return null|Resource\Payment the retrieved payment or null on error
*
* @throws Exception\ConfigurationNotSetException
*/
public static function retrieve($paymentId, Payplug $payplug = null)
{
return Resource\Payment::retrieve($paymentId, $payplug);
}
/**
* Aborts a Payment.
*
* @param string $paymentId the payment ID
* @param Payplug $payplug the client configuration
*
* @return null|Resource\Payment the aborted payment or null on error
*
* @throws Exception\ConfigurationNotSetException
*/
public static function abort($paymentId, Payplug $payplug = null)
{
$payment = Resource\Payment::fromAttributes(array('id' => $paymentId));
return $payment->abort($payplug);
}
/**
* Captures a Payment.
*
* @param string $paymentId the payment ID
* @param Payplug $payplug the client configuration
*
* @return null|Resource\Payment the captured payment or null on error
*
* @throws Exception\ConfigurationNotSetException
*/
public static function capture($paymentId, Payplug $payplug = null)
{
$payment = Resource\Payment::fromAttributes(array('id' => $paymentId));
return $payment->capture($payplug);
}
/**
* Creates a Payment.
*
* @param array $data API data for payment creation
* @param Payplug $payplug the client configuration
*
* @return null|Resource\Payment the created payment instance
*
* @throws Exception\ConfigurationNotSetException
*/
public static function create(array $data, Payplug $payplug = null)
{
return Resource\Payment::create($data, $payplug);
}
/**
* List payments.
*
* @param int $perPage number of results per page
* @param int $page the page number
* @param Payplug $payplug the client configuration
*
* @return null|Resource\Payment[] the array of payments
*
* @throws Exception\InvalidPaymentException
* @throws Exception\UnexpectedAPIResponseException
*/
public static function listPayments($perPage = null, $page = null, Payplug $payplug = null)
{
return Resource\Payment::listPayments($perPage, $page, $payplug);
}
};