Skip to content

Commit

Permalink
Merge pull request #175 from gocardless/template-changes
Browse files Browse the repository at this point in the history
Changes from gocardless/gocardless-pro-php-template
  • Loading branch information
NickLewry authored Nov 24, 2023
2 parents 5e331c2 + c4a666d commit 3df1b2b
Show file tree
Hide file tree
Showing 36 changed files with 262 additions and 83 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.4.0",
"version": "5.5.0",
"keywords": [
"gocardless",
"direct debit",
Expand Down
18 changes: 16 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.4.0',
'GoCardless-Client-Version' => '5.5.0',
'User-Agent' => $this->getUserAgent()
),
'http_errors' => false,
Expand Down Expand Up @@ -491,6 +491,20 @@ public function taxRates()
return $this->tax_rates;
}

/**
* Service for interacting with transferred mandate
*
* @return Services\TransferredMandatesService
*/
public function transferredMandates()
{
if (!isset($this->transferred_mandates)) {
$this->transferred_mandates = new Services\TransferredMandatesService($this->api_client);
}

return $this->transferred_mandates;
}

/**
* Service for interacting with verification details
*
Expand Down Expand Up @@ -568,7 +582,7 @@ private function getUserAgent()
{
$curlinfo = curl_version();
$uagent = array();
$uagent[] = 'gocardless-pro-php/5.4.0';
$uagent[] = 'gocardless-pro-php/5.5.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/BillingRequestFlow.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* @property-read $authorisation_url
* @property-read $auto_fulfil
* @property-read $created_at
* @property-read $customer_details_captured
* @property-read $exit_uri
* @property-read $expires_at
* @property-read $id
Expand Down Expand Up @@ -51,6 +52,11 @@ class BillingRequestFlow extends BaseResource
*/
protected $created_at;

/**
* Identifies whether a Billing Request belongs to a specific customer
*/
protected $customer_details_captured;

/**
* URL that the payer can be taken to if there isn't a way to progress ahead
* in flow.
Expand Down
47 changes: 47 additions & 0 deletions lib/Resources/TransferredMandate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* WARNING: Do not edit by hand, this file was generated by Crank:
*
* https://github.com/gocardless/crank
*/

namespace GoCardlessPro\Resources;

/**
* A thin wrapper around a transferred_mandate, providing access to its
* attributes
*
* @property-read $encrypted_customer_bank_details
* @property-read $encrypted_decryption_key
* @property-read $links
* @property-read $public_key_id
*/
class TransferredMandate extends BaseResource
{
protected $model_name = "TransferredMandate";

/**
* Encrypted customer bank account details, containing:
* `iban`, `account_holder_name`, `swift_bank_code`, `swift_branch_code`,
* `swift_account_number`
*/
protected $encrypted_customer_bank_details;

/**
* Random AES-256 key used to encrypt bank account details, itself encrypted
* with your public key.
*/
protected $encrypted_decryption_key;

/**
*
*/
protected $links;

/**
* The ID of an RSA-2048 public key, from your JWKS, used to encrypt the AES
* key.
*/
protected $public_key_id;

}
60 changes: 60 additions & 0 deletions lib/Services/TransferredMandatesService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php
/**
* WARNING: Do not edit by hand, this file was generated by Crank:
*
* https://github.com/gocardless/crank
*/

namespace GoCardlessPro\Services;

use \GoCardlessPro\Core\Paginator;
use \GoCardlessPro\Core\Util;
use \GoCardlessPro\Core\ListResponse;
use \GoCardlessPro\Resources\TransferredMandate;
use \GoCardlessPro\Core\Exception\InvalidStateException;


