Skip to content

Commit

Permalink
Crankshaft[BU000001SY088G] Client - PHP @ 2015-08-05 17:32:42 +0000
Browse files Browse the repository at this point in the history
2991641 Pete Hamilton <peterejhamilton@gmail.com>
Merge branch dev

----------------

dd7327f Pete Hamilton <peterejhamilton@gmail.com>
Fix payload type error (broke cancel endpoints)

----------------

336ebde Pete Hamilton <peterejhamilton@gmail.com>
Fix SSL

----------------
  • Loading branch information
Crankshaft Robot committed Aug 5, 2015
1 parent 3e8a5a8 commit 1c2e604
Show file tree
Hide file tree
Showing 20 changed files with 4,059 additions and 46 deletions.
3,988 changes: 3,988 additions & 0 deletions cacert.pem

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions lib/GoCardlessPro/Core/CurlWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
*/
class CurlWrapper
{
/** The path to the CA cert bundle for use by Curl */
const CA_CERT_FILENAME = 'cacert.pem';

/** @var array[string]string Associative array of request headers */
private $headers;

Expand Down Expand Up @@ -57,6 +60,7 @@ private function setup_curl($method, $url)
CURLOPT_TIMEOUT => 30,
CURLOPT_CUSTOMREQUEST => strtoupper($method),
CURLOPT_VERBOSE => false,
CURLOPT_CAINFO => $this->getLibraryRootPath() . self::CA_CERT_FILENAME,
CURLOPT_HEADERFUNCTION => array($this, 'setResponseHeader')
);
}
Expand Down Expand Up @@ -196,4 +200,13 @@ public function run()
$this->response_headers
);
}

/**
* Internal function for finding the root path of the library, used to build the path to cacert.pem
* @return Path to the root of the library
*/
private function getLibraryRootPath()
{
return dirname(__FILE__) . "/../../../";
}
}
2 changes: 1 addition & 1 deletion lib/GoCardlessPro/Core/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function run($type, $method, $path, $options, $headers = array())
$path = $path . '?' . $urlParams;
}
} elseif (in_array($method, self::$body_methods)) {
$postBody = json_encode(array($this->getReqEnvelopeKey($type) => $options));
$postBody = json_encode(array($this->getReqEnvelopeKey($type) => (object) $options));
} else {
throw new \Exception('Unsupported HTTP Method');
}
Expand Down
3 changes: 0 additions & 3 deletions lib/GoCardlessPro/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ class Environment
/** The production GoCardless environment to use when billing is involved after development. */
const PRODUCTION = 'https://api.gocardless.com/';

/** A staging server with production data, allowing for testing code against the edge of gocardless. */
const STAGING = 'https://api-staging.gocardless.com/';

/** The sandbox testing server, seperate dataset and no ability to make "real" transactions. */
const SANDBOX = 'https://api-sandbox.gocardless.com/';
}
14 changes: 14 additions & 0 deletions lib/GoCardlessPro/Resources/BankDetailsLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@ public function bank_name()
return $this->data->{$field};
}

/**
* ISO 9362 SWIFT BIC of the bank with which the account is held.
*
* @return string
*/
public function bic()
{
$field = 'bic';
if (!property_exists($this->data, $field)) {
return null;
}
return $this->data->{$field};
}


