Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes from gocardless/gocardless-pro-php-template #195

Merged
merged 9 commits into from
Dec 3, 2024
Merged
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gocardless/gocardless-pro",
"description": "GoCardless Pro PHP Client Library",
"version": "6.0.0",
"version": "6.1.0",
"keywords": [
"gocardless",
"direct debit",
Expand Down
4 changes: 2 additions & 2 deletions lib/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct($config)
'Content-Type' => 'application/json',
'Authorization' => "Bearer " . $access_token,
'GoCardless-Client-Library' => 'gocardless-pro-php',
'GoCardless-Client-Version' => '6.0.0',
'GoCardless-Client-Version' => '6.1.0',
'User-Agent' => $this->getUserAgent()
),
'http_errors' => false,
Expand Down Expand Up @@ -664,7 +664,7 @@ private function getUserAgent()
{
$curlinfo = curl_version();
$uagent = array();
$uagent[] = 'gocardless-pro-php/6.0.0';
$uagent[] = 'gocardless-pro-php/6.1.0';
$uagent[] = 'schema-version/2015-07-06';
if (defined('\GuzzleHttp\Client::MAJOR_VERSION')) {
$uagent[] = 'GuzzleHttp/' . \GuzzleHttp\Client::MAJOR_VERSION;
Expand Down
12 changes: 12 additions & 0 deletions lib/Resources/BillingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
* @property-read mixed $actions
* @property-read mixed $created_at
* @property-read mixed $fallback_enabled
* @property-read mixed $fallback_occurred
* @property-read mixed $id
* @property-read mixed $instalment_schedule_request
* @property-read mixed $links
* @property-read mixed $mandate_request
* @property-read mixed $metadata
Expand Down Expand Up @@ -51,11 +53,21 @@ class BillingRequest extends BaseResource
*/
protected $fallback_enabled;

/**
* True if the billing request was completed with direct debit.
*/
protected $fallback_occurred;

/**
* Unique identifier, beginning with "BRQ".
*/
protected $id;

/**
* Request for an instalment schedule
*/
protected $instalment_schedule_request;

/**
*
*/
Expand Down
8 changes: 8 additions & 0 deletions lib/Resources/BillingRequestFlow.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* @property-read mixed $session_token
* @property-read mixed $show_redirect_buttons
* @property-read mixed $show_success_redirect_button
* @property-read mixed $skip_success_screen
*/
class BillingRequestFlow extends BaseResource
{
Expand Down Expand Up @@ -159,4 +160,11 @@ class BillingRequestFlow extends BaseResource
*/
protected $show_success_redirect_button;

/**
* If true, the payer will not be redirected to the success screen after
* completing the flow. A redirect_uri needs to be provided for this
* parameter to be taken into account.
*/
protected $skip_success_screen;

}
2 changes: 2 additions & 0 deletions tests/Integration/BillingRequestFlowsIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function testBillingRequestFlowsCreate()
$this->assertEquals($body->session_token, $response->session_token);
$this->assertEquals($body->show_redirect_buttons, $response->show_redirect_buttons);
$this->assertEquals($body->show_success_redirect_button, $response->show_success_redirect_button);
$this->assertEquals($body->skip_success_screen, $response->skip_success_screen);


$expectedPathRegex = $this->extract_resource_fixture_path_regex($fixture);
Expand Down Expand Up @@ -82,6 +83,7 @@ public function testBillingRequestFlowsInitialise()
$this->assertEquals($body->session_token, $response->session_token);
$this->assertEquals($body->show_redirect_buttons, $response->show_redirect_buttons);
$this->assertEquals($body->show_success_redirect_button, $response->show_success_redirect_button);
$this->assertEquals($body->skip_success_screen, $response->skip_success_screen);


$expectedPathRegex = $this->extract_resource_fixture_path_regex($fixture);
Expand Down
32 changes: 32 additions & 0 deletions tests/Integration/BillingRequestsIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public function testBillingRequestsCreate()
$this->assertEquals($body->actions, $response->actions);
$this->assertEquals($body->created_at, $response->created_at);
$this->assertEquals($body->fallback_enabled, $response->fallback_enabled);
$this->assertEquals($body->fallback_occurred, $response->fallback_occurred);
$this->assertEquals($body->id, $response->id);
$this->assertEquals($body->instalment_schedule_request, $response->instalment_schedule_request);
$this->assertEquals($body->links, $response->links);
$this->assertEquals($body->mandate_request, $response->mandate_request);
$this->assertEquals($body->metadata, $response->metadata);
Expand Down Expand Up @@ -68,7 +70,9 @@ public function testBillingRequestsCreateWithIdempotencyConflict()
$this->assertEquals($body->actions, $response->actions);
$this->assertEquals($body->created_at, $response->created_at);
$this->assertEquals($body->fallback_enabled, $response->fallback_enabled);
$this->assertEquals($body->fallback_occurred, $response->fallback_occurred);
$this->assertEquals($body->id, $response->id);
$this->assertEquals($body->instalment_schedule_request, $response->instalment_schedule_request);
$this->assertEquals($body->links, $response->links);
$this->assertEquals($body->mandate_request, $response->mandate_request);
$this->assertEquals($body->metadata, $response->metadata);
Expand Down Expand Up @@ -101,7 +105,9 @@ public function testBillingRequestsCollectCustomerDetails()
$this->assertEquals($body->actions, $response->actions);
$this->assertEquals($body->created_at, $response->created_at);
$this->assertEquals($body->fallback_enabled, $response->fallback_enabled);
$this->assertEquals($body->fallback_occurred, $response->fallback_occurred);
$this->assertEquals($body->id, $response->id);
$this->assertEquals($body->instalment_schedule_request, $response->instalment_schedule_request);
$this->assertEquals($body->links, $response->links);
$this->assertEquals($body->mandate_request, $response->mandate_request);
$this->assertEquals($body->metadata, $response->metadata);
Expand Down Expand Up @@ -133,7 +139,9 @@ public function testBillingRequestsCollectBankAccount()
$this->assertEquals($body->actions, $response->actions);
$this->assertEquals($body->created_at, $response->created_at);
$this->assertEquals($body->fallback_enabled, $response->fallback_enabled);
$this->assertEquals($body->fallback_occurred, $response->fallback_occurred);
$this->assertEquals($body->id, $response->id);
$this->assertEquals($body->instalment_schedule_request, $response->instalment_schedule_request);
$this->assertEquals($body->links, $response->links);
$this->assertEquals($body->mandate_request, $response->mandate_request);
$this->assertEquals($body->metadata, $response->metadata);
Expand Down Expand Up @@ -165,7 +173,9 @@ public function testBillingRequestsConfirmPayerDetails()
$this->assertEquals($body->actions, $response->actions);
$this->assertEquals($body->created_at, $response->created_at);
$this->assertEquals($body->fallback_enabled, $response->fallback_enabled);
$this->assertEquals($body->fallback_occurred, $response->fallback_occurred);
$this->assertEquals($body->id, $response->id);
$this->assertEquals($body->instalment_schedule_request, $response->instalment_schedule_request);
$this->assertEquals($body->links, $response->links);
$this->assertEquals($body->mandate_request, $response->mandate_request);
$this->assertEquals($body->metadata, $response->metadata);
Expand Down Expand Up @@ -197,7 +207,9 @@ public function testBillingRequestsFulfil()
$this->assertEquals($body->actions, $response->actions);
$this->assertEquals($body->created_at, $response->created_at);
$this->assertEquals($body->fallback_enabled, $response->fallback_enabled);
$this->assertEquals($body->fallback_occurred, $response->fallback_occurred);
$this->assertEquals($body->id, $response->id);
$this->assertEquals($body->instalment_schedule_request, $response->instalment_schedule_request);
$this->assertEquals($body->links, $response->links);
$this->assertEquals($body->mandate_request, $response->mandate_request);
$this->assertEquals($body->metadata, $response->metadata);
Expand Down Expand Up @@ -229,7 +241,9 @@ public function testBillingRequestsCancel()
$this->assertEquals($body->actions, $response->actions);
$this->assertEquals($body->created_at, $response->created_at);
$this->assertEquals($body->fallback_enabled, $response->fallback_enabled);
$this->assertEquals($body->fallback_occurred, $response->fallback_occurred);
$this->assertEquals($body->id, $response->id);
$this->assertEquals($body->instalment_schedule_request, $response->instalment_schedule_request);
$this->assertEquals($body->links, $response->links);
$this->assertEquals($body->mandate_request, $response->mandate_request);
$this->assertEquals($body->metadata, $response->metadata);
Expand Down Expand Up @@ -281,10 +295,18 @@ public function testBillingRequestsList()
$this->assertEquals($body[$num]->fallback_enabled, $record->fallback_enabled);
}

if (isset($body[$num]->fallback_occurred)) {
$this->assertEquals($body[$num]->fallback_occurred, $record->fallback_occurred);
}

if (isset($body[$num]->id)) {
$this->assertEquals($body[$num]->id, $record->id);
}

if (isset($body[$num]->instalment_schedule_request)) {
$this->assertEquals($body[$num]->instalment_schedule_request, $record->instalment_schedule_request);
}

if (isset($body[$num]->links)) {
$this->assertEquals($body[$num]->links, $record->links);
}
Expand Down Expand Up @@ -340,7 +362,9 @@ public function testBillingRequestsGet()
$this->assertEquals($body->actions, $response->actions);
$this->assertEquals($body->created_at, $response->created_at);
$this->assertEquals($body->fallback_enabled, $response->fallback_enabled);
$this->assertEquals($body->fallback_occurred, $response->fallback_occurred);
$this->assertEquals($body->id, $response->id);
$this->assertEquals($body->instalment_schedule_request, $response->instalment_schedule_request);
$this->assertEquals($body->links, $response->links);
$this->assertEquals($body->mandate_request, $response->mandate_request);
$this->assertEquals($body->metadata, $response->metadata);
Expand Down Expand Up @@ -372,7 +396,9 @@ public function testBillingRequestsNotify()
$this->assertEquals($body->actions, $response->actions);
$this->assertEquals($body->created_at, $response->created_at);
$this->assertEquals($body->fallback_enabled, $response->fallback_enabled);
$this->assertEquals($body->fallback_occurred, $response->fallback_occurred);
$this->assertEquals($body->id, $response->id);
$this->assertEquals($body->instalment_schedule_request, $response->instalment_schedule_request);
$this->assertEquals($body->links, $response->links);
$this->assertEquals($body->mandate_request, $response->mandate_request);
$this->assertEquals($body->metadata, $response->metadata);
Expand Down Expand Up @@ -404,7 +430,9 @@ public function testBillingRequestsFallback()
$this->assertEquals($body->actions, $response->actions);
$this->assertEquals($body->created_at, $response->created_at);
$this->assertEquals($body->fallback_enabled, $response->fallback_enabled);
$this->assertEquals($body->fallback_occurred, $response->fallback_occurred);
$this->assertEquals($body->id, $response->id);
$this->assertEquals($body->instalment_schedule_request, $response->instalment_schedule_request);
$this->assertEquals($body->links, $response->links);
$this->assertEquals($body->mandate_request, $response->mandate_request);
$this->assertEquals($body->metadata, $response->metadata);
Expand Down Expand Up @@ -436,7 +464,9 @@ public function testBillingRequestsChooseCurrency()
$this->assertEquals($body->actions, $response->actions);
$this->assertEquals($body->created_at, $response->created_at);
$this->assertEquals($body->fallback_enabled, $response->fallback_enabled);
$this->assertEquals($body->fallback_occurred, $response->fallback_occurred);
$this->assertEquals($body->id, $response->id);
$this->assertEquals($body->instalment_schedule_request, $response->instalment_schedule_request);
$this->assertEquals($body->links, $response->links);
$this->assertEquals($body->mandate_request, $response->mandate_request);
$this->assertEquals($body->metadata, $response->metadata);
Expand Down Expand Up @@ -468,7 +498,9 @@ public function testBillingRequestsSelectInstitution()
$this->assertEquals($body->actions, $response->actions);
$this->assertEquals($body->created_at, $response->created_at);
$this->assertEquals($body->fallback_enabled, $response->fallback_enabled);
$this->assertEquals($body->fallback_occurred, $response->fallback_occurred);
$this->assertEquals($body->id, $response->id);
$this->assertEquals($body->instalment_schedule_request, $response->instalment_schedule_request);
$this->assertEquals($body->links, $response->links);
$this->assertEquals($body->mandate_request, $response->mandate_request);
$this->assertEquals($body->metadata, $response->metadata);
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/bank_authorisations.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"method": "POST",
"path_template": "/bank_authorisations",
"url_params": {},
"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"}}
"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"}}
},
"get": {
"method": "GET",
"path_template": "/bank_authorisations/:identity",
"url_params": {"identity": "BAU123"},
"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"}}
"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"}}
}
}

4 changes: 2 additions & 2 deletions tests/fixtures/billing_request_flows.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"method": "POST",
"path_template": "/billing_request_flows",
"url_params": {},
"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}}
"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}}
},
"initialise": {
"method": "POST",
"path_template": "/billing_request_flows/:identity/actions/initialise",
"url_params": {"identity": "BRF123"},
"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}}
"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}}
}
}

Loading
Loading