Skip to content

Commit 7058a8a

Browse files
authored
New API methods and 3DSv2 support (#15)
* refactor: group trait and interface into abstract class * refactor: separate requests and responses in folders BREAKING CHANGE: API has changed, see ReadMe.me * chore(release): 2.0.0-0 * chore(release): 2.0.0-beta.0 * refactor: leave successUrl and errorUrl as submitted * refactor(AbstractRequest): make getUrl static * chore(release): 2.0.0-beta.1 * feat: add cart resource and unify resources * docs: update code examples in readme * tests: add resource test * chore(release): 2.0.0-beta.2 * refactor: wip * Revert "refactor: wip" This reverts commit 7d6c1bb. * refactor: rename payment to capture * fix: bad naming, update with camelCase * fix: reference limit to 50 and uppercase language * fix: return if value is not defined in setParameter method * revert: if value is not defined in parameter * refactor: rename capture in purchase * refactor: change resource constructor * refactor: change purchase response toArray method visibility * refactor: include in context only not null resource * fix: do not escape to unicode for context_command * fix: add missing fields in purchase response * docs: add purchase request * docs: add purchase response * chore: update dependencies * refactor: travis.yml * fix: missing return in baseFields * chore(release): 2.0.0-beta.3 * docs: update usage * docs: remove Carbon from usage examples * refactor: cleanup assertions * chore: update ci
1 parent 8cf7e17 commit 7058a8a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2842
-4756
lines changed

.gitignore

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
### Composer ###
22
composer.phar
3+
composer.lock
34
/vendor/
45

5-
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
6-
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
7-
# composer.lock
86
tests/Credentials.php
97
coverage
108
build

.scrutinizer.yml

-5
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,3 @@ checks:
1616
fix_line_ending: true
1717
fix_identation_4spaces: true
1818
fix_doc_comments: true
19-
20-
tools:
21-
external_code_coverage:
22-
timeout: 600
23-
runs: 4

.travis.yml

-17
This file was deleted.

CHANGELOG.md

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4+
5+
## [2.0.0-beta.3](https://github.com/dansmaculotte/monetico-php/compare/v2.0.0-beta.2...v2.0.0-beta.3) (2019-11-30)
6+
7+
8+
### Bug Fixes
9+
10+
* add missing fields in purchase response ([b4c633b](https://github.com/dansmaculotte/monetico-php/commit/b4c633bc3519f99cc10f927505ee551f189870c9))
11+
* bad naming, update with camelCase ([4cc2d15](https://github.com/dansmaculotte/monetico-php/commit/4cc2d152b7409a5292840388e65e71c7d9ff2cdb))
12+
* do not escape to unicode for context_command ([1d578b6](https://github.com/dansmaculotte/monetico-php/commit/1d578b63e5fd063d932c00547bb774073bd9e231))
13+
* missing return in baseFields ([9f894da](https://github.com/dansmaculotte/monetico-php/commit/9f894daf806823f010d36fa07612541de4dcc6ec))
14+
* reference limit to 50 and uppercase language ([609808d](https://github.com/dansmaculotte/monetico-php/commit/609808d6dfab7fe5024eac52cc9f0260ff4b0bba))
15+
* return if value is not defined in setParameter method ([44af33b](https://github.com/dansmaculotte/monetico-php/commit/44af33bb38659f74d0780e7f400df60a20491226))
16+
17+
## [2.0.0-beta.2](https://github.com/dansmaculotte/monetico-php/compare/v2.0.0-beta.1...v2.0.0-beta.2) (2019-08-29)
18+
19+
20+
### Features
21+
22+
* add cart resource and unify resources ([cf45695](https://github.com/dansmaculotte/monetico-php/commit/cf45695))
23+
24+
## [2.0.0-beta.1](https://github.com/DansMaCulotte/monetico-php/compare/v2.0.0-0...v2.0.0-beta.1) (2019-08-28)
25+
26+
## [2.0.0-beta.0](https://github.com/DansMaCulotte/monetico-php/compare/v2.0.0-0...v2.0.0-beta.0) (2019-08-27)
27+
28+
## 2.0.0-0 (2019-08-27)
29+
30+
31+
### ⚠ BREAKING CHANGES
32+
33+
* API has changed, see ReadMe.me
34+
35+
* separate requests and responses in folders ([c312854](https://github.com/DansMaCulotte/monetico-php/commit/c312854))
36+
37+
## 1.0.0 (2019-07-24)
38+
39+
40+
### Bug Fixes
41+
42+
* adjust quotes wrapping for payment receipt output format and lowercase seal in seal validation. Resolves [#2](https://github.com/DansMaCulotte/monetico-php/issues/2). ([c7a9244](https://github.com/DansMaCulotte/monetico-php/commit/c7a9244))
43+
* move carbon to dev dependencies ([5235c76](https://github.com/DansMaCulotte/monetico-php/commit/5235c76))
44+
* transform security key before seal generation ([4bc97d3](https://github.com/DansMaCulotte/monetico-php/commit/4bc97d3))
45+
46+
47+
### Features
48+
49+
* Add base files ([0419ab4](https://github.com/DansMaCulotte/monetico-php/commit/0419ab4))
50+
* add php-cs-fixer and git hooks ([1689a16](https://github.com/DansMaCulotte/monetico-php/commit/1689a16))
51+
* Add ReadMe and Licence ([b61d7ff](https://github.com/DansMaCulotte/monetico-php/commit/b61d7ff))

ReadMe.md

+105-55
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Latest Version](https://img.shields.io/packagist/v/DansMaCulotte/monetico-php.svg?style=flat-square)](https://packagist.org/packages/dansmaculotte/monetico-php)
44
[![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)
5+
[![Build Status](https://img.shields.io/github/workflow/status/dansmaculotte/monetico-php/run-tests?label=tests&style=flat-square)](https://github.com/dansmaculotte/monetico-php/actions?query=workflow%3Arun-tests)
66
[![Quality Score](https://img.shields.io/scrutinizer/g/DansMaCulotte/monetico-php.svg?style=flat-square)](https://scrutinizer-ci.com/g/dansmaculotte/monetico-php)
77
[![Code Coverage](https://img.shields.io/coveralls/github/DansMaCulotte/monetico-php.svg?style=flat-square)](https://coveralls.io/github/dansmaculotte/monetico-php)
88

@@ -30,123 +30,173 @@ use DansMaCulotte\Monetico\Monetico;
3030
$monetico = new Monetico(
3131
'EPT_CODE',
3232
'SECURITY_KEY',
33-
'COMPANY_CODE',
34-
'RETURN_URL',
35-
'RETURN_SUCCESS_URL',
36-
'RETURN_ERROR_URL'
33+
'COMPANY_CODE'
3734
);
3835
```
3936

40-
### Payment
37+
### Purchase
4138

4239
```php
43-
use DansMaCulotte\Monetico\Payment\Payment;
44-
use DansMaCulotte\Monetico\Resources\AddressBilling;
45-
use DansMaCulotte\Monetico\Resources\AddressShipping;
46-
use DansMaCulotte\Monetico\Resources\Client;
40+
use DansMaCulotte\Monetico\Monetico;
41+
use DansMaCulotte\Monetico\Requests\PurchaseRequest;
42+
use DansMaCulotte\Monetico\Resources\BillingAddressResource;
43+
use DansMaCulotte\Monetico\Resources\ShippingAddressResource;
44+
use DansMaCulotte\Monetico\Resources\ClientResource;
4745

48-
$payment = new Payment(array(
46+
$monetico = new Monetico(
47+
'EPT_CODE',
48+
'SECURITY_KEY',
49+
'COMPANY_CODE'
50+
);
51+
52+
$purchase = new PurchaseRequest([
4953
'reference' => 'ABCDEF123',
5054
'description' => 'Documentation',
5155
'language' => 'FR',
5256
'email' => 'john@snow.stark',
5357
'amount' => 42,
5458
'currency' => 'EUR',
55-
'datetime' => Carbon::create(2019, 1, 1),
56-
));
57-
58-
$addressBilling = new AddressBilling('7 rue melingue', 'Caen', '14000', 'France');
59-
$payment->setAddressBilling($addressBilling);
59+
'datetime' => new DateTime(),
60+
'successUrl' => 'http://localhost/thanks',
61+
'errorUrl' => 'http://localhost/oops',
62+
]);
6063

61-
$addressShipping = new AddressShipping('7 rue melingue', 'Caen', '14000', 'France');
62-
$payment->setAddressShipping($addressShipping);
64+
$billingAddress = new BillingAddressResource([
65+
'name' => 'dans ma culotte',
66+
'addressLine1' => '42 rue des serviettes',
67+
'city' => 'Coupeville',
68+
'postalCode' => '42000',
69+
'country' => 'France',
70+
]);
71+
$purchase->setBillingAddress($billingAddress);
72+
73+
$shippingAddress = new ShippingAddressResource([
74+
'name' => 'dans ma culotte',
75+
'addressLine1' => '42 rue des serviettes',
76+
'city' => 'Coupeville',
77+
'postalCode' => '42000',
78+
'country' => 'France',
79+
]);
80+
$purchase->setShippingAddress($shippingAddress);
6381

64-
$client = new Client('MR', 'John', 'Stark', 'Snow');
65-
$payment->setClient($client);
82+
$client = new ClientResource([
83+
'civility' => 'Mr',
84+
'firstName' => 'John',
85+
'lastName' => 'Snow',
86+
]);
87+
$purchase->setClient($client);
6688

67-
$url = $monetico->getPaymentUrl();
68-
$fields = $monetico->getPaymentFields($payment);
89+
$url = PurchaseRequest::getUrl();
90+
$fields = $monetico->getFields($purchase);
6991
```
7092

7193
```php
72-
Use DansMaCulotte\Monetico\Payment\Response;
73-
use DansMaCulotte\Monetico\Payment\Receipt;
94+
use DansMaCulotte\Monetico\Monetico;
95+
use DansMaCulotte\Monetico\Responses\PurchaseResponse;
96+
use DansMaCulotte\Monetico\Receipts\PurchaseReceipt;
7497

75-
// $data = json_decode($body, true);
98+
$data = json_decode([/* bank request body */], true);
7699

77-
$response = new Response($data);
100+
$monetico = new Monetico(
101+
'EPT_CODE',
102+
'SECURITY_KEY',
103+
'COMPANY_CODE'
104+
);
78105

79-
$result = $monetico->validateSeal($response);
106+
$response = new PurchaseResponse($data);
80107

81-
$receipt = new Receipt($result);
108+
$result = $monetico->validate($response);
109+
110+
$receipt = new PurchaseReceipt($result);
82111
```
83112

84113
### Recovery
85114

86115
```php
87-
Use DansMaCulotte\Monetico\Recovery\Recovery;
88-
use DansMaCulotte\Monetico\Recovery\Response;
116+
use DansMaCulotte\Monetico\Monetico;
117+
use DansMaCulotte\Monetico\Requests\RecoveryRequest;
118+
use DansMaCulotte\Monetico\Responses\RecoveryResponse;
89119

90-
$recovery = new Recovery([
120+
$monetico = new Monetico(
121+
'EPT_CODE',
122+
'SECURITY_KEY',
123+
'COMPANY_CODE'
124+
);
125+
126+
$recovery = new RecoveryRequest([
91127
'reference' => 'AXCDEF123',
92128
'language' => 'FR',
93129
'amount' => 42.42,
94130
'amountToRecover' => 0,
95131
'amountRecovered' => 0,
96132
'amountLeft' => 42.42,
97133
'currency' => 'EUR',
98-
'orderDate' => Carbon::create(2019, 07, 17),
99-
'dateTime' => Carbon::create(2019, 07, 17),
134+
'orderDate' => new DateTime(),
135+
'dateTime' => new DateTime(),
100136
]);
101137

102-
$url = $monetico->getRecoveryUrl();
103-
$fields = $monetico->getRecoveryFields($recovery);
138+
$url = RecoveryRequest::getUrl();
139+
$fields = $monetico->getFields($recovery);
104140

105-
$client = new GuzzleHttp\Client();
141+
$client = new Http\Client();
106142
$data = $client->request('POST', $url, $fields);
107143

108144
// $data = json_decode($data, true);
109145

110-
$response = new Response($data);
146+
$response = new RecoveryResponse($data);
111147
```
112148

113149
### Cancel
114150

115151
```php
116-
use DansMaCulotte\Monetico\Cancel\Cancel;
117-
use DansMaCulotte\Monetico\Cancel\Response;
152+
use DansMaCulotte\Monetico\Monetico;
153+
use DansMaCulotte\Monetico\Requests\CancelRequest;
154+
use DansMaCulotte\Monetico\Responses\CancelResponse;
155+
156+
$monetico = new Monetico(
157+
'EPT_CODE',
158+
'SECURITY_KEY',
159+
'COMPANY_CODE'
160+
);
118161

119-
$cancel = new Cancel([
120-
'dateTime' => Carbon::create(2019, 2, 1),
121-
'orderDate' => Carbon::create(2019, 1, 1),
162+
$cancel = new CancelRequest([
163+
'dateTime' => new DateTime(),
164+
'orderDate' => new DateTime(),
122165
'reference' => 'ABC123',
123166
'language' => 'FR',
124167
'currency' => 'EUR',
125168
'amount' => 100,
126169
'amountRecovered' => 0,
127170
]);
128171

129-
$url = $monetico->getCancelUrl();
130-
$fields = $monetico->getCancelFields($recovery);
172+
$url = CancelRequest::getUrl();
173+
$fields = $monetico->getFields($cancel);
131174

132175
$client = new GuzzleHttp\Client();
133176
$data = $client->request('POST', $url, $fields);
134177

135178
// $data = json_decode($data, true);
136179

137-
$response = new Response($data);
180+
$response = new CancelResponse($data);
138181
```
139182

140183
### Refund
141184

142185
```php
143-
use DansMaCulotte\Monetico\Refund\Refund;
144-
use DansMaCulotte\Monetico\Refund\Response;
186+
use DansMaCulotte\Monetico\Monetico;
187+
use DansMaCulotte\Monetico\Requests\RefundRequest;
188+
use DansMaCulotte\Monetico\Responses\RefundResponse;
189+
190+
$monetico = new Monetico(
191+
'EPT_CODE',
192+
'SECURITY_KEY',
193+
'COMPANY_CODE'
194+
);
145195

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),
196+
$refund = new RefundRequest([
197+
'datetime' => new DateTime(),
198+
'orderDatetime' => new DateTime(),
199+
'recoveryDatetime' => new DateTime(),
150200
'authorizationNumber' => '1222',
151201
'reference' => 'ABC123',
152202
'language' => 'FR',
@@ -156,16 +206,16 @@ $refund = new Refund([
156206
'maxRefundAmount' => 80,
157207
]);
158208

159-
$url = $monetico->getRefundUrl();
160-
$fields = $monetico->getRefundFields($recovery);
209+
$url = RefundRequest::getUrl();
210+
$fields = $monetico->getFields($refund);
161211

162212
$client = new GuzzleHttp\Client();
163213
$data = $client->request('POST', $url, $fields);
164214

165215
// $data = json_decode($data, true);
166216

167-
$response = new Response($data);
217+
$response = new RefundResponse($data);
168218
```
169219
## License
170220

171-
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
221+
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

composer.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "dansmaculotte/monetico-php",
33
"description": "PHP SDK for Monetico Payment Service",
4+
"version": "2.0.0-beta.3",
45
"type": "library",
56
"license": "MIT",
67
"keywords": [
@@ -27,14 +28,13 @@
2728
"ext-json": "*"
2829
},
2930
"require-dev": {
30-
"phpunit/phpunit": "^8.3",
31-
"nesbot/carbon": "^2.23",
32-
"friendsofphp/php-cs-fixer": "^2.15",
33-
"brainmaestro/composer-git-hooks": "^2.7"
31+
"phpunit/phpunit": "^8.4",
32+
"nesbot/carbon": "^2.27",
33+
"friendsofphp/php-cs-fixer": "^2.16"
3434
},
3535
"scripts": {
36-
"test": "@php vendor/bin/phpunit",
37-
"coverage": "@php vendor/bin/phpunit --coverage-html coverage",
36+
"test": "@php vendor/bin/phpunit --colors=always",
37+
"test-coverage": "@php vendor/bin/phpunit --coverage-html coverage",
3838
"format": "@php vendor/bin/php-cs-fixer fix --config .php_cs.php"
3939
},
4040
"extra": {

0 commit comments

Comments
 (0)