1
1
# Monetico PHP SDK
2
2
3
- This library aims to facilitate the usage of Monetico Payment Service
3
+ [ ![ Latest Version] ( https://img.shields.io/packagist/v/DansMaCulotte/monetico-php.svg?style=flat-square )] ( https://packagist.org/packages/dansmaculotte/monetico-php )
4
+ [ ![ Total Downloads] ( https://img.shields.io/packagist/dt/DansMaCulotte/monetico-php.svg?style=flat-square )] ( https://packagist.org/packages/dansmaculotte/monetico-php )
5
+ [ ![ Build Status] ( https://img.shields.io/travis/DansMaCulotte/monetico-php/master.svg?style=flat-square )] ( https://travis-ci.org/dansmaculotte/monetico-php )
6
+ [ ![ Quality Score] ( https://img.shields.io/scrutinizer/g/DansMaCulotte/monetico-php.svg?style=flat-square )] ( https://scrutinizer-ci.com/g/dansmaculotte/monetico-php )
7
+ [ ![ Code Coverage] ( https://img.shields.io/coveralls/github/DansMaCulotte/monetico-php.svg?style=flat-square )] ( https://coveralls.io/github/dansmaculotte/monetico-php )
8
+
9
+ This library aims to facilitate the usage of Monetico Service Methods
4
10
5
11
## Installation
6
12
7
13
### Requirements
8
14
9
- - PHP 7.0
15
+ - PHP 7.2
10
16
11
17
You can install the package via composer:
12
18
13
- ``` bash
19
+ ``` bash
14
20
composer require dansmaculotte/monetico-php
15
21
```
16
22
17
23
## Usage
18
24
25
+ ### Monetico
26
+
19
27
``` php
20
28
use DansMaCulotte\Monetico\Monetico;
21
29
@@ -29,8 +37,13 @@ $monetico = new Monetico(
29
37
);
30
38
```
31
39
40
+ ### Payment
41
+
32
42
``` php
33
43
use DansMaCulotte\Monetico\Payment\Payment;
44
+ use DansMaCulotte\Monetico\Resources\AddressBilling;
45
+ use DansMaCulotte\Monetico\Resources\AddressShipping;
46
+ use DansMaCulotte\Monetico\Resources\Client;
34
47
35
48
$payment = new Payment(array(
36
49
'reference' => 'ABCDEF123',
@@ -42,6 +55,15 @@ $payment = new Payment(array(
42
55
'datetime' => Carbon::create(2019, 1, 1),
43
56
));
44
57
58
+ $addressBilling = new AddressBilling('7 rue melingue', 'Caen', '14000', 'France');
59
+ $payment->setAddressBilling($addressBilling);
60
+
61
+ $addressShipping = new AddressShipping('7 rue melingue', 'Caen', '14000', 'France');
62
+ $payment->setAddressShipping($addressShipping);
63
+
64
+ $client = new Client('MR', 'John', 'Stark', 'Snow');
65
+ $payment->setClient($client);
66
+
45
67
$url = $monetico->getPaymentUrl();
46
68
$fields = $monetico->getPaymentFields($payment);
47
69
```
@@ -59,6 +81,91 @@ $result = $monetico->validateSeal($response);
59
81
$receipt = new Receipt($result);
60
82
```
61
83
84
+ ### Recovery
85
+
86
+ ``` php
87
+ Use DansMaCulotte\Monetico\Recovery\Recovery;
88
+ use DansMaCulotte\Monetico\Recovery\Response;
89
+
90
+ $recovery = new Recovery([
91
+ 'reference' => 'AXCDEF123',
92
+ 'language' => 'FR',
93
+ 'amount' => 42.42,
94
+ 'amountToRecover' => 0,
95
+ 'amountRecovered' => 0,
96
+ 'amountLeft' => 42.42,
97
+ 'currency' => 'EUR',
98
+ 'orderDate' => Carbon::create(2019, 07, 17),
99
+ 'dateTime' => Carbon::create(2019, 07, 17),
100
+ ]);
101
+
102
+ $url = $monetico->getRecoveryUrl();
103
+ $fields = $monetico->getRecoveryFields($recovery);
104
+
105
+ $client = new GuzzleHttp\Client();
106
+ $data = $client->request('POST', $url, $fields);
107
+
108
+ // $data = json_decode($data, true);
109
+
110
+ $response = new Response($data);
111
+ ```
112
+
113
+ ### Cancel
114
+
115
+ ``` php
116
+ use DansMaCulotte\Monetico\Cancel\Cancel;
117
+ use DansMaCulotte\Monetico\Cancel\Response;
118
+
119
+ $cancel = new Cancel([
120
+ 'dateTime' => Carbon::create(2019, 2, 1),
121
+ 'orderDate' => Carbon::create(2019, 1, 1),
122
+ 'reference' => 'ABC123',
123
+ 'language' => 'FR',
124
+ 'currency' => 'EUR',
125
+ 'amount' => 100,
126
+ 'amountRecovered' => 0,
127
+ ]);
128
+
129
+ $url = $monetico->getCancelUrl();
130
+ $fields = $monetico->getCancelFields($recovery);
131
+
132
+ $client = new GuzzleHttp\Client();
133
+ $data = $client->request('POST', $url, $fields);
134
+
135
+ // $data = json_decode($data, true);
136
+
137
+ $response = new Response($data);
138
+ ```
139
+
140
+ ### Refund
141
+
142
+ ``` php
143
+ use DansMaCulotte\Monetico\Refund\Refund;
144
+ use DansMaCulotte\Monetico\Refund\Response;
145
+
146
+ $refund = new Refund([
147
+ 'datetime' => Carbon::create(2019, 2, 1),
148
+ 'orderDatetime' => Carbon::create(2019, 1, 1),
149
+ 'recoveryDatetime' => Carbon::create(2019, 1, 1),
150
+ 'authorizationNumber' => '1222',
151
+ 'reference' => 'ABC123',
152
+ 'language' => 'FR',
153
+ 'currency' => 'EUR',
154
+ 'amount' => 100,
155
+ 'refundAmount' => 50,
156
+ 'maxRefundAmount' => 80,
157
+ ]);
158
+
159
+ $url = $monetico->getRefundUrl();
160
+ $fields = $monetico->getRefundFields($recovery);
161
+
162
+ $client = new GuzzleHttp\Client();
163
+ $data = $client->request('POST', $url, $fields);
164
+
165
+ // $data = json_decode($data, true);
166
+
167
+ $response = new Response($data);
168
+ ```
62
169
## License
63
170
64
171
The MIT License (MIT). Please see [ License File] ( LICENSE.md ) for more information.
0 commit comments