Skip to content

Commit aa05f91

Browse files
authored
Merge pull request #195 from gocardless/template-changes
Changes from gocardless/gocardless-pro-php-template
2 parents 2644a71 + 8d1a9d2 commit aa05f91

36 files changed

+142
-88
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "gocardless/gocardless-pro",
33
"description": "GoCardless Pro PHP Client Library",
4-
"version": "6.0.0",
4+
"version": "6.1.0",
55
"keywords": [
66
"gocardless",
77
"direct debit",

lib/Client.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function __construct($config)
5858
'Content-Type' => 'application/json',
5959
'Authorization' => "Bearer " . $access_token,
6060
'GoCardless-Client-Library' => 'gocardless-pro-php',
61-
'GoCardless-Client-Version' => '6.0.0',
61+
'GoCardless-Client-Version' => '6.1.0',
6262
'User-Agent' => $this->getUserAgent()
6363
),
6464
'http_errors' => false,
@@ -664,7 +664,7 @@ private function getUserAgent()
664664
{
665665
$curlinfo = curl_version();
666666
$uagent = array();
667-
$uagent[] = 'gocardless-pro-php/6.0.0';
667+
$uagent[] = 'gocardless-pro-php/6.1.0';
668668
$uagent[] = 'schema-version/2015-07-06';
669669
if (defined('\GuzzleHttp\Client::MAJOR_VERSION')) {
670670
$uagent[] = 'GuzzleHttp/' . \GuzzleHttp\Client::MAJOR_VERSION;

lib/Resources/BillingRequest.php

+12
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
* @property-read mixed $actions
1515
* @property-read mixed $created_at
1616
* @property-read mixed $fallback_enabled
17+
* @property-read mixed $fallback_occurred
1718
* @property-read mixed $id
19+
* @property-read mixed $instalment_schedule_request
1820
* @property-read mixed $links
1921
* @property-read mixed $mandate_request
2022
* @property-read mixed $metadata
@@ -51,11 +53,21 @@ class BillingRequest extends BaseResource
5153
*/
5254
protected $fallback_enabled;
5355

56+
/**
57+
* True if the billing request was completed with direct debit.
58+
*/
59+
protected $fallback_occurred;
60+
5461
/**
5562
* Unique identifier, beginning with "BRQ".
5663
*/
5764
protected $id;
5865

66+
/**
67+
* Request for an instalment schedule
68+
*/
69+
protected $instalment_schedule_request;
70+
5971
/**
6072
*
6173
*/

lib/Resources/BillingRequestFlow.php

+8
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
* @property-read mixed $session_token
3030
* @property-read mixed $show_redirect_buttons
3131
* @property-read mixed $show_success_redirect_button
32+
* @property-read mixed $skip_success_screen
3233
*/
3334
class BillingRequestFlow extends BaseResource
3435
{
@@ -159,4 +160,11 @@ class BillingRequestFlow extends BaseResource
159160
*/
160161
protected $show_success_redirect_button;
161162

163+
/**
164+
* If true, the payer will not be redirected to the success screen after
165+
* completing the flow. A redirect_uri needs to be provided for this
166+
* parameter to be taken into account.
167+
*/
168+
protected $skip_success_screen;
169+
162170
}

tests/Integration/BillingRequestFlowsIntegrationTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public function testBillingRequestFlowsCreate()
4444
$this->assertEquals($body->session_token, $response->session_token);
4545
$this->assertEquals($body->show_redirect_buttons, $response->show_redirect_buttons);
4646
$this->assertEquals($body->show_success_redirect_button, $response->show_success_redirect_button);
47+
$this->assertEquals($body->skip_success_screen, $response->skip_success_screen);
4748

4849

4950
$expectedPathRegex = $this->extract_resource_fixture_path_regex($fixture);
@@ -82,6 +83,7 @@ public function testBillingRequestFlowsInitialise()
8283
$this->assertEquals($body->session_token, $response->session_token);
8384
$this->assertEquals($body->show_redirect_buttons, $response->show_redirect_buttons);
8485
$this->assertEquals($body->show_success_redirect_button, $response->show_success_redirect_button);
86+
$this->assertEquals($body->skip_success_screen, $response->skip_success_screen);
8587

8688

8789
$expectedPathRegex = $this->extract_resource_fixture_path_regex($fixture);

tests/Integration/BillingRequestsIntegrationTest.php

+32
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ public function testBillingRequestsCreate()
2929
$this->assertEquals($body->actions, $response->actions);
3030
$this->assertEquals($body->created_at, $response->created_at);
3131
$this->assertEquals($body->fallback_enabled, $response->fallback_enabled);
32+
$this->assertEquals($body->fallback_occurred, $response->fallback_occurred);
3233
$this->assertEquals($body->id, $response->id);
34+
$this->assertEquals($body->instalment_schedule_request, $response->instalment_schedule_request);
3335
$this->assertEquals($body->links, $response->links);
3436
$this->assertEquals($body->mandate_request, $response->mandate_request);
3537
$this->assertEquals($body->metadata, $response->metadata);
@@ -68,7 +70,9 @@ public function testBillingRequestsCreateWithIdempotencyConflict()
6870
$this->assertEquals($body->actions, $response->actions);
6971
$this->assertEquals($body->created_at, $response->created_at);
7072
$this->assertEquals($body->fallback_enabled, $response->fallback_enabled);
73+
$this->assertEquals($body->fallback_occurred, $response->fallback_occurred);
7174
$this->assertEquals($body->id, $response->id);
75+
$this->assertEquals($body->instalment_schedule_request, $response->instalment_schedule_request);
7276
$this->assertEquals($body->links, $response->links);
7377
$this->assertEquals($body->mandate_request, $response->mandate_request);
7478
$this->assertEquals($body->metadata, $response->metadata);
@@ -101,7 +105,9 @@ public function testBillingRequestsCollectCustomerDetails()
101105
$this->assertEquals($body->actions, $response->actions);
102106
$this->assertEquals($body->created_at, $response->created_at);
103107
$this->assertEquals($body->fallback_enabled, $response->fallback_enabled);
108+
$this->assertEquals($body->fallback_occurred, $response->fallback_occurred);
104109
$this->assertEquals($body->id, $response->id);
110+
$this->assertEquals($body->instalment_schedule_request, $response->instalment_schedule_request);
105111
$this->assertEquals($body->links, $response->links);
106112
$this->assertEquals($body->mandate_request, $response->mandate_request);
107113
$this->assertEquals($body->metadata, $response->metadata);
@@ -133,7 +139,9 @@ public function testBillingRequestsCollectBankAccount()
133139
$this->assertEquals($body->actions, $response->actions);
134140
$this->assertEquals($body->created_at, $response->created_at);
135141
$this->assertEquals($body->fallback_enabled, $response->fallback_enabled);
142+
$this->assertEquals($body->fallback_occurred, $response->fallback_occurred);
136143
$this->assertEquals($body->id, $response->id);
144+
$this->assertEquals($body->instalment_schedule_request, $response->instalment_schedule_request);
137145
$this->assertEquals($body->links, $response->links);
138146
$this->assertEquals($body->mandate_request, $response->mandate_request);
139147
$this->assertEquals($body->metadata, $response->metadata);
@@ -165,7 +173,9 @@ public function testBillingRequestsConfirmPayerDetails()
165173
$this->assertEquals($body->actions, $response->actions);
166174
$this->assertEquals($body->created_at, $response->created_at);
167175
$this->assertEquals($body->fallback_enabled, $response->fallback_enabled);
176+
$this->assertEquals($body->fallback_occurred, $response->fallback_occurred);
168177
$this->assertEquals($body->id, $response->id);
178+
$this->assertEquals($body->instalment_schedule_request, $response->instalment_schedule_request);
169179
$this->assertEquals($body->links, $response->links);
170180
$this->assertEquals($body->mandate_request, $response->mandate_request);
171181
$this->assertEquals($body->metadata, $response->metadata);
@@ -197,7 +207,9 @@ public function testBillingRequestsFulfil()
197207
$this->assertEquals($body->actions, $response->actions);
198208
$this->assertEquals($body->created_at, $response->created_at);
199209
$this->assertEquals($body->fallback_enabled, $response->fallback_enabled);
210+
$this->assertEquals($body->fallback_occurred, $response->fallback_occurred);
200211
$this->assertEquals($body->id, $response->id);
212+
$this->assertEquals($body->instalment_schedule_request, $response->instalment_schedule_request);
201213
$this->assertEquals($body->links, $response->links);
202214
$this->assertEquals($body->mandate_request, $response->mandate_request);
203215
$this->assertEquals($body->metadata, $response->metadata);
@@ -229,7 +241,9 @@ public function testBillingRequestsCancel()
229241
$this->assertEquals($body->actions, $response->actions);
230242
$this->assertEquals($body->created_at, $response->created_at);
231243
$this->assertEquals($body->fallback_enabled, $response->fallback_enabled);
244+
$this->assertEquals($body->fallback_occurred, $response->fallback_occurred);
232245
$this->assertEquals($body->id, $response->id);
246+
$this->assertEquals($body->instalment_schedule_request, $response->instalment_schedule_request);
233247
$this->assertEquals($body->links, $response->links);
234248
$this->assertEquals($body->mandate_request, $response->mandate_request);
235249
$this->assertEquals($body->metadata, $response->metadata);
@@ -281,10 +295,18 @@ public function testBillingRequestsList()
281295
$this->assertEquals($body[$num]->fallback_enabled, $record->fallback_enabled);
282296
}
283297

298+
if (isset($body[$num]->fallback_occurred)) {
299+
$this->assertEquals($body[$num]->fallback_occurred, $record->fallback_occurred);
300+
}
301+
284302
if (isset($body[$num]->id)) {
285303
$this->assertEquals($body[$num]->id, $record->id);
286304
}
287305

306+
if (isset($body[$num]->instalment_schedule_request)) {
307+
$this->assertEquals($body[$num]->instalment_schedule_request, $record->instalment_schedule_request);
308+
}
309+
288310
if (isset($body[$num]->links)) {
289311
$this->assertEquals($body[$num]->links, $record->links);
290312
}
@@ -340,7 +362,9 @@ public function testBillingRequestsGet()
340362
$this->assertEquals($body->actions, $response->actions);
341363
$this->assertEquals($body->created_at, $response->created_at);
342364
$this->assertEquals($body->fallback_enabled, $response->fallback_enabled);
365+
$this->assertEquals($body->fallback_occurred, $response->fallback_occurred);
343366
$this->assertEquals($body->id, $response->id);
367+
$this->assertEquals($body->instalment_schedule_request, $response->instalment_schedule_request);
344368
$this->assertEquals($body->links, $response->links);
345369
$this->assertEquals($body->mandate_request, $response->mandate_request);
346370
$this->assertEquals($body->metadata, $response->metadata);
@@ -372,7 +396,9 @@ public function testBillingRequestsNotify()
372396
$this->assertEquals($body->actions, $response->actions);
373397
$this->assertEquals($body->created_at, $response->created_at);
374398
$this->assertEquals($body->fallback_enabled, $response->fallback_enabled);
399+
$this->assertEquals($body->fallback_occurred, $response->fallback_occurred);
375400
$this->assertEquals($body->id, $response->id);
401+
$this->assertEquals($body->instalment_schedule_request, $response->instalment_schedule_request);
376402
$this->assertEquals($body->links, $response->links);
377403
$this->assertEquals($body->mandate_request, $response->mandate_request);
378404
$this->assertEquals($body->metadata, $response->metadata);
@@ -404,7 +430,9 @@ public function testBillingRequestsFallback()
404430
$this->assertEquals($body->actions, $response->actions);
405431
$this->assertEquals($body->created_at, $response->created_at);
406432
$this->assertEquals($body->fallback_enabled, $response->fallback_enabled);
433+
$this->assertEquals($body->fallback_occurred, $response->fallback_occurred);
407434
$this->assertEquals($body->id, $response->id);
435+
$this->assertEquals($body->instalment_schedule_request, $response->instalment_schedule_request);
408436
$this->assertEquals($body->links, $response->links);
409437
$this->assertEquals($body->mandate_request, $response->mandate_request);
410438
$this->assertEquals($body->metadata, $response->metadata);
@@ -436,7 +464,9 @@ public function testBillingRequestsChooseCurrency()
436464
$this->assertEquals($body->actions, $response->actions);
437465
$this->assertEquals($body->created_at, $response->created_at);
438466
$this->assertEquals($body->fallback_enabled, $response->fallback_enabled);
467+
$this->assertEquals($body->fallback_occurred, $response->fallback_occurred);
439468
$this->assertEquals($body->id, $response->id);
469+
$this->assertEquals($body->instalment_schedule_request, $response->instalment_schedule_request);
440470
$this->assertEquals($body->links, $response->links);
441471
$this->assertEquals($body->mandate_request, $response->mandate_request);
442472
$this->assertEquals($body->metadata, $response->metadata);
@@ -468,7 +498,9 @@ public function testBillingRequestsSelectInstitution()
468498
$this->assertEquals($body->actions, $response->actions);
469499
$this->assertEquals($body->created_at, $response->created_at);
470500
$this->assertEquals($body->fallback_enabled, $response->fallback_enabled);
501+
$this->assertEquals($body->fallback_occurred, $response->fallback_occurred);
471502
$this->assertEquals($body->id, $response->id);
503+
$this->assertEquals($body->instalment_schedule_request, $response->instalment_schedule_request);
472504
$this->assertEquals($body->links, $response->links);
473505
$this->assertEquals($body->mandate_request, $response->mandate_request);
474506
$this->assertEquals($body->metadata, $response->metadata);

tests/fixtures/bank_authorisations.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
"method": "POST",
44
"path_template": "/bank_authorisations",
55
"url_params": {},
6-
"body": {"bank_authorisations":{"authorisation_type":"example authorisation_type 8081","authorised_at":"2020-01-01T12:00:00.000Z","created_at":"2024-09-24T11:43:14.975Z","expires_at":"2024-09-24T11:43:14.975Z","id":"BAU123","last_visited_at":"2020-01-01T12:00:00.000Z","links":{"billing_request":"BRQ123","institution":"monzo"},"qr_code_url":"https://pay.gocardless.com/obauth/BAU123/qr_code","redirect_uri":"https://my-website.com/abc/callback","url":"https://pay.gocardless.com/obauth/BAU123"}}
6+
"body": {"bank_authorisations":{"authorisation_type":"example authorisation_type 8081","authorised_at":"2020-01-01T12:00:00.000Z","created_at":"2024-12-02T16:42:36.882Z","expires_at":"2024-12-02T16:42:36.882Z","id":"BAU123","last_visited_at":"2020-01-01T12:00:00.000Z","links":{"billing_request":"BRQ123","institution":"monzo"},"qr_code_url":"https://pay.gocardless.com/obauth/BAU123/qr_code","redirect_uri":"https://my-website.com/abc/callback","url":"https://pay.gocardless.com/obauth/BAU123"}}
77
},
88
"get": {
99
"method": "GET",
1010
"path_template": "/bank_authorisations/:identity",
1111
"url_params": {"identity": "BAU123"},
12-
"body": {"bank_authorisations":{"authorisation_type":"example authorisation_type 7887","authorised_at":"2020-01-01T12:00:00.000Z","created_at":"2024-09-24T11:43:14.975Z","expires_at":"2024-09-24T11:43:14.975Z","id":"BAU123","last_visited_at":"2020-01-01T12:00:00.000Z","links":{"billing_request":"BRQ123","institution":"monzo"},"qr_code_url":"https://pay.gocardless.com/obauth/BAU123/qr_code","redirect_uri":"https://my-website.com/abc/callback","url":"https://pay.gocardless.com/obauth/BAU123"}}
12+
"body": {"bank_authorisations":{"authorisation_type":"example authorisation_type 7887","authorised_at":"2020-01-01T12:00:00.000Z","created_at":"2024-12-02T16:42:36.882Z","expires_at":"2024-12-02T16:42:36.882Z","id":"BAU123","last_visited_at":"2020-01-01T12:00:00.000Z","links":{"billing_request":"BRQ123","institution":"monzo"},"qr_code_url":"https://pay.gocardless.com/obauth/BAU123/qr_code","redirect_uri":"https://my-website.com/abc/callback","url":"https://pay.gocardless.com/obauth/BAU123"}}
1313
}
1414
}
1515

