1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Luigel\Paymongo; |
4
|
|
|
|
5
|
|
|
use Luigel\Paymongo\Models\Payment; |
6
|
|
|
use Luigel\Paymongo\Models\PaymentIntent; |
7
|
|
|
use Luigel\Paymongo\Models\PaymentMethod; |
8
|
|
|
use Luigel\Paymongo\Models\Source; |
9
|
|
|
use Luigel\Paymongo\Models\Token; |
10
|
|
|
use Luigel\Paymongo\Models\Webhook; |
11
|
|
|
use Luigel\Paymongo\Traits\Request; |
12
|
|
|
|
13
|
|
|
class Paymongo |
14
|
|
|
{ |
15
|
|
|
use Request; |
16
|
|
|
|
17
|
|
|
protected $method; |
18
|
|
|
protected $apiUrl = ''; |
19
|
|
|
protected $payload; |
20
|
|
|
protected $returnModel = ''; |
21
|
|
|
|
22
|
|
|
protected const BASE_API = 'https://api.paymongo.com/v1/'; |
23
|
|
|
protected const ENPDPOINT_SOURCES = 'sources/'; |
24
|
|
|
protected const ENDPOINT_WEBHOOKS = 'webhooks/'; |
25
|
|
|
protected const ENDPOINT_PAYMENT_METHOD = 'payment_methods/'; |
26
|
|
|
protected const ENDPOINT_PAYMENT_INTENT = 'payment_intents/'; |
27
|
|
|
protected const ENDPOINT_PAYMENT = 'payments/'; |
28
|
|
|
protected const ENDPOINT_TOKEN = 'tokens/'; |
29
|
|
|
protected const SOURCE_GCASH = 'gcash'; |
30
|
|
|
protected const SOURCE_GRAB_PAY = 'grab_pay'; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Source Module used to create Source. |
34
|
|
|
* |
35
|
|
|
* @return $this |
36
|
|
|
*/ |
37
|
|
|
public function source() |
38
|
|
|
{ |
39
|
|
|
$this->apiUrl = self::BASE_API.self::ENPDPOINT_SOURCES; |
40
|
|
|
$this->returnModel = Source::class; |
41
|
|
|
|
42
|
|
|
return $this; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Webhook Module used to create, retrieve, enable, and disable Webhooks. |
47
|
|
|
* |
48
|
|
|
* @return $this |
49
|
|
|
*/ |
50
|
|
|
public function webhook() |
51
|
|
|
{ |
52
|
|
|
$this->apiUrl = self::BASE_API.self::ENDPOINT_WEBHOOKS; |
53
|
|
|
$this->returnModel = Webhook::class; |
54
|
|
|
|
55
|
|
|
return $this; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Payment Method Module used to create, retrieve Payment method informations. |
60
|
|
|
* |
61
|
|
|
* @return $this |
62
|
|
|
*/ |
63
|
|
|
public function paymentMethod() |
64
|
|
|
{ |
65
|
|
|
$this->apiUrl = self::BASE_API.self::ENDPOINT_PAYMENT_METHOD; |
66
|
|
|
$this->returnModel = PaymentMethod::class; |
67
|
|
|
|
68
|
|
|
return $this; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Payment Intent Module used to create, retrieve, and attach payment method in payment intent. |
73
|
|
|
* |
74
|
|
|
* @return $this |
75
|
|
|
*/ |
76
|
|
|
public function paymentIntent() |
77
|
|
|
{ |
78
|
|
|
$this->apiUrl = self::BASE_API.self::ENDPOINT_PAYMENT_INTENT; |
79
|
|
|
$this->returnModel = PaymentIntent::class; |
80
|
|
|
|
81
|
|
|
return $this; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Payment Module used to create, retrieve Payment informations. |
86
|
|
|
* |
87
|
|
|
* @return $this |
88
|
|
|
*/ |
89
|
|
|
public function payment() |
90
|
|
|
{ |
91
|
|
|
$this->apiUrl = self::BASE_API.self::ENDPOINT_PAYMENT; |
92
|
|
|
$this->returnModel = Payment::class; |
93
|
|
|
|
94
|
|
|
return $this; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Token Module used to create and retrieve token. |
99
|
|
|
* @deprecated 1.2.0 |
100
|
|
|
* @return $this |
101
|
|
|
*/ |
102
|
|
|
public function token() |
103
|
|
|
{ |
104
|
|
|
$this->apiUrl = self::BASE_API.self::ENDPOINT_TOKEN; |
105
|
|
|
$this->returnModel = Token::class; |
106
|
|
|
|
107
|
|
|
return $this; |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
|