Skip to content

Commit

Permalink
Merge pull request #151 from gocardless/template-changes
Browse files Browse the repository at this point in the history
Added `authorisation_source` parameter to Mandate API and BR mandate_request API
  • Loading branch information
KarmanLeung authored Dec 21, 2022
2 parents 39c3143 + ab902dd commit e75dc90
Show file tree
Hide file tree
Showing 29 changed files with 94 additions and 72 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.23.0",
"version": "4.24.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 @@ -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.23.0',
'GoCardless-Client-Version' => '4.24.0',
'User-Agent' => $this->getUserAgent()
),
'http_errors' => false,
Expand Down Expand Up @@ -526,7 +526,7 @@ private function getUserAgent()
{
$curlinfo = curl_version();
$uagent = array();
$uagent[] = 'gocardless-pro-php/4.23.0';
$uagent[] = 'gocardless-pro-php/4.24.0';
$uagent[] = 'schema-version/2015-07-06';
if (defined('\GuzzleHttp\Client::MAJOR_VERSION')) {
$uagent[] = 'GuzzleHttp/' . \GuzzleHttp\Client::MAJOR_VERSION;
Expand Down
15 changes: 15 additions & 0 deletions lib/Resources/Mandate.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* A thin wrapper around a mandate, providing access to its
* attributes
*
* @property-read $authorisation_source
* @property-read $consent_parameters
* @property-read $created_at
* @property-read $id
Expand All @@ -26,6 +27,20 @@ class Mandate extends BaseResource
{
protected $model_name = "Mandate";

/**
* This field is ACH specific, sometimes referred to as [SEC
* code](https://www.moderntreasury.com/learn/sec-codes).
*
* This is the way that the payer gives authorisation to the merchant.
* web: Authorisation is Internet Initiated or via Mobile Entry (maps to
* SEC code: WEB)
* telephone: Authorisation is provided orally over telephone (maps to SEC
* code: TEL)
* paper: Authorisation is provided in writing and signed, or similarly
* authenticated (maps to SEC code: PPD)
*/
protected $authorisation_source;

/**
* (Optional) Payto and VRP Scheme specific information
*/
Expand Down
7 changes: 7 additions & 0 deletions tests/Integration/MandatesIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function testMandatesCreate()

$this->assertInstanceOf('\GoCardlessPro\Resources\Mandate', $response);

$this->assertEquals($body->authorisation_source, $response->authorisation_source);
$this->assertEquals($body->consent_parameters, $response->consent_parameters);
$this->assertEquals($body->created_at, $response->created_at);
$this->assertEquals($body->id, $response->id);
Expand Down Expand Up @@ -63,6 +64,7 @@ public function testMandatesCreateWithIdempotencyConflict()

$this->assertInstanceOf('\GoCardlessPro\Resources\Mandate', $response);

$this->assertEquals($body->authorisation_source, $response->authorisation_source);
$this->assertEquals($body->consent_parameters, $response->consent_parameters);
$this->assertEquals($body->created_at, $response->created_at);
$this->assertEquals($body->id, $response->id);
Expand Down Expand Up @@ -103,6 +105,7 @@ public function testMandatesList()

foreach (range(0, count($body) - 1) as $num) {
$record = $records[$num];
$this->assertEquals($body[$num]->authorisation_source, $record->authorisation_source);
$this->assertEquals($body[$num]->consent_parameters, $record->consent_parameters);
$this->assertEquals($body[$num]->created_at, $record->created_at);
$this->assertEquals($body[$num]->id, $record->id);
Expand Down Expand Up @@ -134,6 +137,7 @@ public function testMandatesGet()

$this->assertInstanceOf('\GoCardlessPro\Resources\Mandate', $response);

$this->assertEquals($body->authorisation_source, $response->authorisation_source);
$this->assertEquals($body->consent_parameters, $response->consent_parameters);
$this->assertEquals($body->created_at, $response->created_at);
$this->assertEquals($body->id, $response->id);
Expand Down Expand Up @@ -164,6 +168,7 @@ public function testMandatesUpdate()

$this->assertInstanceOf('\GoCardlessPro\Resources\Mandate', $response);

$this->assertEquals($body->authorisation_source, $response->authorisation_source);
$this->assertEquals($body->consent_parameters, $response->consent_parameters);
$this->assertEquals($body->created_at, $response->created_at);
$this->assertEquals($body->id, $response->id);
Expand Down Expand Up @@ -194,6 +199,7 @@ public function testMandatesCancel()

$this->assertInstanceOf('\GoCardlessPro\Resources\Mandate', $response);

$this->assertEquals($body->authorisation_source, $response->authorisation_source);
$this->assertEquals($body->consent_parameters, $response->consent_parameters);
$this->assertEquals($body->created_at, $response->created_at);
$this->assertEquals($body->id, $response->id);
Expand Down Expand Up @@ -224,6 +230,7 @@ public function testMandatesReinstate()

$this->assertInstanceOf('\GoCardlessPro\Resources\Mandate', $response);

$this->assertEquals($body->authorisation_source, $response->authorisation_source);
$this->assertEquals($body->consent_parameters, $response->consent_parameters);
$this->assertEquals($body->created_at, $response->created_at);
$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-12-19T17:58:08.818Z","expires_at":"2022-12-19T17:58:08.818Z","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-21T16:24:50.725Z","expires_at":"2022-12-21T16:24:50.725Z","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-12-19T17:58:08.819Z","expires_at":"2022-12-19T17:58:08.819Z","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-21T16:24:50.725Z","expires_at":"2022-12-21T16:24:50.725Z","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":true,"created_at":"2022-12-19T17:58:08.824Z","exit_uri":"https://my-website.com/abc/callback","expires_at":"2022-12-19T17:58:08.824Z","id":"BRF123","language":"en","links":{"billing_request":"BRQ123"},"lock_bank_account":true,"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":false}}
"body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":true,"created_at":"2022-12-21T16:24:50.728Z","exit_uri":"https://my-website.com/abc/callback","expires_at":"2022-12-21T16:24:50.728Z","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":true}}
},
"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-12-19T17:58:08.824Z","exit_uri":"https://my-website.com/abc/callback","expires_at":"2022-12-19T17:58:08.824Z","id":"BRF123","language":"en","links":{"billing_request":"BRQ123"},"lock_bank_account":true,"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}}
"body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":false,"created_at":"2022-12-21T16:24:50.728Z","exit_uri":"https://my-website.com/abc/callback","expires_at":"2022-12-21T16:24:50.728Z","id":"BRF123","language":"en","links":{"billing_request":"BRQ123"},"lock_bank_account":true,"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}}
}
}

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 6685","before":"example before 2804"},"limit":50}}
},
"get": {
"method": "GET",
Expand Down
Loading

0 comments on commit e75dc90

Please sign in to comment.