/**
* Returns a string representation of the project.
Expand Down
4 changes: 2 additions & 2 deletions lib/GoCardlessPro/Resources/Mandate.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ public function reference()
/**
* <a name="mandates_scheme"></a>Direct Debit scheme to which this mandate
* and associated payments are submitted. Can be supplied or automatically
* detected from the customer's bank account. Currently only "bacs" and
* "sepa_core" are supported.
* detected from the customer's bank account. Currently only "bacs",
* "sepa_core", and "sepa_cor1" are supported.
*
* @return string
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/GoCardlessPro/Resources/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function metadata()
/**
* An optional payment reference. This will be appended to the mandate
* reference on your customer's bank statement. For Bacs payments this can be
* up to 10 characters, for SEPA Core payments the limit is 140 characters.
* up to 10 characters, for SEPA payments the limit is 140 characters.
*
* @return string
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function testBankDetailsLookupsCreate()

$this->matchDeepResponse($body->available_debit_schemes, $response->available_debit_schemes());
$this->matchDeepResponse($body->bank_name, $response->bank_name());
$this->matchDeepResponse($body->bic, $response->bic());


$this->assertTrue($this->hasCheckedCurl);
Expand Down
2 changes: 1 addition & 1 deletion tests/GoCardlessPro/fixtures/bank_details_lookups.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"method": "POST",
"path_template": "/bank_details_lookups",
"url_params": {},
"body": {"bank_details_lookups":{"available_debit_schemes":["bacs"],"bank_name":null}}
"body": {"bank_details_lookups":{"available_debit_schemes":["bacs"],"bank_name":null,"bic":null}}
}
}

8 changes: 4 additions & 4 deletions tests/GoCardlessPro/fixtures/creditor_bank_accounts.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
"method": "POST",
"path_template": "/creditor_bank_accounts",
"url_params": {},
"body": {"creditor_bank_accounts":{"account_holder_name":"Nude Wines","account_number_ending":"11","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"GBP","enabled":true,"id":"BA123","links":{"creditor":"CR123"},"metadata":{}}}
"body": {"creditor_bank_accounts":{"account_holder_name":"Nude Wines","account_number_ending":"11","bank_name":"BARCLAYS BANK PLC","country_code":null,"created_at":"2014-01-01T12:00:00.000Z","currency":"GBP","enabled":true,"id":"BA123","links":{"creditor":"CR123"},"metadata":{}}}
},
"list": {
"method": "GET",
"path_template": "/creditor_bank_accounts",
"url_params": {},
"body": {"creditor_bank_accounts":[{"account_holder_name":"Nude Wines","account_number_ending":"11","bank_name":"BARCLAYS BANK PLC","country_code":null,"created_at":"2014-01-01T12:00:00.000Z","currency":"GBP","enabled":true,"id":"BA123","links":{"creditor":"CR123"},"metadata":{}},{"account_holder_name":"Nude Wines","account_number_ending":"11","bank_name":"BARCLAYS BANK PLC","country_code":null,"created_at":"2014-01-01T12:00:00.000Z","currency":null,"enabled":true,"id":"BA123","links":{"creditor":"CR123"},"metadata":{}}],"meta":{"cursors":{"after":"example after 9703","before":"example before 4538"},"limit":50}}
"body": {"creditor_bank_accounts":[{"account_holder_name":"Nude Wines","account_number_ending":"11","bank_name":"BARCLAYS BANK PLC","country_code":null,"created_at":"2014-01-01T12:00:00.000Z","currency":"GBP","enabled":true,"id":"BA123","links":{"creditor":"CR123"},"metadata":{}},{"account_holder_name":"Nude Wines","account_number_ending":"11","bank_name":"BARCLAYS BANK PLC","country_code":null,"created_at":"2014-01-01T12:00:00.000Z","currency":null,"enabled":true,"id":"BA123","links":{"creditor":"CR123"},"metadata":{}}],"meta":{"cursors":{"after":"example after 156","before":"example before 8266"},"limit":50}}
},
"get": {
"method": "GET",
"path_template": "/creditor_bank_accounts/:identity",
"url_params": {"identity": "BA123"},
"body": {"creditor_bank_accounts":{"account_holder_name":"Nude Wines","account_number_ending":"11","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":null,"enabled":true,"id":"BA123","links":{"creditor":"CR123"},"metadata":{}}}
"body": {"creditor_bank_accounts":{"account_holder_name":"Nude Wines","account_number_ending":"11","bank_name":"BARCLAYS BANK PLC","country_code":null,"created_at":"2014-01-01T12:00:00.000Z","currency":"GBP","enabled":true,"id":"BA123","links":{"creditor":"CR123"},"metadata":{}}}
},
"disable": {
"method": "POST",
"path_template": "/creditor_bank_accounts/:identity/actions/disable",
"url_params": {"identity": "BA123"},
"body": {"creditor_bank_accounts":{"account_holder_name":"Nude Wines","account_number_ending":"11","bank_name":"BARCLAYS BANK PLC","country_code":null,"created_at":"2014-01-01T12:00:00.000Z","currency":"GBP","enabled":true,"id":"BA123","links":{"creditor":"CR123"},"metadata":{}}}
"body": {"creditor_bank_accounts":{"account_holder_name":"Nude Wines","account_number_ending":"11","bank_name":"BARCLAYS BANK PLC","country_code":null,"created_at":"2014-01-01T12:00:00.000Z","currency":null,"enabled":true,"id":"BA123","links":{"creditor":"CR123"},"metadata":{}}}
}
}

8 changes: 4 additions & 4 deletions tests/GoCardlessPro/fixtures/creditors.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
"method": "POST",
"path_template": "/creditors",
"url_params": {},
"body": {"creditors":{"address_line1":"338-346 Goswell Road","address_line2":"Islington","address_line3":"example address_line3 1318","city":"London","country_code":null,"created_at":"2014-01-01T12:00:00.000Z","id":"CR123","links":{"default_eur_payout_account":null,"default_gbp_payout_account":null},"name":"Nude Wines","postal_code":null,"region":"example region 3300"}}
"body": {"creditors":{"address_line1":null,"address_line2":"Islington","address_line3":"example address_line3 456","city":"London","country_code":null,"created_at":"2014-01-01T12:00:00.000Z","id":"CR123","links":{"default_eur_payout_account":"BA456","default_gbp_payout_account":null},"name":"Nude Wines","postal_code":"EC1V 7LQ","region":null}}
},
"list": {
"method": "GET",
"path_template": "/creditors",
"url_params": {},
"body": {"creditors":[{"address_line1":"338-346 Goswell Road","address_line2":"Islington","address_line3":"example address_line3 1445","city":"London","country_code":null,"created_at":"2014-01-01T12:00:00.000Z","id":"CR123","links":{"default_eur_payout_account":"BA456","default_gbp_payout_account":null},"name":"Nude Wines","postal_code":"EC1V 7LQ","region":"example region 5466"},{"address_line1":null,"address_line2":"Islington","address_line3":null,"city":null,"country_code":null,"created_at":"2014-01-01T12:00:00.000Z","id":"CR123","links":{"default_eur_payout_account":null,"default_gbp_payout_account":"BA123"},"name":"Nude Wines","postal_code":"EC1V 7LQ","region":"example region 7387"}],"meta":{"cursors":{"after":"example after 5429","before":"example before 6831"},"limit":50}}
"body": {"creditors":[{"address_line1":"338-346 Goswell Road","address_line2":null,"address_line3":"example address_line3 3274","city":"London","country_code":null,"created_at":"2014-01-01T12:00:00.000Z","id":"CR123","links":{"default_eur_payout_account":"BA456","default_gbp_payout_account":"BA123"},"name":"Nude Wines","postal_code":"EC1V 7LQ","region":"example region 495"},{"address_line1":null,"address_line2":null,"address_line3":"example address_line3 9947","city":null,"country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","id":"CR123","links":{"default_eur_payout_account":null,"default_gbp_payout_account":null},"name":"Nude Wines","postal_code":null,"region":"example region 7387"}],"meta":{"cursors":{"after":"example after 5356","before":"example before 5429"},"limit":50}}
},
"get": {
"method": "GET",
"path_template": "/creditors/:identity",
"url_params": {"identity": "CR123"},
"body": {"creditors":{"address_line1":"338-346 Goswell Road","address_line2":null,"address_line3":null,"city":null,"country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","id":"CR123","links":{"default_eur_payout_account":"BA456","default_gbp_payout_account":"BA123"},"name":"Nude Wines","postal_code":"EC1V 7LQ","region":"example region 1485"}}
"body": {"creditors":{"address_line1":null,"address_line2":null,"address_line3":null,"city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","id":"CR123","links":{"default_eur_payout_account":"BA456","default_gbp_payout_account":null},"name":"Nude Wines","postal_code":"EC1V 7LQ","region":"example region 1485"}}
},
"update": {
"method": "PUT",
"path_template": "/creditors/:identity",
"url_params": {"identity": "CR123"},
"body": {"creditors":{"address_line1":"338-346 Goswell Road","address_line2":"Islington","address_line3":"example address_line3 4324","city":null,"country_code":null,"created_at":"2014-01-01T12:00:00.000Z","id":"CR123","links":{"default_eur_payout_account":null,"default_gbp_payout_account":"BA123"},"name":"Nude Wines","postal_code":null,"region":null}}
"body": {"creditors":{"address_line1":null,"address_line2":"Islington","address_line3":"example address_line3 7189","city":"London","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","id":"CR123","links":{"default_eur_payout_account":"BA456","default_gbp_payout_account":null},"name":"Nude Wines","postal_code":"EC1V 7LQ","region":"example region 3000"}}
}
}

10 changes: 5 additions & 5 deletions tests/GoCardlessPro/fixtures/customer_bank_accounts.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,31 @@
"method": "POST",
"path_template": "/customer_bank_accounts",
"url_params": {},
"body": {"customer_bank_accounts":{"account_holder_name":"Billy Jean","account_number_ending":"11","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":null,"enabled":true,"id":"BA123","links":{"customer":"example customer 2066"},"metadata":{}}}
"body": {"customer_bank_accounts":{"account_holder_name":"Billy Jean","account_number_ending":"11","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"GBP","enabled":true,"id":"BA123","links":{"customer":"example customer 493"},"metadata":{}}}
},
"list": {
"method": "GET",
"path_template": "/customer_bank_accounts",
"url_params": {},
"body": {"customer_bank_accounts":[{"account_holder_name":"Billy Jean","account_number_ending":"11","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"GBP","enabled":true,"id":"BA123","links":{"customer":"example customer 3086"},"metadata":{}},{"account_holder_name":"Billy Jean","account_number_ending":"11","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":null,"enabled":true,"id":"BA123","links":{"customer":"example customer 9819"},"metadata":{}}],"meta":{"cursors":{"after":"example after 6052","before":"example before 7175"},"limit":50}}
"body": {"customer_bank_accounts":[{"account_holder_name":"Billy Jean","account_number_ending":"11","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":null,"enabled":true,"id":"BA123","links":{"customer":"example customer 8981"},"metadata":{}},{"account_holder_name":"Billy Jean","account_number_ending":"11","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"GBP","enabled":true,"id":"BA123","links":{"customer":"example customer 6052"},"metadata":{}}],"meta":{"cursors":{"after":"example after 5710","before":"example before 4885"},"limit":50}}
},
"get": {
"method": "GET",
"path_template": "/customer_bank_accounts/:identity",
"url_params": {"identity": "BA123"},
"body": {"customer_bank_accounts":{"account_holder_name":"Billy Jean","account_number_ending":"11","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":null,"enabled":true,"id":"BA123","links":{"customer":"example customer 4885"},"metadata":{}}}
"body": {"customer_bank_accounts":{"account_holder_name":"Billy Jean","account_number_ending":"11","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"GBP","enabled":true,"id":"BA123","links":{"customer":"example customer 1387"},"metadata":{}}}
},
"update": {
"method": "PUT",
"path_template": "/customer_bank_accounts/:identity",
"url_params": {"identity": "BA123"},
"body": {"customer_bank_accounts":{"account_holder_name":"Billy Jean","account_number_ending":"11","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"GBP","enabled":true,"id":"BA123","links":{"customer":"example customer 1387"},"metadata":{}}}
"body": {"customer_bank_accounts":{"account_holder_name":"Billy Jean","account_number_ending":"11","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"GBP","enabled":true,"id":"BA123","links":{"customer":"example customer 1528"},"metadata":{}}}
},
"disable": {
"method": "POST",
"path_template": "/customer_bank_accounts/:identity/actions/disable",
"url_params": {"identity": "BA123"},
"body": {"customer_bank_accounts":{"account_holder_name":"Billy Jean","account_number_ending":"11","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":"GBP","enabled":true,"id":"BA123","links":{"customer":"example customer 1528"},"metadata":{}}}
"body": {"customer_bank_accounts":{"account_holder_name":"Billy Jean","account_number_ending":"11","bank_name":"BARCLAYS BANK PLC","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","currency":null,"enabled":true,"id":"BA123","links":{"customer":"example customer 4384"},"metadata":{}}}
}
}

8 changes: 4 additions & 4 deletions tests/GoCardlessPro/fixtures/customers.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
"method": "POST",
"path_template": "/customers",
"url_params": {},
"body": {"customers":{"address_line1":"221B Baker Street","address_line2":null,"address_line3":null,"city":null,"company_name":"Hamilton Trading Ltd.","country_code":null,"created_at":"2014-01-01T12:00:00.000Z","email":null,"family_name":"Osborne","given_name":null,"id":"CU123","metadata":{},"postal_code":null,"region":null}}
"body": {"customers":{"address_line1":null,"address_line2":null,"address_line3":"City of Westminster","city":null,"company_name":"Hamilton Trading Ltd.","country_code":null,"created_at":"2014-01-01T12:00:00.000Z","email":null,"family_name":"Osborne","given_name":null,"id":"CU123","metadata":{},"postal_code":null,"region":null}}
},
"list": {
"method": "GET",
"path_template": "/customers",
"url_params": {},
"body": {"customers":[{"address_line1":"221B Baker Street","address_line2":null,"address_line3":"City of Westminster","city":"London","company_name":null,"country_code":null,"created_at":"2014-01-01T12:00:00.000Z","email":null,"family_name":null,"given_name":"Frank","id":"CU123","metadata":{},"postal_code":null,"region":null},{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":null,"company_name":null,"country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":"Osborne","given_name":"Frank","id":"CU123","metadata":{},"postal_code":"NW1 6XE","region":null}],"meta":{"cursors":{"after":"example after 6420","before":"example before 7996"},"limit":50}}
"body": {"customers":[{"address_line1":null,"address_line2":"Marylebone","address_line3":null,"city":null,"company_name":null,"country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":null,"given_name":null,"id":"CU123","metadata":{},"postal_code":null,"region":"Greater London"},{"address_line1":null,"address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":null,"given_name":null,"id":"CU123","metadata":{},"postal_code":"NW1 6XE","region":"Greater London"}],"meta":{"cursors":{"after":"example after 9757","before":"example before 1515"},"limit":50}}
},
"get": {
"method": "GET",
"path_template": "/customers/:identity",
"url_params": {"identity": "CU123"},
"body": {"customers":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":null,"city":"London","company_name":null,"country_code":null,"created_at":"2014-01-01T12:00:00.000Z","email":null,"family_name":null,"given_name":"Frank","id":"CU123","metadata":{},"postal_code":null,"region":"Greater London"}}
"body": {"customers":{"address_line1":null,"address_line2":"Marylebone","address_line3":"City of Westminster","city":null,"company_name":"Hamilton Trading Ltd.","country_code":"GB","created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":null,"given_name":null,"id":"CU123","metadata":{},"postal_code":"NW1 6XE","region":"Greater London"}}
},
"update": {
"method": "PUT",
"path_template": "/customers/:identity",
"url_params": {"identity": "CU123"},
"body": {"customers":{"address_line1":null,"address_line2":"Marylebone","address_line3":"City of Westminster","city":null,"company_name":null,"country_code":null,"created_at":"2014-01-01T12:00:00.000Z","email":null,"family_name":"Osborne","given_name":null,"id":"CU123","metadata":{},"postal_code":"NW1 6XE","region":null}}
"body": {"customers":{"address_line1":null,"address_line2":null,"address_line3":null,"city":"London","company_name":null,"country_code":null,"created_at":"2014-01-01T12:00:00.000Z","email":"user@example.com","family_name":null,"given_name":"Frank","id":"CU123","metadata":{},"postal_code":null,"region":null}}
}
}

Loading

0 comments on commit 1c2e604

Please sign in to comment.