Skip to content

Commit

Permalink
Merge pull request #169 from gocardless/template-changes
Browse files Browse the repository at this point in the history
Bump to version 5.3.0
  • Loading branch information
barrucadu authored Aug 17, 2023
2 parents bae1786 + 89f1dce commit 0e68767
Show file tree
Hide file tree
Showing 34 changed files with 120 additions and 115 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": "5.2.0",
"version": "5.3.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' => '5.2.0',
'GoCardless-Client-Version' => '5.3.0',
'User-Agent' => $this->getUserAgent()
),
'http_errors' => false,
Expand Down Expand Up @@ -568,7 +568,7 @@ private function getUserAgent()
{
$curlinfo = curl_version();
$uagent = array();
$uagent[] = 'gocardless-pro-php/5.2.0';
$uagent[] = 'gocardless-pro-php/5.3.0';
$uagent[] = 'schema-version/2015-07-06';
if (defined('\GuzzleHttp\Client::MAJOR_VERSION')) {
$uagent[] = 'GuzzleHttp/' . \GuzzleHttp\Client::MAJOR_VERSION;
Expand Down
18 changes: 15 additions & 3 deletions lib/Resources/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @property-read $id
* @property-read $links
* @property-read $metadata
* @property-read $resource_metadata
* @property-read $resource_type
*/
class Event extends BaseResource
Expand Down Expand Up @@ -61,12 +62,23 @@ class Event extends BaseResource
protected $links;

/**
* If the `details[origin]` is `api`, this will contain any metadata you
* specified when triggering this event. In other cases it will be an empty
* object.
* The metadata that was passed when making the API request that triggered
* the event
* (for instance, cancelling a mandate).
*
* This field will only be populated if the `details[origin]` field is `api`
* otherwise it will be an empty object.
*/
protected $metadata;

/**
* The metadata of the resource that the event is for. For example, this
* field will have the same
* value of the `mandate[metadata]` field on the response you would receive
* from performing a GET request on a mandate.
*/
protected $resource_metadata;

/**
* The resource type for this event. One of:
* <ul>
Expand Down
13 changes: 13 additions & 0 deletions lib/Resources/Mandate.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* @property-read $authorisation_source
* @property-read $consent_parameters
* @property-read $created_at
* @property-read $funds_settlement
* @property-read $id
* @property-read $links
* @property-read $metadata
Expand Down Expand Up @@ -53,6 +54,18 @@ class Mandate extends BaseResource
*/
protected $created_at;

/**
* This field will decide how GoCardless handles settlement of funds from
* the customer.
*
* - `managed` will be moved through GoCardless' account, batched, and payed
* out.
* - `direct` will be a direct transfer from the payer's account to the
* merchant where
* invoicing will be handled separately.
*/
protected $funds_settlement;

/**
* Unique identifier, beginning with "MD". Note that this prefix may not
* apply to mandates created before 2016.
Expand Down
19 changes: 0 additions & 19 deletions lib/Resources/NegativeBalanceLimit.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,16 @@
* A thin wrapper around a negative_balance_limit, providing access to its
* attributes
*
* @property-read $active
* @property-read $balance_limit
* @property-read $created_at
* @property-read $currency
* @property-read $id
* @property-read $links
* @property-read $reason
* @property-read $updated_at
*/
class NegativeBalanceLimit extends BaseResource
{
protected $model_name = "NegativeBalanceLimit";

/**
* Whether or not this limit is currently active
*/
protected $active;

/**
* The limit amount in pence (e.g. 10000 for a -100 GBP limit).
*/
Expand Down Expand Up @@ -57,15 +49,4 @@ class NegativeBalanceLimit extends BaseResource
*/
protected $links;

/**
* the reason this limit was created
*/
protected $reason;

/**
* Fixed [timestamp](#api-usage-time-zones--dates), recording when this
* limit was last updated.
*/
protected $updated_at;

}
3 changes: 1 addition & 2 deletions lib/Resources/ScenarioSimulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ class ScenarioSimulator extends BaseResource
* through `transferred` and resubmits it to the banks, can be caused be the
* UK's Current Account Switching Service (CASS) or when a customer contacts
* GoCardless to change their bank details. It must start in the
* `pending_submission` state. Only compatible with Bacs, SEPA and Autogiro
* mandates.</li>
* `pending_submission` state. Only compatible with Bacs mandates.</li>
* <li>`mandate_suspended_by_payer`: Transitions a mandate to
* `suspended_by_payer`, as if payer has suspended the mandate after it has
* been setup successfully. It must start in the `activated` state. Only
Expand Down
4 changes: 2 additions & 2 deletions lib/Services/ScenarioSimulatorsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ class ScenarioSimulatorsService extends BaseService
banks, can be caused be the UK's Current Account Switching
Service (CASS) or when a customer contacts GoCardless to
change their bank details. It must start in the
`pending_submission` state. Only compatible with Bacs, SEPA
and Autogiro mandates.</li>
`pending_submission` state. Only compatible with Bacs
mandates.</li>
<li>`mandate_suspended_by_payer`: Transitions a mandate to
`suspended_by_payer`, as if payer has suspended the mandate
after it has been setup successfully. It must start in the
Expand Down
5 changes: 5 additions & 0 deletions tests/Integration/EventsIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ public function testEventsList()
$this->assertEquals($body[$num]->metadata, $record->metadata);
}

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

if (isset($body[$num]->resource_type)) {
$this->assertEquals($body[$num]->resource_type, $record->resource_type);
}
Expand Down Expand Up @@ -96,6 +100,7 @@ public function testEventsGet()
$this->assertEquals($body->id, $response->id);
$this->assertEquals($body->links, $response->links);
$this->assertEquals($body->metadata, $response->metadata);
$this->assertEquals($body->resource_metadata, $response->resource_metadata);
$this->assertEquals($body->resource_type, $response->resource_type);


Expand Down
10 changes: 10 additions & 0 deletions tests/Integration/MandatesIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function testMandatesCreate()
$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->funds_settlement, $response->funds_settlement);
$this->assertEquals($body->id, $response->id);
$this->assertEquals($body->links, $response->links);
$this->assertEquals($body->metadata, $response->metadata);
Expand Down Expand Up @@ -68,6 +69,7 @@ public function testMandatesCreateWithIdempotencyConflict()
$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->funds_settlement, $response->funds_settlement);
$this->assertEquals($body->id, $response->id);
$this->assertEquals($body->links, $response->links);
$this->assertEquals($body->metadata, $response->metadata);
Expand Down Expand Up @@ -121,6 +123,10 @@ public function testMandatesList()
$this->assertEquals($body[$num]->created_at, $record->created_at);
}

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