tests/fixtures/billing_request_flows.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
"method": "POST",
44
"path_template": "/billing_request_flows",
55
"url_params": {},
6-
"body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":true,"created_at":"2024-09-24T11:43:14.978Z","customer_details_captured":true,"exit_uri":"https://my-website.com/abc/callback","expires_at":"2024-09-24T11:43:14.978Z","id":"BRF123","language":"en","links":{"billing_request":"BRQ123"},"lock_bank_account":true,"lock_currency":false,"lock_customer_details":false,"prefilled_bank_account":{"account_type":"savings"},"prefilled_customer":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","danish_identity_number":"220550-6218","email":"[email protected]","family_name":"Osborne","given_name":"Frank","postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},"redirect_uri":"https://my-website.com/abc/callback","session_token":"sesh_123","show_redirect_buttons":false,"show_success_redirect_button":true}}
6+
"body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":false,"created_at":"2024-12-02T16:42:36.887Z","customer_details_captured":true,"exit_uri":"https://my-website.com/abc/callback","expires_at":"2024-12-02T16:42:36.887Z","id":"BRF123","language":"en","links":{"billing_request":"BRQ123"},"lock_bank_account":false,"lock_currency":true,"lock_customer_details":true,"prefilled_bank_account":{"account_type":"savings"},"prefilled_customer":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","danish_identity_number":"220550-6218","email":"[email protected]","family_name":"Osborne","given_name":"Frank","postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},"redirect_uri":"https://my-website.com/abc/callback","session_token":"sesh_123","show_redirect_buttons":true,"show_success_redirect_button":false,"skip_success_screen":false}}
77
},
88
"initialise": {
99
"method": "POST",
1010
"path_template": "/billing_request_flows/:identity/actions/initialise",
1111
"url_params": {"identity": "BRF123"},
12-
"body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":false,"created_at":"2024-09-24T11:43:14.979Z","customer_details_captured":false,"exit_uri":"https://my-website.com/abc/callback","expires_at":"2024-09-24T11:43:14.979Z","id":"BRF123","language":"en","links":{"billing_request":"BRQ123"},"lock_bank_account":false,"lock_currency":true,"lock_customer_details":false,"prefilled_bank_account":{"account_type":"savings"},"prefilled_customer":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","danish_identity_number":"220550-6218","email":"[email protected]","family_name":"Osborne","given_name":"Frank","postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},"redirect_uri":"https://my-website.com/abc/callback","session_token":"sesh_123","show_redirect_buttons":true,"show_success_redirect_button":false}}
12+
"body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":false,"created_at":"2024-12-02T16:42:36.887Z","customer_details_captured":false,"exit_uri":"https://my-website.com/abc/callback","expires_at":"2024-12-02T16:42:36.887Z","id":"BRF123","language":"en","links":{"billing_request":"BRQ123"},"lock_bank_account":false,"lock_currency":false,"lock_customer_details":true,"prefilled_bank_account":{"account_type":"savings"},"prefilled_customer":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","danish_identity_number":"220550-6218","email":"[email protected]","family_name":"Osborne","given_name":"Frank","postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},"redirect_uri":"https://my-website.com/abc/callback","session_token":"sesh_123","show_redirect_buttons":true,"show_success_redirect_button":true,"skip_success_screen":true}}
1313
}
1414
}
1515

0 commit comments

Comments
 (0)