Skip to content

Commit

Permalink
Merge pull request #149 from gocardless/template-changes
Browse files Browse the repository at this point in the history
Added `language` parameter to Billing Request Flow creation.
  • Loading branch information
Yusuf B authored Dec 13, 2022
2 parents e12a7d4 + 320305e commit ec767a3
Show file tree
Hide file tree
Showing 25 changed files with 83 additions and 67 deletions.
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": "4.21.0",
"version": "4.22.0",
"keywords": [
"gocardless",
"direct debit",
Expand Down
18 changes: 2 additions & 16 deletions lib/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function __construct($config)
'Content-Type' => 'application/json',
'Authorization' => "Bearer " . $access_token,
'GoCardless-Client-Library' => 'gocardless-pro-php',
'GoCardless-Client-Version' => '4.21.0',
'GoCardless-Client-Version' => '4.22.0',
'User-Agent' => $this->getUserAgent()
),
'http_errors' => false,
Expand Down Expand Up @@ -337,20 +337,6 @@ public function mandatePdfs()
return $this->mandate_pdfs;
}

/**
* Service for interacting with mandate request constraints
*
* @return Services\MandateRequestConstraintsService
*/
public function mandateRequestConstraints()
{
if (!isset($this->mandate_request_constraints)) {
$this->mandate_request_constraints = new Services\MandateRequestConstraintsService($this->api_client);
}

return $this->mandate_request_constraints;
}

/**
* Service for interacting with payer authorisations
*
Expand Down Expand Up @@ -540,7 +526,7 @@ private function getUserAgent()
{
$curlinfo = curl_version();
$uagent = array();
$uagent[] = 'gocardless-pro-php/4.21.0';
$uagent[] = 'gocardless-pro-php/4.22.0';
$uagent[] = 'schema-version/2015-07-06';
if (defined('\GuzzleHttp\Client::MAJOR_VERSION')) {
$uagent[] = 'GuzzleHttp/' . \GuzzleHttp\Client::MAJOR_VERSION;
Expand Down
17 changes: 15 additions & 2 deletions lib/Resources/BillingRequestFlow.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* @property-read $exit_uri
* @property-read $expires_at
* @property-read $id
* @property-read $language
* @property-read $links
* @property-read $lock_bank_account
* @property-read $lock_currency
Expand Down Expand Up @@ -66,6 +67,12 @@ class BillingRequestFlow extends BaseResource
*/
protected $id;

/**
* Sets the default language of the Billing Request Flow and the customer.
* [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) code.
*/
protected $language;

/**
*
*/
Expand All @@ -74,7 +81,10 @@ class BillingRequestFlow extends BaseResource
/**
* If true, the payer will not be able to change their bank account within
* the flow. If the bank_account details are collected as part of
* bank_authorisation then GC will set this value to true mid flow
* bank_authorisation then GC will set this value to true mid flow.
*
* You can only lock bank account if these have already been completed as a
* part of the billing request.
*/
protected $lock_bank_account;

Expand All @@ -89,7 +99,10 @@ class BillingRequestFlow extends BaseResource
/**
* If true, the payer will not be able to edit their customer details within
* the flow. If the customer details are collected as part of
* bank_authorisation then GC will set this value to true mid flow
* bank_authorisation then GC will set this value to true mid flow.
*
* You can only lock customer details if these have already been completed
* as a part of the billing request.
*/
protected $lock_customer_details;

Expand Down
11 changes: 7 additions & 4 deletions lib/Resources/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class Block extends BaseResource
/**
* Type of entity we will seek to match against when blocking the mandate.
* This
* can currently be one of 'email', 'email_domain', or 'bank_account'.
* can currently be one of 'email', 'email_domain', 'bank_account', or
* 'bank_name'.
*/
protected $block_type;

Expand Down Expand Up @@ -75,9 +76,11 @@ class Block extends BaseResource
* raw value
* (in the case of emails or email domains) or the ID of the resource (in
* the case of
* bank accounts). This means in order to block a specific bank account it
* must already
* have been created as a resource.
* bank accounts and bank names). This means in order to block a specific
* bank account
* (even if you wish to block generically by name) it must already have been
* created as
* a resource.
*/
protected $resource_reference;

Expand Down
7 changes: 7 additions & 0 deletions lib/Resources/Creditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* @property-read $city
* @property-read $country_code
* @property-read $created_at
* @property-read $creditor_type
* @property-read $custom_payment_pages_enabled
* @property-read $fx_payout_currency
* @property-read $id
Expand Down Expand Up @@ -79,6 +80,12 @@ class Creditor extends BaseResource
*/
protected $created_at;

/**
* The type of business of the creditor. Currently, `individual`, `company`,
* `charity`, `partnership`, and `trust` are supported.
*/
protected $creditor_type;