if (isset($body[$num]->id)) {
$this->assertEquals($body[$num]->id, $record->id);
}
Expand Down Expand Up @@ -180,6 +186,7 @@ public function testMandatesGet()
$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->funds_settlement, $response->funds_settlement);
$this->assertEquals($body->id, $response->id);
$this->assertEquals($body->links, $response->links);
$this->assertEquals($body->metadata, $response->metadata);
Expand Down Expand Up @@ -212,6 +219,7 @@ public function testMandatesUpdate()
$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->funds_settlement, $response->funds_settlement);
$this->assertEquals($body->id, $response->id);
$this->assertEquals($body->links, $response->links);
$this->assertEquals($body->metadata, $response->metadata);
Expand Down Expand Up @@ -244,6 +252,7 @@ public function testMandatesCancel()
$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->funds_settlement, $response->funds_settlement);
$this->assertEquals($body->id, $response->id);
$this->assertEquals($body->links, $response->links);
$this->assertEquals($body->metadata, $response->metadata);
Expand Down Expand Up @@ -276,6 +285,7 @@ public function testMandatesReinstate()
$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->funds_settlement, $response->funds_settlement);
$this->assertEquals($body->id, $response->id);
$this->assertEquals($body->links, $response->links);
$this->assertEquals($body->metadata, $response->metadata);
Expand Down
15 changes: 0 additions & 15 deletions tests/Integration/NegativeBalanceLimitsIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ public function testNegativeBalanceLimitsList()
foreach (range(0, count($body) - 1) as $num) {
$record = $records[$num];

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

if (isset($body[$num]->balance_limit)) {
$this->assertEquals($body[$num]->balance_limit, $record->balance_limit);
}
Expand All @@ -61,14 +57,6 @@ public function testNegativeBalanceLimitsList()
$this->assertEquals($body[$num]->links, $record->links);
}

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

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

}

$expectedPathRegex = $this->extract_resource_fixture_path_regex($fixture);
Expand All @@ -89,14 +77,11 @@ public function testNegativeBalanceLimitsCreate()

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

$this->assertEquals($body->active, $response->active);
$this->assertEquals($body->balance_limit, $response->balance_limit);
$this->assertEquals($body->created_at, $response->created_at);
$this->assertEquals($body->currency, $response->currency);
$this->assertEquals($body->id, $response->id);
$this->assertEquals($body->links, $response->links);
$this->assertEquals($body->reason, $response->reason);
$this->assertEquals($body->updated_at, $response->updated_at);


$expectedPathRegex = $this->extract_resource_fixture_path_regex($fixture);
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":"2023-05-15T10:39:15.930Z","expires_at":"2023-05-15T10:39:15.930Z","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":"2023-08-17T13:20:41.179Z","expires_at":"2023-08-17T13:20:41.179Z","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":"2023-05-15T10:39:15.930Z","expires_at":"2023-05-15T10:39:15.930Z","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":"2023-08-17T13:20:41.179Z","expires_at":"2023-08-17T13:20:41.179Z","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":false,"created_at":"2023-05-15T10:39:15.933Z","exit_uri":"https://my-website.com/abc/callback","expires_at":"2023-05-15T10:39:15.933Z","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":"user@example.com","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":false}}
"body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":false,"created_at":"2023-08-17T13:20:41.184Z","exit_uri":"https://my-website.com/abc/callback","expires_at":"2023-08-17T13:20:41.184Z","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":"user@example.com","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}}
},
"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":"2023-05-15T10:39:15.934Z","exit_uri":"https://my-website.com/abc/callback","expires_at":"2023-05-15T10:39:15.934Z","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":"user@example.com","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":"2023-08-17T13:20:41.184Z","exit_uri":"https://my-website.com/abc/callback","expires_at":"2023-08-17T13:20:41.184Z","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":"user@example.com","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}}
}
}

Loading

0 comments on commit 0e68767

Please sign in to comment.