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 #193

Merged
merged 9 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.11.0",
"version": "6.0.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' => '5.11.0',
'GoCardless-Client-Version' => '6.0.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/5.11.0';
$uagent[] = 'gocardless-pro-php/6.0.0';
$uagent[] = 'schema-version/2015-07-06';
if (defined('\GuzzleHttp\Client::MAJOR_VERSION')) {
$uagent[] = 'GuzzleHttp/' . \GuzzleHttp\Client::MAJOR_VERSION;
Expand Down
6 changes: 6 additions & 0 deletions lib/Resources/BillingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* @property-read mixed $purpose_code
* @property-read mixed $resources
* @property-read mixed $status
* @property-read mixed $subscription_request
*/
class BillingRequest extends BaseResource
{
Expand Down Expand Up @@ -105,4 +106,9 @@ class BillingRequest extends BaseResource
*/
protected $status;

/**
* Request for a subscription
*/
protected $subscription_request;

}
2 changes: 1 addition & 1 deletion lib/Resources/BillingRequestTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class BillingRequestTemplate extends BaseResource
protected $name;

/**
* Amount in minor unit (e.g. pence in GBP, cents in EUR).
* Amount in full.
*/
protected $payment_request_amount;

Expand Down
7 changes: 7 additions & 0 deletions lib/Resources/CustomerBankAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* @property-read mixed $account_holder_name
* @property-read mixed $account_number_ending
* @property-read mixed $account_type
* @property-read mixed $bank_account_token
* @property-read mixed $bank_name
* @property-read mixed $country_code
* @property-read mixed $created_at
Expand Down Expand Up @@ -48,6 +49,12 @@ class CustomerBankAccount extends BaseResource
*/
protected $account_type;

/**
* A token to uniquely refer to a set of bank account details. This feature
* is still in early access and is only available for certain organisations.
*/
protected $bank_account_token;

/**
* Name of bank, taken from the bank details.
*/
Expand Down
8 changes: 8 additions & 0 deletions lib/Resources/Mandate.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*
* @property-read mixed $authorisation_source
* @property-read mixed $consent_parameters
* @property-read mixed $consent_type
* @property-read mixed $created_at
* @property-read mixed $funds_settlement
* @property-read mixed $id
Expand Down Expand Up @@ -49,6 +50,13 @@ class Mandate extends BaseResource
*/
protected $consent_parameters;

/**
* (Optional) Specifies the type of authorisation agreed between the payer
* and merchant. It can be set to one-off, recurring or standing for ACH, or
* single, recurring and sporadic for PAD.
*/
protected $consent_type;

/**
* Fixed [timestamp](#api-usage-time-zones--dates), recording when this
* resource was created.
Expand Down
16 changes: 16 additions & 0 deletions tests/Integration/BillingRequestsIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function testBillingRequestsCreate()
$this->assertEquals($body->purpose_code, $response->purpose_code);
$this->assertEquals($body->resources, $response->resources);
$this->assertEquals($body->status, $response->status);
$this->assertEquals($body->subscription_request, $response->subscription_request);


$expectedPathRegex = $this->extract_resource_fixture_path_regex($fixture);
Expand Down Expand Up @@ -75,6 +76,7 @@ public function testBillingRequestsCreateWithIdempotencyConflict()
$this->assertEquals($body->purpose_code, $response->purpose_code);
$this->assertEquals($body->resources, $response->resources);
$this->assertEquals($body->status, $response->status);
$this->assertEquals($body->subscription_request, $response->subscription_request);


$expectedPathRegex = $this->extract_resource_fixture_path_regex($fixture);
Expand Down Expand Up @@ -107,6 +109,7 @@ public function testBillingRequestsCollectCustomerDetails()
$this->assertEquals($body->purpose_code, $response->purpose_code);
$this->assertEquals($body->resources, $response->resources);
$this->assertEquals($body->status, $response->status);
$this->assertEquals($body->subscription_request, $response->subscription_request);


$expectedPathRegex = $this->extract_resource_fixture_path_regex($fixture);
Expand Down Expand Up @@ -138,6 +141,7 @@ public function testBillingRequestsCollectBankAccount()
$this->assertEquals($body->purpose_code, $response->purpose_code);
$this->assertEquals($body->resources, $response->resources);
$this->assertEquals($body->status, $response->status);
$this->assertEquals($body->subscription_request, $response->subscription_request);


$expectedPathRegex = $this->extract_resource_fixture_path_regex($fixture);
Expand Down Expand Up @@ -169,6 +173,7 @@ public function testBillingRequestsConfirmPayerDetails()
$this->assertEquals($body->purpose_code, $response->purpose_code);
$this->assertEquals($body->resources, $response->resources);
$this->assertEquals($body->status, $response->status);
$this->assertEquals($body->subscription_request, $response->subscription_request);


$expectedPathRegex = $this->extract_resource_fixture_path_regex($fixture);
Expand Down Expand Up @@ -200,6 +205,7 @@ public function testBillingRequestsFulfil()
$this->assertEquals($body->purpose_code, $response->purpose_code);
$this->assertEquals($body->resources, $response->resources);
$this->assertEquals($body->status, $response->status);
$this->assertEquals($body->subscription_request, $response->subscription_request);


$expectedPathRegex = $this->extract_resource_fixture_path_regex($fixture);
Expand Down Expand Up @@ -231,6 +237,7 @@ public function testBillingRequestsCancel()
$this->assertEquals($body->purpose_code, $response->purpose_code);
$this->assertEquals($body->resources, $response->resources);
$this->assertEquals($body->status, $response->status);
$this->assertEquals($body->subscription_request, $response->subscription_request);


$expectedPathRegex = $this->extract_resource_fixture_path_regex($fixture);
Expand Down Expand Up @@ -306,6 +313,10 @@ public function testBillingRequestsList()
$this->assertEquals($body[$num]->status, $record->status);
}

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

}

$expectedPathRegex = $this->extract_resource_fixture_path_regex($fixture);
Expand Down Expand Up @@ -337,6 +348,7 @@ public function testBillingRequestsGet()
$this->assertEquals($body->purpose_code, $response->purpose_code);
$this->assertEquals($body->resources, $response->resources);
$this->assertEquals($body->status, $response->status);
$this->assertEquals($body->subscription_request, $response->subscription_request);


$expectedPathRegex = $this->extract_resource_fixture_path_regex($fixture);
Expand Down Expand Up @@ -368,6 +380,7 @@ public function testBillingRequestsNotify()
$this->assertEquals($body->purpose_code, $response->purpose_code);
$this->assertEquals($body->resources, $response->resources);
$this->assertEquals($body->status, $response->status);
$this->assertEquals($body->subscription_request, $response->subscription_request);


$expectedPathRegex = $this->extract_resource_fixture_path_regex($fixture);
Expand Down Expand Up @@ -399,6 +412,7 @@ public function testBillingRequestsFallback()
$this->assertEquals($body->purpose_code, $response->purpose_code);
$this->assertEquals($body->resources, $response->resources);
$this->assertEquals($body->status, $response->status);
$this->assertEquals($body->subscription_request, $response->subscription_request);


$expectedPathRegex = $this->extract_resource_fixture_path_regex($fixture);
Expand Down Expand Up @@ -430,6 +444,7 @@ public function testBillingRequestsChooseCurrency()
$this->assertEquals($body->purpose_code, $response->purpose_code);
$this->assertEquals($body->resources, $response->resources);
$this->assertEquals($body->status, $response->status);
$this->assertEquals($body->subscription_request, $response->subscription_request);


$expectedPathRegex = $this->extract_resource_fixture_path_regex($fixture);
Expand Down Expand Up @@ -461,6 +476,7 @@ public function testBillingRequestsSelectInstitution()
$this->assertEquals($body->purpose_code, $response->purpose_code);
$this->assertEquals($body->resources, $response->resources);
$this->assertEquals($body->status, $response->status);
$this->assertEquals($body->subscription_request, $response->subscription_request);


$expectedPathRegex = $this->extract_resource_fixture_path_regex($fixture);
Expand Down
9 changes: 9 additions & 0 deletions tests/Integration/CustomerBankAccountsIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function testCustomerBankAccountsCreate()
$this->assertEquals($body->account_holder_name, $response->account_holder_name);
$this->assertEquals($body->account_number_ending, $response->account_number_ending);
$this->assertEquals($body->account_type, $response->account_type);
$this->assertEquals($body->bank_account_token, $response->bank_account_token);
$this->assertEquals($body->bank_name, $response->bank_name);
$this->assertEquals($body->country_code, $response->country_code);
$this->assertEquals($body->created_at, $response->created_at);
Expand Down Expand Up @@ -67,6 +68,7 @@ public function testCustomerBankAccountsCreateWithIdempotencyConflict()
$this->assertEquals($body->account_holder_name, $response->account_holder_name);
$this->assertEquals($body->account_number_ending, $response->account_number_ending);
$this->assertEquals($body->account_type, $response->account_type);
$this->assertEquals($body->bank_account_token, $response->bank_account_token);
$this->assertEquals($body->bank_name, $response->bank_name);
$this->assertEquals($body->country_code, $response->country_code);
$this->assertEquals($body->created_at, $response->created_at);
Expand Down Expand Up @@ -119,6 +121,10 @@ public function testCustomerBankAccountsList()
$this->assertEquals($body[$num]->account_type, $record->account_type);
}

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

if (isset($body[$num]->bank_name)) {
$this->assertEquals($body[$num]->bank_name, $record->bank_name);
}
Expand Down Expand Up @@ -174,6 +180,7 @@ public function testCustomerBankAccountsGet()
$this->assertEquals($body->account_holder_name, $response->account_holder_name);
$this->assertEquals($body->account_number_ending, $response->account_number_ending);
$this->assertEquals($body->account_type, $response->account_type);
$this->assertEquals($body->bank_account_token, $response->bank_account_token);
$this->assertEquals($body->bank_name, $response->bank_name);
$this->assertEquals($body->country_code, $response->country_code);
$this->assertEquals($body->created_at, $response->created_at);
Expand Down Expand Up @@ -205,6 +212,7 @@ public function testCustomerBankAccountsUpdate()
$this->assertEquals($body->account_holder_name, $response->account_holder_name);
$this->assertEquals($body->account_number_ending, $response->account_number_ending);
$this->assertEquals($body->account_type, $response->account_type);
$this->assertEquals($body->bank_account_token, $response->bank_account_token);
$this->assertEquals($body->bank_name, $response->bank_name);
$this->assertEquals($body->country_code, $response->country_code);
$this->assertEquals($body->created_at, $response->created_at);
Expand Down Expand Up @@ -236,6 +244,7 @@ public function testCustomerBankAccountsDisable()
$this->assertEquals($body->account_holder_name, $response->account_holder_name);
$this->assertEquals($body->account_number_ending, $response->account_number_ending);
$this->assertEquals($body->account_type, $response->account_type);
$this->assertEquals($body->bank_account_token, $response->bank_account_token);
$this->assertEquals($body->bank_name, $response->bank_name);
$this->assertEquals($body->country_code, $response->country_code);
$this->assertEquals($body->created_at, $response->created_at);
Expand Down
10 changes: 10 additions & 0 deletions tests/Integration/MandatesIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function testMandatesCreate()

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

$this->assertEquals($body->authorisation_source, $response->authorisation_source);
$this->assertEquals($body->consent_parameters, $response->consent_parameters);
$this->assertEquals($body->consent_type, $response->consent_type);
$this->assertEquals($body->created_at, $response->created_at);
$this->assertEquals($body->funds_settlement, $response->funds_settlement);
$this->assertEquals($body->id, $response->id);
Expand Down Expand Up @@ -121,6 +123,10 @@ public function testMandatesList()
$this->assertEquals($body[$num]->consent_parameters, $record->consent_parameters);
}

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

if (isset($body[$num]->created_at)) {
$this->assertEquals($body[$num]->created_at, $record->created_at);
}
Expand Down Expand Up @@ -191,6 +197,7 @@ public function testMandatesGet()

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

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

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

$this->assertEquals($body->authorisation_source, $response->authorisation_source);
$this->assertEquals($body->consent_parameters, $response->consent_parameters);
$this->assertEquals($body->consent_type, $response->consent_type);
$this->assertEquals($body->created_at, $response->created_at);
$this->assertEquals($body->funds_settlement, $response->funds_settlement);
$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": "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-08-13T10:44:20.235Z","expires_at":"2024-08-13T10:44:20.235Z","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-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"}}
},
"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-08-13T10:44:20.235Z","expires_at":"2024-08-13T10:44:20.235Z","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-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"}}
}
}

Loading
Loading