/**
* Boolean value indicating whether creditor has the [Custom Payment
* Pages](https://hub.gocardless.com/s/article/Custom-payment-pages)
Expand Down
2 changes: 2 additions & 0 deletions tests/Integration/BillingRequestFlowsIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function testBillingRequestFlowsCreate()
$this->assertEquals($body->exit_uri, $response->exit_uri);
$this->assertEquals($body->expires_at, $response->expires_at);
$this->assertEquals($body->id, $response->id);
$this->assertEquals($body->language, $response->language);
$this->assertEquals($body->links, $response->links);
$this->assertEquals($body->lock_bank_account, $response->lock_bank_account);
$this->assertEquals($body->lock_currency, $response->lock_currency);
Expand Down Expand Up @@ -67,6 +68,7 @@ public function testBillingRequestFlowsInitialise()
$this->assertEquals($body->exit_uri, $response->exit_uri);
$this->assertEquals($body->expires_at, $response->expires_at);
$this->assertEquals($body->id, $response->id);
$this->assertEquals($body->language, $response->language);
$this->assertEquals($body->links, $response->links);
$this->assertEquals($body->lock_bank_account, $response->lock_bank_account);
$this->assertEquals($body->lock_currency, $response->lock_currency);
Expand Down
5 changes: 5 additions & 0 deletions tests/Integration/CreditorsIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function testCreditorsCreate()
$this->assertEquals($body->city, $response->city);
$this->assertEquals($body->country_code, $response->country_code);
$this->assertEquals($body->created_at, $response->created_at);
$this->assertEquals($body->creditor_type, $response->creditor_type);
$this->assertEquals($body->custom_payment_pages_enabled, $response->custom_payment_pages_enabled);
$this->assertEquals($body->fx_payout_currency, $response->fx_payout_currency);
$this->assertEquals($body->id, $response->id);
Expand Down Expand Up @@ -81,6 +82,7 @@ public function testCreditorsCreateWithIdempotencyConflict()
$this->assertEquals($body->city, $response->city);
$this->assertEquals($body->country_code, $response->country_code);
$this->assertEquals($body->created_at, $response->created_at);
$this->assertEquals($body->creditor_type, $response->creditor_type);
$this->assertEquals($body->custom_payment_pages_enabled, $response->custom_payment_pages_enabled);
$this->assertEquals($body->fx_payout_currency, $response->fx_payout_currency);
$this->assertEquals($body->id, $response->id);
Expand Down Expand Up @@ -131,6 +133,7 @@ public function testCreditorsList()
$this->assertEquals($body[$num]->city, $record->city);
$this->assertEquals($body[$num]->country_code, $record->country_code);
$this->assertEquals($body[$num]->created_at, $record->created_at);
$this->assertEquals($body[$num]->creditor_type, $record->creditor_type);
$this->assertEquals($body[$num]->custom_payment_pages_enabled, $record->custom_payment_pages_enabled);
$this->assertEquals($body[$num]->fx_payout_currency, $record->fx_payout_currency);
$this->assertEquals($body[$num]->id, $record->id);
Expand Down Expand Up @@ -172,6 +175,7 @@ public function testCreditorsGet()
$this->assertEquals($body->city, $response->city);
$this->assertEquals($body->country_code, $response->country_code);
$this->assertEquals($body->created_at, $response->created_at);
$this->assertEquals($body->creditor_type, $response->creditor_type);
$this->assertEquals($body->custom_payment_pages_enabled, $response->custom_payment_pages_enabled);
$this->assertEquals($body->fx_payout_currency, $response->fx_payout_currency);
$this->assertEquals($body->id, $response->id);
Expand Down Expand Up @@ -212,6 +216,7 @@ public function testCreditorsUpdate()
$this->assertEquals($body->city, $response->city);
$this->assertEquals($body->country_code, $response->country_code);
$this->assertEquals($body->created_at, $response->created_at);
$this->assertEquals($body->creditor_type, $response->creditor_type);
$this->assertEquals($body->custom_payment_pages_enabled, $response->custom_payment_pages_enabled);
$this->assertEquals($body->fx_payout_currency, $response->fx_payout_currency);
$this->assertEquals($body->id, $response->id);
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": "GET",
"path_template": "/bank_authorisations/:identity",
"url_params": {"identity": "BAU123"},
"body": {"bank_authorisations":{"authorisation_type":"example authorisation_type 8081","authorised_at":"2020-01-01T12:00:00.000Z","created_at":"2022-11-30T10:49:55.389Z","expires_at":"2022-11-30T10:49:55.389Z","id":"BAU123","last_visited_at":"2020-01-01T12:00:00.000Z","links":{"billing_request":"BRQ123","institution":"monzo"},"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":"2022-12-13T13:34:21.692Z","expires_at":"2022-12-13T13:34:21.692Z","id":"BAU123","last_visited_at":"2020-01-01T12:00:00.000Z","links":{"billing_request":"BRQ123","institution":"monzo"},"redirect_uri":"https://my-website.com/abc/callback","url":"https://pay.gocardless.com/obauth/BAU123"}}
},
"create": {
"method": "POST",
"path_template": "/bank_authorisations",
"url_params": {},
"body": {"bank_authorisations":{"authorisation_type":"example authorisation_type 7887","authorised_at":"2020-01-01T12:00:00.000Z","created_at":"2022-11-30T10:49:55.389Z","expires_at":"2022-11-30T10:49:55.389Z","id":"BAU123","last_visited_at":"2020-01-01T12:00:00.000Z","links":{"billing_request":"BRQ123","institution":"monzo"},"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":"2022-12-13T13:34:21.692Z","expires_at":"2022-12-13T13:34:21.692Z","id":"BAU123","last_visited_at":"2020-01-01T12:00:00.000Z","links":{"billing_request":"BRQ123","institution":"monzo"},"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":false,"created_at":"2022-11-30T10:49:55.393Z","exit_uri":"https://my-website.com/abc/callback","expires_at":"2022-11-30T10:49:55.393Z","id":"BRF123","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","language":"en","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}}
"body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":true,"created_at":"2022-12-13T13:34:21.696Z","exit_uri":"https://my-website.com/abc/callback","expires_at":"2022-12-13T13:34:21.696Z","id":"BRF123","language":"en","links":{"billing_request":"BRQ123"},"lock_bank_account":true,"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":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":true,"created_at":"2022-11-30T10:49:55.393Z","exit_uri":"https://my-website.com/abc/callback","expires_at":"2022-11-30T10:49:55.393Z","id":"BRF123","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","language":"en","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}}
"body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":true,"created_at":"2022-12-13T13:34:21.696Z","exit_uri":"https://my-website.com/abc/callback","expires_at":"2022-12-13T13:34:21.696Z","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}}
}
}

2 changes: 1 addition & 1 deletion tests/fixtures/billing_request_templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"method": "GET",
"path_template": "/billing_request_templates",
"url_params": {},
"body": {"billing_request_templates":[{"authorisation_url":"https://pay.gocardless.com/BRT123","created_at":"2021-01-01T12:00:00.000Z","id":"BRT123","mandate_request_currency":"GBP","mandate_request_description":"Top-up Payment","mandate_request_metadata":{},"mandate_request_scheme":"bacs","mandate_request_verify":null,"metadata":{},"name":"12 Month Gold Plan","payment_request_amount":1000,"payment_request_currency":"GBP","payment_request_description":"Top-up Payment","payment_request_metadata":{},"payment_request_scheme":"faster_payments","redirect_uri":"https://my-website.com/abc/callback","updated_at":"2021-01-01T12:00:00.000Z"},{"authorisation_url":"https://pay.gocardless.com/BRT123","created_at":"2021-01-01T12:00:00.000Z","id":"BRT123","mandate_request_currency":"GBP","mandate_request_description":"Top-up Payment","mandate_request_metadata":{},"mandate_request_scheme":"bacs","mandate_request_verify":null,"metadata":{},"name":"12 Month Gold Plan","payment_request_amount":1000,"payment_request_currency":"GBP","payment_request_description":"Top-up Payment","payment_request_metadata":{},"payment_request_scheme":"faster_payments","redirect_uri":"https://my-website.com/abc/callback","updated_at":"2021-01-01T12:00:00.000Z"}],"meta":{"cursors":{"after":"example after 1464","before":"example before 2954"},"limit":50}}
"body": {"billing_request_templates":[{"authorisation_url":"https://pay.gocardless.com/BRT123","created_at":"2021-01-01T12:00:00.000Z","id":"BRT123","mandate_request_currency":"GBP","mandate_request_description":"Top-up Payment","mandate_request_metadata":{},"mandate_request_scheme":"bacs","mandate_request_verify":null,"metadata":{},"name":"12 Month Gold Plan","payment_request_amount":1000,"payment_request_currency":"GBP","payment_request_description":"Top-up Payment","payment_request_metadata":{},"payment_request_scheme":"faster_payments","redirect_uri":"https://my-website.com/abc/callback","updated_at":"2021-01-01T12:00:00.000Z"},{"authorisation_url":"https://pay.gocardless.com/BRT123","created_at":"2021-01-01T12:00:00.000Z","id":"BRT123","mandate_request_currency":"GBP","mandate_request_description":"Top-up Payment","mandate_request_metadata":{},"mandate_request_scheme":"bacs","mandate_request_verify":null,"metadata":{},"name":"12 Month Gold Plan","payment_request_amount":1000,"payment_request_currency":"GBP","payment_request_description":"Top-up Payment","payment_request_metadata":{},"payment_request_scheme":"faster_payments","redirect_uri":"https://my-website.com/abc/callback","updated_at":"2021-01-01T12:00:00.000Z"}],"meta":{"cursors":{"after":"example after 2954","before":"example before 1464"},"limit":50}}
},
"get": {
"method": "GET",
Expand Down
Loading

0 comments on commit ec767a3

Please sign in to comment.