/**
* Service that provides access to the TransferredMandate
* endpoints of the API
*
* @method transferredMandates()
*/
class TransferredMandatesService extends BaseService
{

protected $envelope_key = 'transferred_mandates';
protected $resource_class = '\GoCardlessPro\Resources\TransferredMandate';


/**
* Get updated customer bank details
*
* Example URL: /transferred_mandates/:identity
*
* @param string $identity Unique identifier, beginning with "MD". Note that this
prefix may not apply to mandates created before 2016.
* @param string[mixed] $params An associative array for any params
* @return TransferredMandate
**/
public function transferredMandates($identity, $params = array())
{
$path = Util::subUrl(
'/transferred_mandates/:identity',
array(

'identity' => $identity
)
);
if(isset($params['params'])) { $params['query'] = $params['params'];
unset($params['params']);
}


$response = $this->api_client->get($path, $params);


return $this->getResourceForResponse($response);
}

}
2 changes: 2 additions & 0 deletions tests/Integration/BillingRequestFlowsIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function testBillingRequestFlowsCreate()
$this->assertEquals($body->authorisation_url, $response->authorisation_url);
$this->assertEquals($body->auto_fulfil, $response->auto_fulfil);
$this->assertEquals($body->created_at, $response->created_at);
$this->assertEquals($body->customer_details_captured, $response->customer_details_captured);
$this->assertEquals($body->exit_uri, $response->exit_uri);
$this->assertEquals($body->expires_at, $response->expires_at);
$this->assertEquals($body->id, $response->id);
Expand Down Expand Up @@ -66,6 +67,7 @@ public function testBillingRequestFlowsInitialise()
$this->assertEquals($body->authorisation_url, $response->authorisation_url);
$this->assertEquals($body->auto_fulfil, $response->auto_fulfil);
$this->assertEquals($body->created_at, $response->created_at);
$this->assertEquals($body->customer_details_captured, $response->customer_details_captured);
$this->assertEquals($body->exit_uri, $response->exit_uri);
$this->assertEquals($body->expires_at, $response->expires_at);
$this->assertEquals($body->id, $response->id);
Expand Down
41 changes: 41 additions & 0 deletions tests/Integration/TransferredMandatesIntegrationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
//
// WARNING: Do not edit by hand, this file was generated by Crank:
// https://github.com/gocardless/crank
//

namespace GoCardlessPro\Integration;

class TransferredMandatesIntegrationTest extends IntegrationTestBase
{
public function testResourceModelExists()
{
$obj = new \GoCardlessPro\Resources\TransferredMandate(array());
$this->assertNotNull($obj);
}

public function testTransferredMandatesTransferredMandates()
{
$fixture = $this->loadJsonFixture('transferred_mandates')->transferred_mandates;
$this->stub_request($fixture);

$service = $this->client->transferredMandates();
$response = call_user_func_array(array($service, 'transferredMandates'), (array)$fixture->url_params);

$body = $fixture->body->transferred_mandates;

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

$this->assertEquals($body->encrypted_customer_bank_details, $response->encrypted_customer_bank_details);
$this->assertEquals($body->encrypted_decryption_key, $response->encrypted_decryption_key);
$this->assertEquals($body->links, $response->links);
$this->assertEquals($body->public_key_id, $response->public_key_id);


$expectedPathRegex = $this->extract_resource_fixture_path_regex($fixture);
$dispatchedRequest = $this->history[0]['request'];
$this->assertMatchesRegularExpression($expectedPathRegex, $dispatchedRequest->getUri()->getPath());
}


}
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-10-26T13:07:05.665Z","expires_at":"2023-10-26T13:07:05.665Z","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-11-24T11:31:50.810Z","expires_at":"2023-11-24T11:31:50.810Z","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-10-26T13:07:05.665Z","expires_at":"2023-10-26T13:07:05.665Z","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-11-24T11:31:50.810Z","expires_at":"2023-11-24T11:31:50.810Z","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-10-26T13:07:05.670Z","exit_uri":"https://my-website.com/abc/callback","expires_at":"2023-10-26T13:07:05.670Z","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":false,"show_success_redirect_button":false}}
"body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":false,"created_at":"2023-11-24T11:31:50.813Z","customer_details_captured":false,"exit_uri":"https://my-website.com/abc/callback","expires_at":"2023-11-24T11:31:50.813Z","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":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":"2023-10-26T13:07:05.670Z","exit_uri":"https://my-website.com/abc/callback","expires_at":"2023-10-26T13:07:05.670Z","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":false}}
"body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":false,"created_at":"2023-11-24T11:31:50.813Z","customer_details_captured":true,"exit_uri":"https://my-website.com/abc/callback","expires_at":"2023-11-24T11:31:50.813Z","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,"show_success_redirect_button":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 1053","before":"example before 5343"},"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 9859","before":"example before 5166"},"limit":50}}
},
"get": {
"method": "GET",
Expand Down
Loading

0 comments on commit 3df1b2b

Please sign in to comment.