-
-
Save gedex/e7b3e4cd41e9f00d70f550ed55c19d71 to your computer and use it in GitHub Desktop.
This file has been truncated, but you can view the full file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: braintree_sdk/CHANGELOG.md | |
=================================================================== | |
--- braintree_sdk/CHANGELOG.md (revision 1387260) | |
+++ braintree_sdk/CHANGELOG.md (working copy) | |
@@ -1,3 +1,25 @@ | |
+## 3.8.0 | |
+* Add payment method revoke | |
+* Add support for options in `submit_for_settlement` transaction flows | |
+* Add verification create API | |
+* Update https certificate bundle | |
+ | |
+## 3.7.0 | |
+* Add VenmoAccount | |
+* Allow order_id and descriptor to be passed in for Transaction submit_for_settlement | |
+* Add facilitator details onto transactions | |
+* Add check webhook constant | |
+ | |
+## 3.6.1 | |
+* Fix PSR-0 style namespacing when using Symfony | |
+ | |
+## 3.6.0 | |
+* Add support for proxy servers | |
+* Add PSR-4 namespacing support | |
+* Add support for AMEX Express Checkout | |
+* Add support for new fields in dispute webhooks (`dateWon`, `dateOpened`, `kind`) | |
+* Add transaction data to sucessful subscription webhook | |
+ | |
## 3.5.0 | |
* Add support for raw ApplePay params on Transaction create | |
Index: braintree_sdk/README.md | |
=================================================================== | |
--- braintree_sdk/README.md (revision 1387260) | |
+++ braintree_sdk/README.md (working copy) | |
@@ -21,18 +21,16 @@ | |
require_once 'PATH_TO_BRAINTREE/lib/Braintree.php'; | |
-Braintree_Configuration::environment('sandbox'); | |
-Braintree_Configuration::merchantId('your_merchant_id'); | |
-Braintree_Configuration::publicKey('your_public_key'); | |
-Braintree_Configuration::privateKey('your_private_key'); | |
+Braintree\Configuration::environment('sandbox'); | |
+Braintree\Configuration::merchantId('your_merchant_id'); | |
+Braintree\Configuration::publicKey('your_public_key'); | |
+Braintree\Configuration::privateKey('your_private_key'); | |
-$result = Braintree_Transaction::sale(array( | |
+$result = Braintree\Transaction::sale([ | |
'amount' => '1000.00', | |
- 'creditCard' => array( | |
- 'number' => '5105105105105100', | |
- 'expirationDate' => '05/12' | |
- ) | |
-)); | |
+ 'paymentMethodNonce' => 'nonceFromTheClient', | |
+ 'options' => [ 'submitForSettlement' => true ] | |
+]); | |
if ($result->success) { | |
print_r("success!: " . $result->transaction->id); | |
@@ -44,8 +42,6 @@ | |
print_r("Validation errors: \n"); | |
print_r($result->errors->deepAll()); | |
} | |
- | |
-?> | |
``` | |
## HHVM Support | |
@@ -62,14 +58,13 @@ | |
## Testing | |
-Tests are written in PHPunit (installed by composer). Unit tests should run on | |
-any system meeting the base requirements: | |
+The unit specs can be run by anyone on any system, but the integration specs are meant to be run against a local development server of our gateway code. These integration specs are not meant for public consumption and will likely fail if run on your system. To run unit tests use rake: `rake test:unit`. | |
- phpunit tests/unit/ | |
+The benefit of the `rake` tasks is that testing covers default `hhvm` and `php` interpreters. However, if you want to run tests manually simply use the following command: | |
+``` | |
+phpunit tests/unit/ | |
+``` | |
-Please note that the integration tests require access to services internal to | |
-Braintree, and so will not run in your test environment. | |
- | |
## Open Source Attribution | |
A list of open source projects that help power Braintree can be found [here](https://www.braintreepayments.com/developers/open-source). | |
Index: braintree_sdk/Rakefile | |
=================================================================== | |
--- braintree_sdk/Rakefile (revision 1387260) | |
+++ braintree_sdk/Rakefile (working copy) | |
@@ -49,11 +49,21 @@ | |
task :hhvm => %w[hhvm:unit hhvm:integration] | |
desc "run a single test file" | |
- task :single_test, :file_path do |t, args| | |
+ task :file, :file_path do |t, args| | |
run_php_test_file(args[:file_path]) | |
end | |
+ | |
+ desc "run a single test" | |
+ task :single, :test_name do |t, args| | |
+ run_php_test(args[:test_name]) | |
+ end | |
end | |
+desc "update the copyright year" | |
+task :copyright, :from_year, :to_year do |t, args| | |
+ sh "find tests lib -type f -name '*.php' -exec sed -i 's/#{args[:from_year]} Braintree/#{args[:to_year]} Braintree/g' {} +" | |
+end | |
+ | |
def print_php_version(interpreter) | |
sh "#{interpreter} --version" | |
end | |
@@ -65,3 +75,7 @@ | |
def run_php_test_file(test_file) | |
sh "./vendor/bin/phpunit #{test_file}" | |
end | |
+ | |
+def run_php_test(test_name) | |
+ sh "./vendor/bin/phpunit --filter #{test_name}" | |
+end | |
Index: braintree_sdk/composer.json | |
=================================================================== | |
--- braintree_sdk/composer.json (revision 1387260) | |
+++ braintree_sdk/composer.json (working copy) | |
@@ -22,7 +22,15 @@ | |
}, | |
"autoload": { | |
"psr-0": { | |
- "Braintree": "lib" | |
+ "Braintree": "lib/" | |
+ }, | |
+ "psr-4": { | |
+ "Braintree\\": "lib/Braintree" | |
} | |
+ }, | |
+ "autoload-dev": { | |
+ "psr-4": { | |
+ "Test\\": "tests" | |
+ } | |
} | |
} | |
Index: braintree_sdk/lib/Braintree/AddOn.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/AddOn.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/AddOn.php (working copy) | |
@@ -1,11 +1,12 @@ | |
<?php | |
+namespace Braintree; | |
-class Braintree_AddOn extends Braintree_Modification | |
+class AddOn extends Modification | |
{ | |
/** | |
* | |
* @param array $attributes | |
- * @return Braintree_AddOn | |
+ * @return AddOn | |
*/ | |
public static function factory($attributes) | |
{ | |
@@ -18,10 +19,11 @@ | |
/** | |
* static methods redirecting to gateway | |
* | |
- * @return Braintree_AddOn[] | |
+ * @return AddOn[] | |
*/ | |
public static function all() | |
{ | |
- return Braintree_Configuration::gateway()->addOn()->all(); | |
+ return Configuration::gateway()->addOn()->all(); | |
} | |
} | |
+class_alias('Braintree\AddOn', 'Braintree_AddOn'); | |
Index: braintree_sdk/lib/Braintree/AddOnGateway.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/AddOnGateway.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/AddOnGateway.php (working copy) | |
@@ -1,51 +1,53 @@ | |
<?php | |
+namespace Braintree; | |
-class Braintree_AddOnGateway | |
+class AddOnGateway | |
{ | |
/** | |
* | |
- * @var Braintree_Gateway | |
+ * @var Gateway | |
*/ | |
private $_gateway; | |
- | |
+ | |
/** | |
* | |
- * @var Braintree_Configuration | |
+ * @var Configuration | |
*/ | |
private $_config; | |
- | |
+ | |
/** | |
* | |
- * @var Braintree_Http | |
+ * @var Http | |
*/ | |
private $_http; | |
/** | |
- * | |
- * @param Braintree_Gateway $gateway | |
+ * | |
+ * @param Gateway $gateway | |
*/ | |
public function __construct($gateway) | |
{ | |
$this->_gateway = $gateway; | |
$this->_config = $gateway->config; | |
$this->_config->assertHasAccessTokenOrKeys(); | |
- $this->_http = new Braintree_Http($gateway->config); | |
+ $this->_http = new Http($gateway->config); | |
} | |
/** | |
- * | |
- * @return Braintree_AddOn[] | |
+ * | |
+ * @return AddOn[] | |
*/ | |
public function all() | |
{ | |
$path = $this->_config->merchantPath() . '/add_ons'; | |
$response = $this->_http->get($path); | |
- $addOns = array("addOn" => $response['addOns']); | |
+ $addOns = ["addOn" => $response['addOns']]; | |
- return Braintree_Util::extractAttributeAsArray( | |
+ return Util::extractAttributeAsArray( | |
$addOns, | |
'addOn' | |
); | |
} | |
} | |
+class_alias('Braintree\AddOnGateway', 'Braintree_AddOnGateway'); | |
Index: braintree_sdk/lib/Braintree/Address.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Address.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Address.php (working copy) | |
@@ -1,4 +1,6 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
/** | |
* Braintree Address module | |
* PHP Version 5 | |
@@ -9,7 +11,7 @@ | |
* as the shipping address when creating a Transaction. | |
* | |
* @package Braintree | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
* @property-read string $company | |
* @property-read string $countryName | |
@@ -25,18 +27,18 @@ | |
* @property-read string $streetAddress | |
* @property-read string $updatedAt | |
*/ | |
-class Braintree_Address extends Braintree_Base | |
+class Address extends Base | |
{ | |
/** | |
- * returns false if comparing object is not a Braintree_Address, | |
- * or is a Braintree_Address with a different id | |
+ * returns false if comparing object is not a Address, | |
+ * or is a Address with a different id | |
* | |
* @param object $other address to compare against | |
* @return boolean | |
*/ | |
public function isEqual($other) | |
{ | |
- return !($other instanceof Braintree_Address) ? | |
+ return !($other instanceof self) ? | |
false : | |
($this->id === $other->id && $this->customerId === $other->customerId); | |
} | |
@@ -45,12 +47,12 @@ | |
* create a printable representation of the object as: | |
* ClassName[property=value, property=value] | |
* @ignore | |
- * @return var | |
+ * @return string | |
*/ | |
public function __toString() | |
{ | |
return __CLASS__ . '[' . | |
- Braintree_Util::attributesToString($this->_attributes) .']'; | |
+ Util::attributesToString($this->_attributes) . ']'; | |
} | |
/** | |
@@ -59,7 +61,7 @@ | |
* @ignore | |
* @access protected | |
* @param array $addressAttribs array of address data | |
- * @return none | |
+ * @return void | |
*/ | |
protected function _initialize($addressAttribs) | |
{ | |
@@ -68,10 +70,10 @@ | |
} | |
/** | |
- * factory method: returns an instance of Braintree_Address | |
+ * factory method: returns an instance of Address | |
* to the requesting method, with populated properties | |
* @ignore | |
- * @return object instance of Braintree_Address | |
+ * @return Address | |
*/ | |
public static function factory($attributes) | |
{ | |
@@ -85,64 +87,65 @@ | |
// static methods redirecting to gateway | |
/** | |
- * | |
+ * | |
* @param array $attribs | |
- * @return Braintree_Address | |
+ * @return Address | |
*/ | |
public static function create($attribs) | |
{ | |
- return Braintree_Configuration::gateway()->address()->create($attribs); | |
+ return Configuration::gateway()->address()->create($attribs); | |
} | |
/** | |
- * | |
+ * | |
* @param array $attribs | |
- * @return Braintree_Address | |
+ * @return Address | |
*/ | |
public static function createNoValidate($attribs) | |
{ | |
- return Braintree_Configuration::gateway()->address()->createNoValidate($attribs); | |
+ return Configuration::gateway()->address()->createNoValidate($attribs); | |
} | |
/** | |
- * | |
- * @param Braintree_Customer|int $customerOrId | |
+ * | |
+ * @param Customer|int $customerOrId | |
* @param int $addressId | |
* @throws InvalidArgumentException | |
- * @return Braintree_Result_Successful | |
+ * @return Result\Successful | |
*/ | |
public static function delete($customerOrId = null, $addressId = null) | |
{ | |
- return Braintree_Configuration::gateway()->address()->delete($customerOrId, $addressId); | |
+ return Configuration::gateway()->address()->delete($customerOrId, $addressId); | |
} | |
/** | |
- * | |
- * @param Braintree_Customer|int $customerOrId | |
+ * | |
+ * @param Customer|int $customerOrId | |
* @param int $addressId | |
- * @throws Braintree_Exception_NotFound | |
- * @return Braintree_Address | |
+ * @throws Exception\NotFound | |
+ * @return Address | |
*/ | |
public static function find($customerOrId, $addressId) | |
{ | |
- return Braintree_Configuration::gateway()->address()->find($customerOrId, $addressId); | |
+ return Configuration::gateway()->address()->find($customerOrId, $addressId); | |
} | |
/** | |
- * | |
- * @param Braintree_Customer|int $customerOrId | |
+ * | |
+ * @param Customer|int $customerOrId | |
* @param int $addressId | |
* @param array $attributes | |
- * @throws Braintree_Exception_Unexpected | |
- * @return Braintree_Result_Successful|Braintree_Result_Error | |
+ * @throws Exception\Unexpected | |
+ * @return Result\Successful|Result\Error | |
*/ | |
public static function update($customerOrId, $addressId, $attributes) | |
{ | |
- return Braintree_Configuration::gateway()->address()->update($customerOrId, $addressId, $attributes); | |
+ return Configuration::gateway()->address()->update($customerOrId, $addressId, $attributes); | |
} | |
public static function updateNoValidate($customerOrId, $addressId, $attributes) | |
{ | |
- return Braintree_Configuration::gateway()->address()->updateNoValidate($customerOrId, $addressId, $attributes); | |
+ return Configuration::gateway()->address()->updateNoValidate($customerOrId, $addressId, $attributes); | |
} | |
} | |
+class_alias('Braintree\Address', 'Braintree_Address'); | |
Index: braintree_sdk/lib/Braintree/AddressGateway.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/AddressGateway.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/AddressGateway.php (working copy) | |
@@ -1,4 +1,8 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
+use InvalidArgumentException; | |
+ | |
/** | |
* Braintree AddressGateway module | |
* PHP Version 5 | |
@@ -9,38 +13,38 @@ | |
* as the shipping address when creating a Transaction. | |
* | |
* @package Braintree | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_AddressGateway | |
+class AddressGateway | |
{ | |
/** | |
* | |
- * @var Braintree_Gateway | |
+ * @var Gateway | |
*/ | |
private $_gateway; | |
- | |
+ | |
/** | |
* | |
- * @var Braintree_Configuration | |
+ * @var Configuration | |
*/ | |
private $_config; | |
- | |
+ | |
/** | |
* | |
- * @var Braintree_Http | |
+ * @var Http | |
*/ | |
private $_http; | |
/** | |
- * | |
- * @param Braintree_Gateway $gateway | |
+ * | |
+ * @param Gateway $gateway | |
*/ | |
public function __construct($gateway) | |
{ | |
$this->_gateway = $gateway; | |
$this->_config = $gateway->config; | |
$this->_config->assertHasAccessTokenOrKeys(); | |
- $this->_http = new Braintree_Http($gateway->config); | |
+ $this->_http = new Http($gateway->config); | |
} | |
@@ -49,11 +53,11 @@ | |
* | |
* @access public | |
* @param array $attribs | |
- * @return object Result, either Successful or Error | |
+ * @return Result\Successful|Result\Error | |
*/ | |
public function create($attribs) | |
{ | |
- Braintree_Util::verifyKeys(self::createSignature(), $attribs); | |
+ Util::verifyKeys(self::createSignature(), $attribs); | |
$customerId = isset($attribs['customerId']) ? | |
$attribs['customerId'] : | |
null; | |
@@ -62,23 +66,23 @@ | |
unset($attribs['customerId']); | |
return $this->_doCreate( | |
'/customers/' . $customerId . '/addresses', | |
- array('address' => $attribs) | |
+ ['address' => $attribs] | |
); | |
} | |
/** | |
* attempts the create operation assuming all data will validate | |
- * returns a Braintree_Address object instead of a Result | |
+ * returns a Address object instead of a Result | |
* | |
* @access public | |
* @param array $attribs | |
- * @return object | |
- * @throws Braintree_Exception_ValidationError | |
+ * @return self | |
+ * @throws Exception\ValidationError | |
*/ | |
public function createNoValidate($attribs) | |
{ | |
$result = $this->create($attribs); | |
- return Braintree_Util::returnObjectOrThrowException(__CLASS__, $result); | |
+ return Util::returnObjectOrThrowException(__CLASS__, $result); | |
} | |
@@ -94,7 +98,7 @@ | |
$customerId = $this->_determineCustomerId($customerOrId); | |
$path = $this->_config->merchantPath() . '/customers/' . $customerId . '/addresses/' . $addressId; | |
$this->_http->delete($path); | |
- return new Braintree_Result_Successful(); | |
+ return new Result\Successful(); | |
} | |
/** | |
@@ -108,8 +112,8 @@ | |
* @access public | |
* @param mixed $customerOrId | |
* @param string $addressId | |
- * @return object Braintree_Address | |
- * @throws Braintree_Exception_NotFound | |
+ * @return Address | |
+ * @throws Exception\NotFound | |
*/ | |
public function find($customerOrId, $addressId) | |
{ | |
@@ -120,9 +124,9 @@ | |
try { | |
$path = $this->_config->merchantPath() . '/customers/' . $customerId . '/addresses/' . $addressId; | |
$response = $this->_http->get($path); | |
- return Braintree_Address::factory($response['address']); | |
- } catch (Braintree_Exception_NotFound $e) { | |
- throw new Braintree_Exception_NotFound( | |
+ return Address::factory($response['address']); | |
+ } catch (Exception\NotFound $e) { | |
+ throw new Exception\NotFound( | |
'address for customer ' . $customerId . | |
' with id ' . $addressId . ' not found.' | |
); | |
@@ -142,16 +146,16 @@ | |
* @param array $attributes | |
* @param mixed $customerOrId (only used in call) | |
* @param string $addressId (only used in call) | |
- * @return object Braintree_Result_Successful or Braintree_Result_Error | |
+ * @return Result\Successful|Result\Error | |
*/ | |
public function update($customerOrId, $addressId, $attributes) | |
{ | |
$this->_validateId($addressId); | |
$customerId = $this->_determineCustomerId($customerOrId); | |
- Braintree_Util::verifyKeys(self::updateSignature(), $attributes); | |
+ Util::verifyKeys(self::updateSignature(), $attributes); | |
$path = $this->_config->merchantPath() . '/customers/' . $customerId . '/addresses/' . $addressId; | |
- $response = $this->_http->put($path, array('address' => $attributes)); | |
+ $response = $this->_http->put($path, ['address' => $attributes]); | |
return $this->_verifyGatewayResponse($response); | |
@@ -167,14 +171,14 @@ | |
* @access public | |
* @param array $transactionAttribs | |
* @param string $customerId | |
- * @return object Braintree_Transaction | |
- * @throws Braintree_Exception_ValidationsFailed | |
- * @see Braintree_Address::update() | |
+ * @return Transaction | |
+ * @throws Exception\ValidationsFailed | |
+ * @see Address::update() | |
*/ | |
public function updateNoValidate($customerOrId, $addressId, $attributes) | |
{ | |
$result = $this->update($customerOrId, $addressId, $attributes); | |
- return Braintree_Util::returnObjectOrThrowException(__CLASS__, $result); | |
+ return Util::returnObjectOrThrowException(__CLASS__, $result); | |
} | |
/** | |
@@ -183,11 +187,11 @@ | |
*/ | |
public static function createSignature() | |
{ | |
- return array( | |
+ return [ | |
'company', 'countryCodeAlpha2', 'countryCodeAlpha3', 'countryCodeNumeric', | |
'countryName', 'customerId', 'extendedAddress', 'firstName', | |
'lastName', 'locality', 'postalCode', 'region', 'streetAddress' | |
- ); | |
+ ]; | |
} | |
/** | |
@@ -250,7 +254,7 @@ | |
*/ | |
private function _determineCustomerId($customerOrId) | |
{ | |
- $customerId = ($customerOrId instanceof Braintree_Customer) ? $customerOrId->id : $customerOrId; | |
+ $customerId = ($customerOrId instanceof Customer) ? $customerOrId->id : $customerOrId; | |
$this->_validateCustomerId($customerId); | |
return $customerId; | |
@@ -262,7 +266,7 @@ | |
* @ignore | |
* @param string $subPath | |
* @param array $params | |
- * @return mixed | |
+ * @return Result\Successful|Result\Error | |
*/ | |
private function _doCreate($subPath, $params) | |
{ | |
@@ -276,30 +280,31 @@ | |
/** | |
* generic method for validating incoming gateway responses | |
* | |
- * creates a new Braintree_Address object and encapsulates | |
- * it inside a Braintree_Result_Successful object, or | |
- * encapsulates a Braintree_Errors object inside a Result_Error | |
- * alternatively, throws an Unexpected exception if the response is invalid. | |
+ * creates a new Address object and encapsulates | |
+ * it inside a Result\Successful object, or | |
+ * encapsulates an Errors object inside a Result\Error | |
+ * alternatively, throws an Unexpected exception if the response is invalid | |
* | |
* @ignore | |
* @param array $response gateway response values | |
- * @return object Result_Successful|Result_Error | |
- * @throws Braintree_Exception_Unexpected | |
+ * @return Result\Successful|Result\Error | |
+ * @throws Exception\Unexpected | |
*/ | |
private function _verifyGatewayResponse($response) | |
{ | |
if (isset($response['address'])) { | |
- // return a populated instance of Braintree_Address | |
- return new Braintree_Result_Successful( | |
- Braintree_Address::factory($response['address']) | |
+ // return a populated instance of Address | |
+ return new Result\Successful( | |
+ Address::factory($response['address']) | |
); | |
} else if (isset($response['apiErrorResponse'])) { | |
- return new Braintree_Result_Error($response['apiErrorResponse']); | |
+ return new Result\Error($response['apiErrorResponse']); | |
} else { | |
- throw new Braintree_Exception_Unexpected( | |
+ throw new Exception\Unexpected( | |
"Expected address or apiErrorResponse" | |
); | |
} | |
} | |
} | |
+class_alias('Braintree\AddressGateway', 'Braintree_AddressGateway'); | |
Index: braintree_sdk/lib/Braintree/AmexExpressCheckoutCard.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/AmexExpressCheckoutCard.php (revision 0) | |
+++ braintree_sdk/lib/Braintree/AmexExpressCheckoutCard.php (working copy) | |
@@ -0,0 +1,81 @@ | |
+<?php | |
+namespace Braintree; | |
+ | |
+/** | |
+ * Braintree AmexExpressCheckoutCard module | |
+ * Creates and manages Braintree Amex Express Checkout cards | |
+ * | |
+ * <b>== More information ==</b> | |
+ * | |
+ * See {@link https://developers.braintreepayments.com/javascript+php}<br /> | |
+ * | |
+ * @package Braintree | |
+ * @category Resources | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
+ * | |
+ * @property-read string $createdAt | |
+ * @property-read string $default | |
+ * @property-read string $updatedAt | |
+ * @property-read string $customerId | |
+ * @property-read string $cardType | |
+ * @property-read string $bin | |
+ * @property-read string $cardMemberExpiryDate | |
+ * @property-read string $cardMemberNumber | |
+ * @property-read string $cardType | |
+ * @property-read string $sourceDescription | |
+ * @property-read string $token | |
+ * @property-read string $imageUrl | |
+ * @property-read string $expirationMonth | |
+ * @property-read string $expirationYear | |
+ */ | |
+class AmexExpressCheckoutCard extends Base | |
+{ | |
+ /* instance methods */ | |
+ /** | |
+ * returns false if default is null or false | |
+ * | |
+ * @return boolean | |
+ */ | |
+ public function isDefault() | |
+ { | |
+ return $this->default; | |
+ } | |
+ | |
+ /** | |
+ * factory method: returns an instance of AmexExpressCheckoutCard | |
+ * to the requesting method, with populated properties | |
+ * | |
+ * @ignore | |
+ * @return AmexExpressCheckoutCard | |
+ */ | |
+ public static function factory($attributes) | |
+ { | |
+ | |
+ $instance = new self(); | |
+ $instance->_initialize($attributes); | |
+ return $instance; | |
+ } | |
+ | |
+ /** | |
+ * sets instance properties from an array of values | |
+ * | |
+ * @access protected | |
+ * @param array $amexExpressCheckoutCardAttribs array of Amex Express Checkout card properties | |
+ * @return void | |
+ */ | |
+ protected function _initialize($amexExpressCheckoutCardAttribs) | |
+ { | |
+ // set the attributes | |
+ $this->_attributes = $amexExpressCheckoutCardAttribs; | |
+ | |
+ $subscriptionArray = []; | |
+ if (isset($amexExpressCheckoutCardAttribs['subscriptions'])) { | |
+ foreach ($amexExpressCheckoutCardAttribs['subscriptions'] AS $subscription) { | |
+ $subscriptionArray[] = Subscription::factory($subscription); | |
+ } | |
+ } | |
+ | |
+ $this->_set('subscriptions', $subscriptionArray); | |
+ } | |
+} | |
+class_alias('Braintree\AmexExpressCheckoutCard', 'Braintree_AmexExpressCheckoutCard'); | |
Index: braintree_sdk/lib/Braintree/AndroidPayCard.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/AndroidPayCard.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/AndroidPayCard.php (working copy) | |
@@ -1,4 +1,6 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
/** | |
* Braintree AndroidPayCard module | |
* Creates and manages Braintree Android Pay cards | |
@@ -9,11 +11,12 @@ | |
* | |
* @package Braintree | |
* @category Resources | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
* @property-read string $bin | |
* @property-read string $cardType | |
* @property-read string $createdAt | |
+ * @property-read string $customerId | |
* @property-read string $default | |
* @property-read string $expirationMonth | |
* @property-read string $expirationYear | |
@@ -28,7 +31,7 @@ | |
* @property-read string $virtualCardLast4 | |
* @property-read string $virtualCardType | |
*/ | |
-class Braintree_AndroidPayCard extends Braintree_Base | |
+class AndroidPayCard extends Base | |
{ | |
/* instance methods */ | |
/** | |
@@ -42,20 +45,20 @@ | |
} | |
/** | |
- * factory method: returns an instance of Braintree_AndroidPayCard | |
+ * factory method: returns an instance of AndroidPayCard | |
* to the requesting method, with populated properties | |
* | |
* @ignore | |
- * @return object instance of Braintree_AndroidPayCard | |
+ * @return AndroidPayCard | |
*/ | |
public static function factory($attributes) | |
{ | |
- $defaultAttributes = array( | |
+ $defaultAttributes = [ | |
'expirationMonth' => '', | |
'expirationYear' => '', | |
'last4' => $attributes['virtualCardLast4'], | |
'cardType' => $attributes['virtualCardType'], | |
- ); | |
+ ]; | |
$instance = new self(); | |
$instance->_initialize(array_merge($defaultAttributes, $attributes)); | |
@@ -67,20 +70,21 @@ | |
* | |
* @access protected | |
* @param array $androidPayCardAttribs array of Android Pay card properties | |
- * @return none | |
+ * @return void | |
*/ | |
protected function _initialize($androidPayCardAttribs) | |
{ | |
// set the attributes | |
$this->_attributes = $androidPayCardAttribs; | |
- $subscriptionArray = array(); | |
+ $subscriptionArray = []; | |
if (isset($androidPayCardAttribs['subscriptions'])) { | |
foreach ($androidPayCardAttribs['subscriptions'] AS $subscription) { | |
- $subscriptionArray[] = Braintree_Subscription::factory($subscription); | |
+ $subscriptionArray[] = Subscription::factory($subscription); | |
} | |
} | |
$this->_set('subscriptions', $subscriptionArray); | |
} | |
} | |
+class_alias('Braintree\AndroidPayCard', 'Braintree_AndroidPayCard'); | |
Index: braintree_sdk/lib/Braintree/ApplePayCard.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/ApplePayCard.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/ApplePayCard.php (working copy) | |
@@ -1,4 +1,6 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
/** | |
* Braintree ApplePayCard module | |
* Creates and manages Braintree Apple Pay cards | |
@@ -9,10 +11,11 @@ | |
* | |
* @package Braintree | |
* @category Resources | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
* @property-read string $cardType | |
* @property-read string $createdAt | |
+ * @property-read string $customerId | |
* @property-read string $expirationDate | |
* @property-read string $expirationMonth | |
* @property-read string $expirationYear | |
@@ -23,7 +26,7 @@ | |
* @property-read string $sourceDescription | |
* @property-read string $updatedAt | |
*/ | |
-class Braintree_ApplePayCard extends Braintree_Base | |
+class ApplePayCard extends Base | |
{ | |
// Card Type | |
const AMEX = 'Apple Pay - American Express'; | |
@@ -52,19 +55,19 @@ | |
} | |
/** | |
- * factory method: returns an instance of Braintree_ApplePayCard | |
+ * factory method: returns an instance of ApplePayCard | |
* to the requesting method, with populated properties | |
* | |
* @ignore | |
- * @return object instance of Braintree_ApplePayCard | |
+ * @return ApplePayCard | |
*/ | |
public static function factory($attributes) | |
{ | |
- $defaultAttributes = array( | |
+ $defaultAttributes = [ | |
'expirationMonth' => '', | |
'expirationYear' => '', | |
'last4' => '', | |
- ); | |
+ ]; | |
$instance = new self(); | |
$instance->_initialize(array_merge($defaultAttributes, $attributes)); | |
@@ -76,17 +79,17 @@ | |
* | |
* @access protected | |
* @param array $applePayCardAttribs array of Apple Pay card properties | |
- * @return none | |
+ * @return void | |
*/ | |
protected function _initialize($applePayCardAttribs) | |
{ | |
// set the attributes | |
$this->_attributes = $applePayCardAttribs; | |
- $subscriptionArray = array(); | |
+ $subscriptionArray = []; | |
if (isset($applePayCardAttribs['subscriptions'])) { | |
foreach ($applePayCardAttribs['subscriptions'] AS $subscription) { | |
- $subscriptionArray[] = Braintree_Subscription::factory($subscription); | |
+ $subscriptionArray[] = Subscription::factory($subscription); | |
} | |
} | |
@@ -94,3 +97,4 @@ | |
$this->_set('expirationDate', $this->expirationMonth . '/' . $this->expirationYear); | |
} | |
} | |
+class_alias('Braintree\ApplePayCard', 'Braintree_ApplePayCard'); | |
Index: braintree_sdk/lib/Braintree/Base.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Base.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Base.php (working copy) | |
@@ -1,17 +1,24 @@ | |
<?php | |
+namespace Braintree; | |
/** | |
- * Base functionality for library classes | |
+ * Braintree PHP Library. | |
+ * | |
+ * Braintree base class and initialization | |
+ * Provides methods to child classes. This class cannot be instantiated. | |
+ * | |
+ * PHP version 5 | |
+ * | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-abstract class Braintree_Base | |
+abstract class Base | |
{ | |
+ protected $_attributes = []; | |
+ | |
/** | |
- * Disable the default constructor | |
- * | |
- * Objects that inherit from Braintree_Base should be constructed with | |
- * the static factory() method. | |
- * | |
* @ignore | |
+ * don't permit an explicit call of the constructor! | |
+ * (like $t = new Transaction()) | |
*/ | |
protected function __construct() | |
{ | |
Index: braintree_sdk/lib/Braintree/ClientToken.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/ClientToken.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/ClientToken.php (working copy) | |
@@ -1,6 +1,7 @@ | |
<?php | |
+namespace Braintree; | |
-class Braintree_ClientToken | |
+class ClientToken | |
{ | |
const DEFAULT_VERSION = 2; | |
@@ -8,40 +9,41 @@ | |
// static methods redirecting to gateway | |
/** | |
- * | |
+ * | |
* @param array $params | |
* @return array | |
*/ | |
- public static function generate($params=array()) | |
+ public static function generate($params=[]) | |
{ | |
- return Braintree_Configuration::gateway()->clientToken()->generate($params); | |
+ return Configuration::gateway()->clientToken()->generate($params); | |
} | |
/** | |
- * | |
+ * | |
* @param type $params | |
* @throws InvalidArgumentException | |
*/ | |
public static function conditionallyVerifyKeys($params) | |
{ | |
- return Braintree_Configuration::gateway()->clientToken()->conditionallyVerifyKeys($params); | |
+ return Configuration::gateway()->clientToken()->conditionallyVerifyKeys($params); | |
} | |
/** | |
- * | |
+ * | |
* @return string client token retrieved from server | |
*/ | |
public static function generateWithCustomerIdSignature() | |
{ | |
- return Braintree_Configuration::gateway()->clientToken()->generateWithCustomerIdSignature(); | |
+ return Configuration::gateway()->clientToken()->generateWithCustomerIdSignature(); | |
} | |
/** | |
- * | |
+ * | |
* @return string client token retrieved from server | |
*/ | |
public static function generateWithoutCustomerIdSignature() | |
{ | |
- return Braintree_Configuration::gateway()->clientToken()->generateWithoutCustomerIdSignature(); | |
+ return Configuration::gateway()->clientToken()->generateWithoutCustomerIdSignature(); | |
} | |
} | |
+class_alias('Braintree\ClientToken', 'Braintree_ClientToken'); | |
Index: braintree_sdk/lib/Braintree/ClientTokenGateway.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/ClientTokenGateway.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/ClientTokenGateway.php (working copy) | |
@@ -1,45 +1,48 @@ | |
<?php | |
+namespace Braintree; | |
-class Braintree_ClientTokenGateway | |
+use InvalidArgumentException; | |
+ | |
+class ClientTokenGateway | |
{ | |
/** | |
* | |
- * @var Braintree_Gateway | |
+ * @var Gateway | |
*/ | |
private $_gateway; | |
/** | |
* | |
- * @var Braintree_Configuration | |
+ * @var Configuration | |
*/ | |
private $_config; | |
/** | |
* | |
- * @var Braintree_Http | |
+ * @var Http | |
*/ | |
private $_http; | |
/** | |
* | |
- * @param Braintree_Gateway $gateway | |
+ * @param Gateway $gateway | |
*/ | |
public function __construct($gateway) | |
{ | |
$this->_gateway = $gateway; | |
$this->_config = $gateway->config; | |
$this->_config->assertHasAccessTokenOrKeys(); | |
- $this->_http = new Braintree_Http($gateway->config); | |
+ $this->_http = new Http($gateway->config); | |
} | |
- public function generate($params=array()) | |
+ public function generate($params=[]) | |
{ | |
if (!array_key_exists("version", $params)) { | |
- $params["version"] = Braintree_ClientToken::DEFAULT_VERSION; | |
+ $params["version"] = ClientToken::DEFAULT_VERSION; | |
} | |
$this->conditionallyVerifyKeys($params); | |
- $generateParams = array("client_token" => $params); | |
+ $generateParams = ["client_token" => $params]; | |
return $this->_doGenerate('/client_token', $generateParams); | |
} | |
@@ -68,9 +71,9 @@ | |
public function conditionallyVerifyKeys($params) | |
{ | |
if (array_key_exists("customerId", $params)) { | |
- Braintree_Util::verifyKeys($this->generateWithCustomerIdSignature(), $params); | |
+ Util::verifyKeys($this->generateWithCustomerIdSignature(), $params); | |
} else { | |
- Braintree_Util::verifyKeys($this->generateWithoutCustomerIdSignature(), $params); | |
+ Util::verifyKeys($this->generateWithoutCustomerIdSignature(), $params); | |
} | |
} | |
@@ -80,10 +83,10 @@ | |
*/ | |
public function generateWithCustomerIdSignature() | |
{ | |
- return array( | |
+ return [ | |
"version", "customerId", "proxyMerchantId", | |
- array("options" => array("makeDefault", "verifyCard", "failOnDuplicatePaymentMethod")), | |
- "merchantAccountId", "sepaMandateType", "sepaMandateAcceptanceLocation"); | |
+ ["options" => ["makeDefault", "verifyCard", "failOnDuplicatePaymentMethod"]], | |
+ "merchantAccountId", "sepaMandateType", "sepaMandateAcceptanceLocation"]; | |
} | |
/** | |
@@ -92,7 +95,7 @@ | |
*/ | |
public function generateWithoutCustomerIdSignature() | |
{ | |
- return array("version", "proxyMerchantId", "merchantAccountId"); | |
+ return ["version", "proxyMerchantId", "merchantAccountId"]; | |
} | |
/** | |
@@ -116,10 +119,11 @@ | |
$response['apiErrorResponse']['message'] | |
); | |
} else { | |
- throw new Braintree_Exception_Unexpected( | |
+ throw new Exception\Unexpected( | |
"Expected clientToken or apiErrorResponse" | |
); | |
} | |
} | |
} | |
+class_alias('Braintree\ClientTokenGateway', 'Braintree_ClientTokenGateway'); | |
Index: braintree_sdk/lib/Braintree/CoinbaseAccount.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/CoinbaseAccount.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/CoinbaseAccount.php (working copy) | |
@@ -1,10 +1,12 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
/** | |
* Braintree CoinbaseAccount module | |
* | |
* @package Braintree | |
* @category Resources | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
/** | |
@@ -15,21 +17,22 @@ | |
* | |
* @package Braintree | |
* @category Resources | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
+ * @property-read string $customerId | |
* @property-read string $token | |
* @property-read string $userId | |
* @property-read string $userName | |
* @property-read string $userEmail | |
*/ | |
-class Braintree_CoinbaseAccount extends Braintree_Base | |
+class CoinbaseAccount extends Base | |
{ | |
/** | |
- * factory method: returns an instance of Braintree_CoinbaseAccount | |
+ * factory method: returns an instance of CoinbaseAccount | |
* to the requesting method, with populated properties | |
* | |
* @ignore | |
- * @return object instance of Braintree_CoinbaseAccount | |
+ * @return CoinbaseAccount | |
*/ | |
public static function factory($attributes) | |
{ | |
@@ -55,17 +58,17 @@ | |
* | |
* @access protected | |
* @param array $coinbaseAccountAttribs array of coinbaseAccount data | |
- * @return none | |
+ * @return void | |
*/ | |
protected function _initialize($coinbaseAccountAttribs) | |
{ | |
// set the attributes | |
$this->_attributes = $coinbaseAccountAttribs; | |
- $subscriptionArray = array(); | |
+ $subscriptionArray = []; | |
if (isset($coinbaseAccountAttribs['subscriptions'])) { | |
foreach ($coinbaseAccountAttribs['subscriptions'] AS $subscription) { | |
- $subscriptionArray[] = Braintree_Subscription::factory($subscription); | |
+ $subscriptionArray[] = Subscription::factory($subscription); | |
} | |
} | |
@@ -80,7 +83,7 @@ | |
public function __toString() | |
{ | |
return __CLASS__ . '[' . | |
- Braintree_Util::attributesToString($this->_attributes) .']'; | |
+ Util::attributesToString($this->_attributes) .']'; | |
} | |
@@ -88,21 +91,22 @@ | |
public static function find($token) | |
{ | |
- return Braintree_Configuration::gateway()->coinbaseAccount()->find($token); | |
+ return Configuration::gateway()->coinbaseAccount()->find($token); | |
} | |
public static function update($token, $attributes) | |
{ | |
- return Braintree_Configuration::gateway()->coinbaseAccount()->update($token, $attributes); | |
+ return Configuration::gateway()->coinbaseAccount()->update($token, $attributes); | |
} | |
public static function delete($token) | |
{ | |
- return Braintree_Configuration::gateway()->coinbaseAccount()->delete($token); | |
+ return Configuration::gateway()->coinbaseAccount()->delete($token); | |
} | |
public static function sale($token, $transactionAttribs) | |
{ | |
- return Braintree_Configuration::gateway()->coinbaseAccount()->sale($token, $transactionAttribs); | |
+ return Configuration::gateway()->coinbaseAccount()->sale($token, $transactionAttribs); | |
} | |
} | |
+class_alias('Braintree\CoinbaseAccount', 'Braintree_CoinbaseAccount'); | |
Index: braintree_sdk/lib/Braintree/Collection.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Collection.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Collection.php (working copy) | |
@@ -1,4 +1,12 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
+use Countable; | |
+use IteratorAggregate; | |
+use ArrayAccess; | |
+use OutOfRangeException; | |
+use ArrayIterator; | |
+ | |
/** | |
* Braintree Generic collection | |
* | |
@@ -9,16 +17,16 @@ | |
* | |
* @package Braintree | |
* @subpackage Utility | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_Collection implements Countable, IteratorAggregate, ArrayAccess | |
+class Collection implements Countable, IteratorAggregate, ArrayAccess | |
{ | |
/** | |
* | |
- * @var array $_collection collection storage | |
+ * @var array collection storage | |
*/ | |
- protected $_collection = array(); | |
+ protected $_collection = []; | |
/** | |
* Add a value into the collection | |
@@ -151,3 +159,4 @@ | |
} | |
} | |
+class_alias('Braintree\Collection', 'Braintree_Collection'); | |
Index: braintree_sdk/lib/Braintree/Configuration.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Configuration.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Configuration.php (working copy) | |
@@ -1,14 +1,16 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
/** | |
* | |
* Configuration registry | |
* | |
* @package Braintree | |
* @subpackage Utility | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_Configuration | |
+class Configuration | |
{ | |
public static $global; | |
@@ -19,6 +21,9 @@ | |
private $_clientId = null; | |
private $_clientSecret = null; | |
private $_accessToken = null; | |
+ private $_proxyHost = null; | |
+ private $_proxyPort = null; | |
+ private $_proxyType = null; | |
/** | |
* Braintree API version to use | |
@@ -26,11 +31,11 @@ | |
*/ | |
const API_VERSION = 4; | |
- public function __construct($attribs = array()) | |
+ public function __construct($attribs = []) | |
{ | |
foreach ($attribs as $kind => $value) { | |
if ($kind == 'environment') { | |
- Braintree_CredentialsParser::assertValidEnvironment($value); | |
+ CredentialsParser::assertValidEnvironment($value); | |
$this->_environment = $value; | |
} | |
if ($kind == 'merchantId') { | |
@@ -46,9 +51,9 @@ | |
if (isset($attribs['clientId']) || isset($attribs['accessToken'])) { | |
if (isset($attribs['environment']) || isset($attribs['merchantId']) || isset($attribs['publicKey']) || isset($attribs['privateKey'])) { | |
- throw new Braintree_Exception_Configuration('Cannot mix OAuth credentials (clientId, clientSecret, accessToken) with key credentials (publicKey, privateKey, environment, merchantId).'); | |
+ throw new Exception\Configuration('Cannot mix OAuth credentials (clientId, clientSecret, accessToken) with key credentials (publicKey, privateKey, environment, merchantId).'); | |
} | |
- $parsedCredentials = new Braintree_CredentialsParser($attribs); | |
+ $parsedCredentials = new CredentialsParser($attribs); | |
$this->_environment = $parsedCredentials->getEnvironment(); | |
$this->_merchantId = $parsedCredentials->getMerchantId(); | |
@@ -64,12 +69,12 @@ | |
*/ | |
public static function reset() | |
{ | |
- self::$global = new Braintree_Configuration(); | |
+ self::$global = new Configuration(); | |
} | |
public static function gateway() | |
{ | |
- return new Braintree_Gateway(self::$global); | |
+ return new Gateway(self::$global); | |
} | |
public static function environment($value=null) | |
@@ -77,7 +82,7 @@ | |
if (empty($value)) { | |
return self::$global->getEnvironment(); | |
} | |
- Braintree_CredentialsParser::assertValidEnvironment($value); | |
+ CredentialsParser::assertValidEnvironment($value); | |
self::$global->setEnvironment($value); | |
} | |
@@ -105,6 +110,61 @@ | |
self::$global->setPrivateKey($value); | |
} | |
+ /** | |
+ * Sets or gets the proxy host to use for connecting to Braintree | |
+ * | |
+ * @param string $value If provided, sets the proxy host | |
+ * @return string The proxy host used for connecting to Braintree | |
+ */ | |
+ public static function proxyHost($value = null) | |
+ { | |
+ if (empty($value)) { | |
+ return self::$global->getProxyHost(); | |
+ } | |
+ self::$global->setProxyHost($value); | |
+ } | |
+ | |
+ /** | |
+ * Sets or gets the port of the proxy to use for connecting to Braintree | |
+ * | |
+ * @param string $value If provided, sets the port of the proxy | |
+ * @return string The port of the proxy used for connecting to Braintree | |
+ */ | |
+ public static function proxyPort($value = null) | |
+ { | |
+ if (empty($value)) { | |
+ return self::$global->getProxyPort(); | |
+ } | |
+ self::$global->setProxyPort($value); | |
+ } | |
+ | |
+ /** | |
+ * Sets or gets the proxy type to use for connecting to Braintree. This value | |
+ * can be any of the CURLOPT_PROXYTYPE options in PHP cURL. | |
+ * | |
+ * @param string $value If provided, sets the proxy type | |
+ * @return string The proxy type used for connecting to Braintree | |
+ */ | |
+ public static function proxyType($value = null) | |
+ { | |
+ if (empty($value)) { | |
+ return self::$global->getProxyType(); | |
+ } | |
+ self::$global->setProxyType($value); | |
+ } | |
+ | |
+ /** | |
+ * Specifies whether or not a proxy is properly configured | |
+ * | |
+ * @return bool true if a proxy is configured properly, false if not | |
+ */ | |
+ public static function isUsingProxy() | |
+ { | |
+ $proxyHost = self::$global->getProxyHost(); | |
+ $proxyPort = self::$global->getProxyPort(); | |
+ return !empty($proxyHost) && !empty($proxyPort); | |
+ } | |
+ | |
public static function assertGlobalHasAccessTokenOrKeys() | |
{ | |
self::$global->assertHasAccessTokenOrKeys(); | |
@@ -114,13 +174,13 @@ | |
{ | |
if (empty($this->_accessToken)) { | |
if (empty($this->_merchantId)) { | |
- throw new Braintree_Exception_Configuration('Braintree_Configuration::merchantId needs to be set (or accessToken needs to be passed to Braintree_Gateway).'); | |
+ throw new Exception\Configuration('Braintree\\Configuration::merchantId needs to be set (or accessToken needs to be passed to Braintree\\Gateway).'); | |
} else if (empty($this->_environment)) { | |
- throw new Braintree_Exception_Configuration('Braintree_Configuration::environment needs to be set.'); | |
+ throw new Exception\Configuration('Braintree\\Configuration::environment needs to be set.'); | |
} else if (empty($this->_publicKey)) { | |
- throw new Braintree_Exception_Configuration('Braintree_Configuration::publicKey needs to be set.'); | |
+ throw new Exception\Configuration('Braintree\\Configuration::publicKey needs to be set.'); | |
} else if (empty($this->_privateKey)) { | |
- throw new Braintree_Exception_Configuration('Braintree_Configuration::privateKey needs to be set.'); | |
+ throw new Exception\Configuration('Braintree\\Configuration::privateKey needs to be set.'); | |
} | |
} | |
} | |
@@ -134,14 +194,14 @@ | |
public function assertHasClientId() | |
{ | |
if (empty($this->_clientId)) { | |
- throw new Braintree_Exception_Configuration('clientId needs to be passed to Braintree_Gateway.'); | |
+ throw new Exception\Configuration('clientId needs to be passed to Braintree\\Gateway.'); | |
} | |
} | |
public function assertHasClientSecret() | |
{ | |
if (empty($this->_clientSecret)) { | |
- throw new Braintree_Exception_Configuration('clientSecret needs to be passed to Braintree_Gateway.'); | |
+ throw new Exception\Configuration('clientSecret needs to be passed to Braintree\\Gateway.'); | |
} | |
} | |
@@ -207,6 +267,36 @@ | |
$this->_privateKey = $value; | |
} | |
+ private function setProxyHost($value) | |
+ { | |
+ $this->_proxyHost = $value; | |
+ } | |
+ | |
+ public function getProxyHost() | |
+ { | |
+ return $this->_proxyHost; | |
+ } | |
+ | |
+ private function setProxyPort($value) | |
+ { | |
+ $this->_proxyPort = $value; | |
+ } | |
+ | |
+ public function getProxyPort() | |
+ { | |
+ return $this->_proxyPort; | |
+ } | |
+ | |
+ private function setProxyType($value) | |
+ { | |
+ $this->_proxyType = $value; | |
+ } | |
+ | |
+ public function getProxyType() | |
+ { | |
+ return $this->_proxyType; | |
+ } | |
+ | |
public function getAccessToken() | |
{ | |
return $this->_accessToken; | |
@@ -242,7 +332,7 @@ | |
*/ | |
public function merchantPath() | |
{ | |
- return '/merchants/'.$this->_merchantId; | |
+ return '/merchants/' . $this->_merchantId; | |
} | |
/** | |
@@ -256,15 +346,11 @@ | |
{ | |
$sslPath = $sslPath ? $sslPath : DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . | |
'ssl' . DIRECTORY_SEPARATOR; | |
+ $caPath = __DIR__ . $sslPath . 'api_braintreegateway_com.ca.crt'; | |
- $caPath = realpath( | |
- dirname(__FILE__) . | |
- $sslPath . 'api_braintreegateway_com.ca.crt' | |
- ); | |
- | |
if (!file_exists($caPath)) | |
{ | |
- throw new Braintree_Exception_SSLCaFileNotFound(); | |
+ throw new Exception\SSLCaFileNotFound(); | |
} | |
return $caPath; | |
@@ -385,4 +471,5 @@ | |
error_log('[Braintree] ' . $message); | |
} | |
} | |
-Braintree_Configuration::reset(); | |
+Configuration::reset(); | |
+class_alias('Braintree\Configuration', 'Braintree_Configuration'); | |
Index: braintree_sdk/lib/Braintree/CredentialsParser.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/CredentialsParser.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/CredentialsParser.php (working copy) | |
@@ -1,14 +1,16 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
/** | |
* | |
* CredentialsParser registry | |
* | |
* @package Braintree | |
* @subpackage Utility | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_CredentialsParser | |
+class CredentialsParser | |
{ | |
private $_clientId; | |
private $_clientSecret; | |
@@ -38,32 +40,32 @@ | |
* @static | |
* @var array valid environments, used for validation | |
*/ | |
- private static $_validEnvironments = array( | |
+ private static $_validEnvironments = [ | |
'development', | |
'integration', | |
'sandbox', | |
'production', | |
'qa', | |
- ); | |
+ ]; | |
public function parse() | |
{ | |
- $environments = array(); | |
+ $environments = []; | |
if (!empty($this->_clientId)) { | |
- $environments[] = array('clientId', $this->_parseClientCredential('clientId', $this->_clientId, 'client_id')); | |
+ $environments[] = ['clientId', $this->_parseClientCredential('clientId', $this->_clientId, 'client_id')]; | |
} | |
if (!empty($this->_clientSecret)) { | |
- $environments[] = array('clientSecret', $this->_parseClientCredential('clientSecret', $this->_clientSecret, 'client_secret')); | |
+ $environments[] = ['clientSecret', $this->_parseClientCredential('clientSecret', $this->_clientSecret, 'client_secret')]; | |
} | |
if (!empty($this->_accessToken)) { | |
- $environments[] = array('accessToken', $this->_parseAccessToken()); | |
+ $environments[] = ['accessToken', $this->_parseAccessToken()]; | |
} | |
$checkEnv = $environments[0]; | |
foreach ($environments as $env) { | |
if ($env[1] !== $checkEnv[1]) { | |
- throw new Braintree_Exception_Configuration( | |
+ throw new Exception\Configuration( | |
'Mismatched credential environments: ' . $checkEnv[0] . ' environment is ' . $checkEnv[1] . | |
' and ' . $env[0] . ' environment is ' . $env[1]); | |
} | |
@@ -75,7 +77,7 @@ | |
public static function assertValidEnvironment($environment) { | |
if (!in_array($environment, self::$_validEnvironments)) { | |
- throw new Braintree_Exception_Configuration('"' . | |
+ throw new Exception\Configuration('"' . | |
$environment . '" is not a valid environment.'); | |
} | |
} | |
@@ -84,7 +86,7 @@ | |
{ | |
$explodedCredential = explode('$', $value); | |
if (sizeof($explodedCredential) != 3) { | |
- throw new Braintree_Exception_Configuration('Incorrect ' . $credentialType . ' format. Expected: type$environment$token'); | |
+ throw new Exception\Configuration('Incorrect ' . $credentialType . ' format. Expected: type$environment$token'); | |
} | |
$gotValuePrefix = $explodedCredential[0]; | |
@@ -92,7 +94,7 @@ | |
$token = $explodedCredential[2]; | |
if ($gotValuePrefix != $expectedValuePrefix) { | |
- throw new Braintree_Exception_Configuration('Value passed for ' . $credentialType . ' is not a ' . $credentialType); | |
+ throw new Exception\Configuration('Value passed for ' . $credentialType . ' is not a ' . $credentialType); | |
} | |
return $environment; | |
@@ -102,7 +104,7 @@ | |
{ | |
$accessTokenExploded = explode('$', $this->_accessToken); | |
if (sizeof($accessTokenExploded) != 4) { | |
- throw new Braintree_Exception_Configuration('Incorrect accessToken syntax. Expected: type$environment$merchant_id$token'); | |
+ throw new Exception\Configuration('Incorrect accessToken syntax. Expected: type$environment$merchant_id$token'); | |
} | |
$gotValuePrefix = $accessTokenExploded[0]; | |
@@ -111,7 +113,7 @@ | |
$token = $accessTokenExploded[3]; | |
if ($gotValuePrefix != 'access_token') { | |
- throw new Braintree_Exception_Configuration('Value passed for accessToken is not an accessToken'); | |
+ throw new Exception\Configuration('Value passed for accessToken is not an accessToken'); | |
} | |
$this->_merchantId = $merchantId; | |
@@ -143,3 +145,4 @@ | |
return $this->_merchantId; | |
} | |
} | |
+class_alias('Braintree\CredentialsParser', 'Braintree_CredentialsParser'); | |
Index: braintree_sdk/lib/Braintree/CreditCard.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/CreditCard.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/CreditCard.php (working copy) | |
@@ -1,4 +1,6 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
/** | |
* Braintree CreditCard module | |
* Creates and manages Braintree CreditCards | |
@@ -10,7 +12,7 @@ | |
* | |
* @package Braintree | |
* @category Resources | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
* @property-read string $billingAddress | |
* @property-read string $bin | |
@@ -27,7 +29,7 @@ | |
* @property-read string $token | |
* @property-read string $updatedAt | |
*/ | |
-class Braintree_CreditCard extends Braintree_Base | |
+class CreditCard extends Base | |
{ | |
// Card Type | |
const AMEX = 'American Express'; | |
@@ -111,7 +113,7 @@ | |
* | |
* @access protected | |
* @param array $creditCardAttribs array of creditcard data | |
- * @return none | |
+ * @return void | |
*/ | |
protected function _initialize($creditCardAttribs) | |
{ | |
@@ -120,13 +122,13 @@ | |
// map each address into its own object | |
$billingAddress = isset($creditCardAttribs['billingAddress']) ? | |
- Braintree_Address::factory($creditCardAttribs['billingAddress']) : | |
+ Address::factory($creditCardAttribs['billingAddress']) : | |
null; | |
- $subscriptionArray = array(); | |
+ $subscriptionArray = []; | |
if (isset($creditCardAttribs['subscriptions'])) { | |
foreach ($creditCardAttribs['subscriptions'] AS $subscription) { | |
- $subscriptionArray[] = Braintree_Subscription::factory($subscription); | |
+ $subscriptionArray[] = Subscription::factory($subscription); | |
} | |
} | |
@@ -137,9 +139,9 @@ | |
if(isset($creditCardAttribs['verifications']) && count($creditCardAttribs['verifications']) > 0) { | |
$verifications = $creditCardAttribs['verifications']; | |
- usort($verifications, array($this, '_compareCreatedAtOnVerifications')); | |
+ usort($verifications, [$this, '_compareCreatedAtOnVerifications']); | |
- $this->_set('verification', Braintree_CreditCardVerification::factory($verifications[0])); | |
+ $this->_set('verification', CreditCardVerification::factory($verifications[0])); | |
} | |
} | |
@@ -149,15 +151,15 @@ | |
} | |
/** | |
- * returns false if comparing object is not a Braintree_CreditCard, | |
- * or is a Braintree_CreditCard with a different id | |
+ * returns false if comparing object is not a CreditCard, | |
+ * or is a CreditCard with a different id | |
* | |
* @param object $otherCreditCard customer to compare against | |
* @return boolean | |
*/ | |
public function isEqual($otherCreditCard) | |
{ | |
- return !($otherCreditCard instanceof Braintree_CreditCard) ? false : $this->token === $otherCreditCard->token; | |
+ return !($otherCreditCard instanceof self) ? false : $this->token === $otherCreditCard->token; | |
} | |
/** | |
@@ -168,24 +170,24 @@ | |
public function __toString() | |
{ | |
return __CLASS__ . '[' . | |
- Braintree_Util::attributesToString($this->_attributes) .']'; | |
+ Util::attributesToString($this->_attributes) .']'; | |
} | |
/** | |
- * factory method: returns an instance of Braintree_CreditCard | |
+ * factory method: returns an instance of CreditCard | |
* to the requesting method, with populated properties | |
* | |
* @ignore | |
- * @return object instance of Braintree_CreditCard | |
+ * @return CreditCard | |
*/ | |
public static function factory($attributes) | |
{ | |
- $defaultAttributes = array( | |
+ $defaultAttributes = [ | |
'bin' => '', | |
'expirationMonth' => '', | |
'expirationYear' => '', | |
'last4' => '', | |
- ); | |
+ ]; | |
$instance = new self(); | |
$instance->_initialize(array_merge($defaultAttributes, $attributes)); | |
@@ -197,115 +199,117 @@ | |
public static function create($attribs) | |
{ | |
- return Braintree_Configuration::gateway()->creditCard()->create($attribs); | |
+ return Configuration::gateway()->creditCard()->create($attribs); | |
} | |
public static function createNoValidate($attribs) | |
{ | |
- return Braintree_Configuration::gateway()->creditCard()->createNoValidate($attribs); | |
+ return Configuration::gateway()->creditCard()->createNoValidate($attribs); | |
} | |
public static function createFromTransparentRedirect($queryString) | |
{ | |
- return Braintree_Configuration::gateway()->creditCard()->createFromTransparentRedirect($queryString); | |
+ return Configuration::gateway()->creditCard()->createFromTransparentRedirect($queryString); | |
} | |
public static function createCreditCardUrl() | |
{ | |
- return Braintree_Configuration::gateway()->creditCard()->createCreditCardUrl(); | |
+ return Configuration::gateway()->creditCard()->createCreditCardUrl(); | |
} | |
public static function expired() | |
{ | |
- return Braintree_Configuration::gateway()->creditCard()->expired(); | |
+ return Configuration::gateway()->creditCard()->expired(); | |
} | |
public static function fetchExpired($ids) | |
{ | |
- return Braintree_Configuration::gateway()->creditCard()->fetchExpired($ids); | |
+ return Configuration::gateway()->creditCard()->fetchExpired($ids); | |
} | |
public static function expiringBetween($startDate, $endDate) | |
{ | |
- return Braintree_Configuration::gateway()->creditCard()->expiringBetween($startDate, $endDate); | |
+ return Configuration::gateway()->creditCard()->expiringBetween($startDate, $endDate); | |
} | |
public static function fetchExpiring($startDate, $endDate, $ids) | |
{ | |
- return Braintree_Configuration::gateway()->creditCard()->fetchExpiring($startDate, $endDate, $ids); | |
+ return Configuration::gateway()->creditCard()->fetchExpiring($startDate, $endDate, $ids); | |
} | |
public static function find($token) | |
{ | |
- return Braintree_Configuration::gateway()->creditCard()->find($token); | |
+ return Configuration::gateway()->creditCard()->find($token); | |
} | |
public static function fromNonce($nonce) | |
{ | |
- return Braintree_Configuration::gateway()->creditCard()->fromNonce($nonce); | |
+ return Configuration::gateway()->creditCard()->fromNonce($nonce); | |
} | |
public static function credit($token, $transactionAttribs) | |
{ | |
- return Braintree_Configuration::gateway()->creditCard()->credit($token, $transactionAttribs); | |
+ return Configuration::gateway()->creditCard()->credit($token, $transactionAttribs); | |
} | |
public static function creditNoValidate($token, $transactionAttribs) | |
{ | |
- return Braintree_Configuration::gateway()->creditCard()->creditNoValidate($token, $transactionAttribs); | |
+ return Configuration::gateway()->creditCard()->creditNoValidate($token, $transactionAttribs); | |
} | |
public static function sale($token, $transactionAttribs) | |
{ | |
- return Braintree_Configuration::gateway()->creditCard()->sale($token, $transactionAttribs); | |
+ return Configuration::gateway()->creditCard()->sale($token, $transactionAttribs); | |
} | |
public static function saleNoValidate($token, $transactionAttribs) | |
{ | |
- return Braintree_Configuration::gateway()->creditCard()->saleNoValidate($token, $transactionAttribs); | |
+ return Configuration::gateway()->creditCard()->saleNoValidate($token, $transactionAttribs); | |
} | |
public static function update($token, $attributes) | |
{ | |
- return Braintree_Configuration::gateway()->creditCard()->update($token, $attributes); | |
+ return Configuration::gateway()->creditCard()->update($token, $attributes); | |
} | |
public static function updateNoValidate($token, $attributes) | |
{ | |
- return Braintree_Configuration::gateway()->creditCard()->updateNoValidate($token, $attributes); | |
+ return Configuration::gateway()->creditCard()->updateNoValidate($token, $attributes); | |
} | |
public static function updateCreditCardUrl() | |
{ | |
- return Braintree_Configuration::gateway()->creditCard()->updateCreditCardUrl(); | |
+ return Configuration::gateway()->creditCard()->updateCreditCardUrl(); | |
} | |
public static function updateFromTransparentRedirect($queryString) | |
{ | |
- return Braintree_Configuration::gateway()->creditCard()->updateFromTransparentRedirect($queryString); | |
+ return Configuration::gateway()->creditCard()->updateFromTransparentRedirect($queryString); | |
} | |
public static function delete($token) | |
{ | |
- return Braintree_Configuration::gateway()->creditCard()->delete($token); | |
+ return Configuration::gateway()->creditCard()->delete($token); | |
} | |
+ /** @return array */ | |
public static function allCardTypes() | |
{ | |
- return array( | |
- Braintree_CreditCard::AMEX, | |
- Braintree_CreditCard::CARTE_BLANCHE, | |
- Braintree_CreditCard::CHINA_UNION_PAY, | |
- Braintree_CreditCard::DINERS_CLUB_INTERNATIONAL, | |
- Braintree_CreditCard::DISCOVER, | |
- Braintree_CreditCard::JCB, | |
- Braintree_CreditCard::LASER, | |
- Braintree_CreditCard::MAESTRO, | |
- Braintree_CreditCard::MASTER_CARD, | |
- Braintree_CreditCard::SOLO, | |
- Braintree_CreditCard::SWITCH_TYPE, | |
- Braintree_CreditCard::VISA, | |
- Braintree_CreditCard::UNKNOWN | |
- ); | |
+ return [ | |
+ CreditCard::AMEX, | |
+ CreditCard::CARTE_BLANCHE, | |
+ CreditCard::CHINA_UNION_PAY, | |
+ CreditCard::DINERS_CLUB_INTERNATIONAL, | |
+ CreditCard::DISCOVER, | |
+ CreditCard::JCB, | |
+ CreditCard::LASER, | |
+ CreditCard::MAESTRO, | |
+ CreditCard::MASTER_CARD, | |
+ CreditCard::SOLO, | |
+ CreditCard::SWITCH_TYPE, | |
+ CreditCard::VISA, | |
+ CreditCard::UNKNOWN | |
+ ]; | |
} | |
} | |
+class_alias('Braintree\CreditCard', 'Braintree_CreditCard'); | |
Index: braintree_sdk/lib/Braintree/CreditCardGateway.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/CreditCardGateway.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/CreditCardGateway.php (working copy) | |
@@ -1,4 +1,8 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
+use InvalidArgumentException; | |
+ | |
/** | |
* Braintree CreditCardGateway module | |
* Creates and manages Braintree CreditCards | |
@@ -10,9 +14,9 @@ | |
* | |
* @package Braintree | |
* @category Resources | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_CreditCardGateway | |
+class CreditCardGateway | |
{ | |
private $_gateway; | |
private $_config; | |
@@ -23,84 +27,86 @@ | |
$this->_gateway = $gateway; | |
$this->_config = $gateway->config; | |
$this->_config->assertHasAccessTokenOrKeys(); | |
- $this->_http = new Braintree_Http($gateway->config); | |
+ $this->_http = new Http($gateway->config); | |
} | |
public function create($attribs) | |
{ | |
- Braintree_Util::verifyKeys(self::createSignature(), $attribs); | |
- return $this->_doCreate('/payment_methods', array('credit_card' => $attribs)); | |
+ Util::verifyKeys(self::createSignature(), $attribs); | |
+ return $this->_doCreate('/payment_methods', ['credit_card' => $attribs]); | |
} | |
/** | |
* attempts the create operation assuming all data will validate | |
- * returns a Braintree_CreditCard object instead of a Result | |
+ * returns a CreditCard object instead of a Result | |
* | |
* @access public | |
* @param array $attribs | |
- * @return object | |
- * @throws Braintree_Exception_ValidationError | |
+ * @return CreditCard | |
+ * @throws Exception\ValidationError | |
*/ | |
public function createNoValidate($attribs) | |
{ | |
$result = $this->create($attribs); | |
- return Braintree_Util::returnObjectOrThrowException(__CLASS__, $result); | |
+ return Util::returnObjectOrThrowException(__CLASS__, $result); | |
} | |
/** | |
* create a customer from a TransparentRedirect operation | |
* | |
+ * @deprecated since version 2.3.0 | |
* @access public | |
* @param array $attribs | |
- * @return object | |
+ * @return Result\Successful|Result\Error | |
*/ | |
public function createFromTransparentRedirect($queryString) | |
{ | |
- trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::confirm", E_USER_NOTICE); | |
- $params = Braintree_TransparentRedirect::parseAndValidateQueryString( | |
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::confirm", E_USER_NOTICE); | |
+ $params = TransparentRedirect::parseAndValidateQueryString( | |
$queryString | |
); | |
return $this->_doCreate( | |
'/payment_methods/all/confirm_transparent_redirect_request', | |
- array('id' => $params['id']) | |
+ ['id' => $params['id']] | |
); | |
} | |
/** | |
* | |
+ * @deprecated since version 2.3.0 | |
* @access public | |
* @param none | |
* @return string | |
*/ | |
public function createCreditCardUrl() | |
{ | |
- trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::url", E_USER_NOTICE); | |
- return $this->_config->baseUrl() . $this->_config->merchantPath() . | |
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::url", E_USER_NOTICE); | |
+ return $this->_config->baseUrl() . $this->_config->merchantPath(). | |
'/payment_methods/all/create_via_transparent_redirect_request'; | |
} | |
/** | |
* returns a ResourceCollection of expired credit cards | |
- * @return object ResourceCollection | |
+ * @return ResourceCollection | |
*/ | |
public function expired() | |
{ | |
$path = $this->_config->merchantPath() . '/payment_methods/all/expired_ids'; | |
$response = $this->_http->post($path); | |
- $pager = array( | |
+ $pager = [ | |
'object' => $this, | |
'method' => 'fetchExpired', | |
- 'methodArgs' => array() | |
- ); | |
+ 'methodArgs' => [] | |
+ ]; | |
- return new Braintree_ResourceCollection($response, $pager); | |
+ return new ResourceCollection($response, $pager); | |
} | |
public function fetchExpired($ids) | |
{ | |
$path = $this->_config->merchantPath() . "/payment_methods/all/expired"; | |
- $response = $this->_http->post($path, array('search' => array('ids' => $ids))); | |
+ $response = $this->_http->post($path, ['search' => ['ids' => $ids]]); | |
- return Braintree_Util::extractattributeasarray( | |
+ return Util::extractattributeasarray( | |
$response['paymentMethods'], | |
'creditCard' | |
); | |
@@ -108,27 +114,27 @@ | |
/** | |
* returns a ResourceCollection of credit cards expiring between start/end | |
* | |
- * @return object ResourceCollection | |
+ * @return ResourceCollection | |
*/ | |
public function expiringBetween($startDate, $endDate) | |
{ | |
$queryPath = $this->_config->merchantPath() . '/payment_methods/all/expiring_ids?start=' . date('mY', $startDate) . '&end=' . date('mY', $endDate); | |
$response = $this->_http->post($queryPath); | |
- $pager = array( | |
+ $pager = [ | |
'object' => $this, | |
'method' => 'fetchExpiring', | |
- 'methodArgs' => array($startDate, $endDate) | |
- ); | |
+ 'methodArgs' => [$startDate, $endDate] | |
+ ]; | |
- return new Braintree_ResourceCollection($response, $pager); | |
+ return new ResourceCollection($response, $pager); | |
} | |
public function fetchExpiring($startDate, $endDate, $ids) | |
{ | |
$queryPath = $this->_config->merchantPath() . '/payment_methods/all/expiring?start=' . date('mY', $startDate) . '&end=' . date('mY', $endDate); | |
- $response = $this->_http->post($queryPath, array('search' => array('ids' => $ids))); | |
+ $response = $this->_http->post($queryPath, ['search' => ['ids' => $ids]]); | |
- return Braintree_Util::extractAttributeAsArray( | |
+ return Util::extractAttributeAsArray( | |
$response['paymentMethods'], | |
'creditCard' | |
); | |
@@ -139,8 +145,8 @@ | |
* | |
* @access public | |
* @param string $token credit card unique id | |
- * @return object Braintree_CreditCard | |
- * @throws Braintree_Exception_NotFound | |
+ * @return CreditCard | |
+ * @throws Exception\NotFound | |
*/ | |
public function find($token) | |
{ | |
@@ -148,9 +154,9 @@ | |
try { | |
$path = $this->_config->merchantPath() . '/payment_methods/credit_card/' . $token; | |
$response = $this->_http->get($path); | |
- return Braintree_CreditCard::factory($response['creditCard']); | |
- } catch (Braintree_Exception_NotFound $e) { | |
- throw new Braintree_Exception_NotFound( | |
+ return CreditCard::factory($response['creditCard']); | |
+ } catch (Exception\NotFound $e) { | |
+ throw new Exception\NotFound( | |
'credit card with token ' . $token . ' not found' | |
); | |
} | |
@@ -162,8 +168,8 @@ | |
* | |
* @access public | |
* @param string $nonce payment method nonce | |
- * @return object Braintree_CreditCard | |
- * @throws Braintree_Exception_NotFound | |
+ * @return CreditCard | |
+ * @throws Exception\NotFound | |
*/ | |
public function fromNonce($nonce) | |
{ | |
@@ -171,9 +177,9 @@ | |
try { | |
$path = $this->_config->merchantPath() . '/payment_methods/from_nonce/' . $nonce; | |
$response = $this->_http->get($path); | |
- return Braintree_CreditCard::factory($response['creditCard']); | |
- } catch (Braintree_Exception_NotFound $e) { | |
- throw new Braintree_Exception_NotFound( | |
+ return CreditCard::factory($response['creditCard']); | |
+ } catch (Exception\NotFound $e) { | |
+ throw new Exception\NotFound( | |
'credit card with nonce ' . $nonce . ' locked, consumed or not found' | |
); | |
} | |
@@ -185,15 +191,15 @@ | |
* | |
* @access public | |
* @param array $attribs | |
- * @return object Braintree_Result_Successful or Braintree_Result_Error | |
+ * @return Result\Successful|Result\Error | |
*/ | |
public function credit($token, $transactionAttribs) | |
{ | |
$this->_validateId($token); | |
- return Braintree_Transaction::credit( | |
+ return Transaction::credit( | |
array_merge( | |
$transactionAttribs, | |
- array('paymentMethodToken' => $token) | |
+ ['paymentMethodToken' => $token] | |
) | |
); | |
} | |
@@ -201,17 +207,17 @@ | |
/** | |
* create a credit on this card, assuming validations will pass | |
* | |
- * returns a Braintree_Transaction object on success | |
+ * returns a Transaction object on success | |
* | |
* @access public | |
* @param array $attribs | |
- * @return object Braintree_Transaction | |
- * @throws Braintree_Exception_ValidationError | |
+ * @return Transaction | |
+ * @throws Exception\ValidationError | |
*/ | |
public function creditNoValidate($token, $transactionAttribs) | |
{ | |
$result = $this->credit($token, $transactionAttribs); | |
- return Braintree_Util::returnObjectOrThrowException('Transaction', $result); | |
+ return Util::returnObjectOrThrowException('Braintree\Transaction', $result); | |
} | |
/** | |
@@ -219,16 +225,16 @@ | |
* | |
* @param string $token | |
* @param array $transactionAttribs | |
- * @return object Braintree_Result_Successful or Braintree_Result_Error | |
- * @see Braintree_Transaction::sale() | |
+ * @return Result\Successful|Result\Error | |
+ * @see Transaction::sale() | |
*/ | |
public function sale($token, $transactionAttribs) | |
{ | |
$this->_validateId($token); | |
- return Braintree_Transaction::sale( | |
+ return Transaction::sale( | |
array_merge( | |
$transactionAttribs, | |
- array('paymentMethodToken' => $token) | |
+ ['paymentMethodToken' => $token] | |
) | |
); | |
} | |
@@ -236,19 +242,19 @@ | |
/** | |
* create a new sale using this card, assuming validations will pass | |
* | |
- * returns a Braintree_Transaction object on success | |
+ * returns a Transaction object on success | |
* | |
* @access public | |
* @param array $transactionAttribs | |
* @param string $token | |
- * @return object Braintree_Transaction | |
- * @throws Braintree_Exception_ValidationsFailed | |
- * @see Braintree_Transaction::sale() | |
+ * @return Transaction | |
+ * @throws Exception\ValidationsFailed | |
+ * @see Transaction::sale() | |
*/ | |
public function saleNoValidate($token, $transactionAttribs) | |
{ | |
$result = $this->sale($token, $transactionAttribs); | |
- return Braintree_Util::returnObjectOrThrowException('Transaction', $result); | |
+ return Util::returnObjectOrThrowException('Braintree\Transaction', $result); | |
} | |
/** | |
@@ -260,13 +266,13 @@ | |
* @access public | |
* @param array $attributes | |
* @param string $token (optional) | |
- * @return object Braintree_Result_Successful or Braintree_Result_Error | |
+ * @return Result\Successful|Result\Error | |
*/ | |
public function update($token, $attributes) | |
{ | |
- Braintree_Util::verifyKeys(self::updateSignature(), $attributes); | |
+ Util::verifyKeys(self::updateSignature(), $attributes); | |
$this->_validateId($token); | |
- return $this->_doUpdate('put', '/payment_methods/credit_card/' . $token, array('creditCard' => $attributes)); | |
+ return $this->_doUpdate('put', '/payment_methods/credit_card/' . $token, ['creditCard' => $attributes]); | |
} | |
/** | |
@@ -274,18 +280,18 @@ | |
* | |
* if calling this method in context, $token | |
* is the 2nd attribute. $token is not sent in object context. | |
- * returns a Braintree_CreditCard object on success | |
+ * returns a CreditCard object on success | |
* | |
* @access public | |
* @param array $attributes | |
* @param string $token | |
- * @return object Braintree_CreditCard | |
- * @throws Braintree_Exception_ValidationsFailed | |
+ * @return CreditCard | |
+ * @throws Exception\ValidationsFailed | |
*/ | |
public function updateNoValidate($token, $attributes) | |
{ | |
$result = $this->update($token, $attributes); | |
- return Braintree_Util::returnObjectOrThrowException(__CLASS__, $result); | |
+ return Util::returnObjectOrThrowException(__CLASS__, $result); | |
} | |
/** | |
* | |
@@ -295,7 +301,7 @@ | |
*/ | |
public function updateCreditCardUrl() | |
{ | |
- trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::url", E_USER_NOTICE); | |
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::url", E_USER_NOTICE); | |
return $this->_config->baseUrl() . $this->_config->merchantPath() . | |
'/payment_methods/all/update_via_transparent_redirect_request'; | |
} | |
@@ -303,20 +309,21 @@ | |
/** | |
* update a customer from a TransparentRedirect operation | |
* | |
+ * @deprecated since version 2.3.0 | |
* @access public | |
* @param array $attribs | |
* @return object | |
*/ | |
public function updateFromTransparentRedirect($queryString) | |
{ | |
- trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::confirm", E_USER_NOTICE); | |
- $params = Braintree_TransparentRedirect::parseAndValidateQueryString( | |
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::confirm", E_USER_NOTICE); | |
+ $params = TransparentRedirect::parseAndValidateQueryString( | |
$queryString | |
); | |
return $this->_doUpdate( | |
'post', | |
'/payment_methods/all/confirm_transparent_redirect_request', | |
- array('id' => $params['id']) | |
+ ['id' => $params['id']] | |
); | |
} | |
@@ -325,40 +332,45 @@ | |
$this->_validateId($token); | |
$path = $this->_config->merchantPath() . '/payment_methods/credit_card/' . $token; | |
$this->_http->delete($path); | |
- return new Braintree_Result_Successful(); | |
+ return new Result\Successful(); | |
} | |
private static function baseOptions() | |
{ | |
- return array('makeDefault', 'verificationMerchantAccountId', 'verifyCard', 'verificationAmount', 'venmoSdkSession'); | |
+ return ['makeDefault', 'verificationMerchantAccountId', 'verifyCard', 'verificationAmount', 'venmoSdkSession']; | |
} | |
private static function baseSignature($options) | |
{ | |
- return array( | |
+ return [ | |
'billingAddressId', 'cardholderName', 'cvv', 'number', 'deviceSessionId', | |
'expirationDate', 'expirationMonth', 'expirationYear', 'token', 'venmoSdkPaymentMethodCode', | |
'deviceData', 'fraudMerchantId', 'paymentMethodNonce', | |
- array('options' => $options), | |
- array( | |
- 'billingAddress' => array( | |
- 'firstName', | |
- 'lastName', | |
- 'company', | |
- 'countryCodeAlpha2', | |
- 'countryCodeAlpha3', | |
- 'countryCodeNumeric', | |
- 'countryName', | |
- 'extendedAddress', | |
- 'locality', | |
- 'region', | |
- 'postalCode', | |
- 'streetAddress' | |
- ), | |
- ), | |
- ); | |
+ ['options' => $options], | |
+ [ | |
+ 'billingAddress' => self::billingAddressSignature() | |
+ ], | |
+ ]; | |
} | |
+ public static function billingAddressSignature() | |
+ { | |
+ return [ | |
+ 'firstName', | |
+ 'lastName', | |
+ 'company', | |
+ 'countryCodeAlpha2', | |
+ 'countryCodeAlpha3', | |
+ 'countryCodeNumeric', | |
+ 'countryName', | |
+ 'extendedAddress', | |
+ 'locality', | |
+ 'region', | |
+ 'postalCode', | |
+ 'streetAddress' | |
+ ]; | |
+ } | |
+ | |
public static function createSignature() | |
{ | |
$options = self::baseOptions(); | |
@@ -372,13 +384,13 @@ | |
{ | |
$signature = self::baseSignature(self::baseOptions()); | |
- $updateExistingBillingSignature = array( | |
- array( | |
- 'options' => array( | |
+ $updateExistingBillingSignature = [ | |
+ [ | |
+ 'options' => [ | |
'updateExisting' | |
- ) | |
- ) | |
- ); | |
+ ] | |
+ ] | |
+ ]; | |
foreach($signature AS $key => $value) { | |
if(is_array($value) and array_key_exists('billingAddress', $value)) { | |
@@ -444,29 +456,30 @@ | |
/** | |
* generic method for validating incoming gateway responses | |
* | |
- * creates a new Braintree_CreditCard object and encapsulates | |
- * it inside a Braintree_Result_Successful object, or | |
- * encapsulates a Braintree_Errors object inside a Result_Error | |
- * alternatively, throws an Unexpected exception if the response is invalid. | |
+ * creates a new CreditCard object and encapsulates | |
+ * it inside a Result\Successful object, or | |
+ * encapsulates a Errors object inside a Result\Error | |
+ * alternatively, throws an Unexpected exception if the response is invalid | |
* | |
* @ignore | |
* @param array $response gateway response values | |
- * @return object Result_Successful or Result_Error | |
- * @throws Braintree_Exception_Unexpected | |
+ * @return Result\Successful|Result\Error | |
+ * @throws Exception\Unexpected | |
*/ | |
private function _verifyGatewayResponse($response) | |
{ | |
if (isset($response['creditCard'])) { | |
- // return a populated instance of Braintree_Address | |
- return new Braintree_Result_Successful( | |
- Braintree_CreditCard::factory($response['creditCard']) | |
+ // return a populated instance of Address | |
+ return new Result\Successful( | |
+ CreditCard::factory($response['creditCard']) | |
); | |
- } else if (isset($response['apiErrorResponse'])) { | |
- return new Braintree_Result_Error($response['apiErrorResponse']); | |
+ } elseif (isset($response['apiErrorResponse'])) { | |
+ return new Result\Error($response['apiErrorResponse']); | |
} else { | |
- throw new Braintree_Exception_Unexpected( | |
+ throw new Exception\Unexpected( | |
"Expected address or apiErrorResponse" | |
); | |
} | |
} | |
} | |
+class_alias('Braintree\CreditCardGateway', 'Braintree_CreditCardGateway'); | |
Index: braintree_sdk/lib/Braintree/CreditCardVerification.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/CreditCardVerification.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/CreditCardVerification.php (working copy) | |
@@ -1,5 +1,7 @@ | |
<?php | |
-class Braintree_CreditCardVerification extends Braintree_Result_CreditCardVerification | |
+namespace Braintree; | |
+ | |
+class CreditCardVerification extends Result\CreditCardVerification | |
{ | |
public static function factory($attributes) | |
{ | |
@@ -7,16 +9,35 @@ | |
return $instance; | |
} | |
- | |
// static methods redirecting to gateway | |
+ // | |
+ public static function create($attributes) | |
+ { | |
+ Util::verifyKeys(self::createSignature(), $attributes); | |
+ return Configuration::gateway()->creditCardVerification()->create($attributes); | |
+ } | |
public static function fetch($query, $ids) | |
{ | |
- return Braintree_Configuration::gateway()->creditCardVerification()->fetch($query, $ids); | |
+ return Configuration::gateway()->creditCardVerification()->fetch($query, $ids); | |
} | |
public static function search($query) | |
{ | |
- return Braintree_Configuration::gateway()->creditCardVerification()->search($query); | |
+ return Configuration::gateway()->creditCardVerification()->search($query); | |
} | |
+ | |
+ public static function createSignature() | |
+ { | |
+ return [ | |
+ ['options' => ['amount', 'merchantAccountId']], | |
+ ['creditCard' => | |
+ [ | |
+ 'cardholderName', 'cvv', 'number', | |
+ 'expirationDate', 'expirationMonth', 'expirationYear', | |
+ ['billingAddress' => CreditCardGateway::billingAddressSignature()] | |
+ ] | |
+ ]]; | |
+ } | |
} | |
+class_alias('Braintree\CreditCardVerification', 'Braintree_CreditCardVerification'); | |
Index: braintree_sdk/lib/Braintree/CreditCardVerificationGateway.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/CreditCardVerificationGateway.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/CreditCardVerificationGateway.php (working copy) | |
@@ -1,5 +1,7 @@ | |
<?php | |
-class Braintree_CreditCardVerificationGateway | |
+namespace Braintree; | |
+ | |
+class CreditCardVerificationGateway | |
{ | |
private $_gateway; | |
private $_config; | |
@@ -10,20 +12,42 @@ | |
$this->_gateway = $gateway; | |
$this->_config = $gateway->config; | |
$this->_config->assertHasAccessTokenOrKeys(); | |
- $this->_http = new Braintree_Http($gateway->config); | |
+ $this->_http = new Http($gateway->config); | |
} | |
+ public function create($attributes) | |
+ { | |
+ $response = $this->_http->post($this->_config->merchantPath() . "/verifications", ['verification' => $attributes]); | |
+ return $this->_verifyGatewayResponse($response); | |
+ } | |
+ | |
+ private function _verifyGatewayResponse($response) | |
+ { | |
+ | |
+ if(isset($response['verification'])){ | |
+ return new Result\Successful( | |
+ CreditCardVerification::factory($response['verification']) | |
+ ); | |
+ } else if (isset($response['apiErrorResponse'])) { | |
+ return new Result\Error($response['apiErrorResponse']); | |
+ } else { | |
+ throw new Exception\Unexpected( | |
+ "Expected transaction or apiErrorResponse" | |
+ ); | |
+ } | |
+ } | |
+ | |
public function fetch($query, $ids) | |
{ | |
- $criteria = array(); | |
+ $criteria = []; | |
foreach ($query as $term) { | |
$criteria[$term->name] = $term->toparam(); | |
} | |
- $criteria["ids"] = Braintree_CreditCardVerificationSearch::ids()->in($ids)->toparam(); | |
+ $criteria["ids"] = CreditCardVerificationSearch::ids()->in($ids)->toparam(); | |
$path = $this->_config->merchantPath() . '/verifications/advanced_search'; | |
- $response = $this->_http->post($path, array('search' => $criteria)); | |
+ $response = $this->_http->post($path, ['search' => $criteria]); | |
- return Braintree_Util::extractattributeasarray( | |
+ return Util::extractattributeasarray( | |
$response['creditCardVerifications'], | |
'verification' | |
); | |
@@ -31,19 +55,20 @@ | |
public function search($query) | |
{ | |
- $criteria = array(); | |
+ $criteria = []; | |
foreach ($query as $term) { | |
$criteria[$term->name] = $term->toparam(); | |
} | |
$path = $this->_config->merchantPath() . '/verifications/advanced_search_ids'; | |
- $response = $this->_http->post($path, array('search' => $criteria)); | |
- $pager = array( | |
+ $response = $this->_http->post($path, ['search' => $criteria]); | |
+ $pager = [ | |
'object' => $this, | |
'method' => 'fetch', | |
- 'methodArgs' => array($query) | |
- ); | |
+ 'methodArgs' => [$query] | |
+ ]; | |
- return new Braintree_ResourceCollection($response, $pager); | |
+ return new ResourceCollection($response, $pager); | |
} | |
} | |
+class_alias('Braintree\CreditCardVerificationGateway', 'Braintree_CreditCardVerificationGateway'); | |
Index: braintree_sdk/lib/Braintree/CreditCardVerificationSearch.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/CreditCardVerificationSearch.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/CreditCardVerificationSearch.php (working copy) | |
@@ -1,53 +1,56 @@ | |
<?php | |
-class Braintree_CreditCardVerificationSearch | |
+namespace Braintree; | |
+ | |
+class CreditCardVerificationSearch | |
{ | |
- static function id() { | |
- return new Braintree_TextNode('id'); | |
+ public static function id() { | |
+ return new TextNode('id'); | |
} | |
- static function creditCardCardholderName() { | |
- return new Braintree_TextNode('credit_card_cardholder_name'); | |
+ public static function creditCardCardholderName() { | |
+ return new TextNode('credit_card_cardholder_name'); | |
} | |
- static function billingAddressDetailsPostalCode() { | |
- return new Braintree_TextNode('billing_address_details_postal_code'); | |
+ public static function billingAddressDetailsPostalCode() { | |
+ return new TextNode('billing_address_details_postal_code'); | |
} | |
- static function customerEmail() { | |
- return new Braintree_TextNode('customer_email'); | |
+ public static function customerEmail() { | |
+ return new TextNode('customer_email'); | |
} | |
- static function customerId() { | |
- return new Braintree_TextNode('customer_id'); | |
+ public static function customerId() { | |
+ return new TextNode('customer_id'); | |
} | |
- static function paymentMethodToken(){ | |
- return new Braintree_TextNode('payment_method_token'); | |
+ public static function paymentMethodToken(){ | |
+ return new TextNode('payment_method_token'); | |
} | |
- static function creditCardExpirationDate() { | |
- return new Braintree_EqualityNode('credit_card_expiration_date'); | |
+ public static function creditCardExpirationDate() { | |
+ return new EqualityNode('credit_card_expiration_date'); | |
} | |
- static function creditCardNumber() { | |
- return new Braintree_PartialMatchNode('credit_card_number'); | |
+ public static function creditCardNumber() { | |
+ return new PartialMatchNode('credit_card_number'); | |
} | |
- static function ids() { | |
- return new Braintree_MultipleValueNode('ids'); | |
+ public static function ids() { | |
+ return new MultipleValueNode('ids'); | |
} | |
- static function createdAt() { | |
- return new Braintree_RangeNode("created_at"); | |
+ public static function createdAt() { | |
+ return new RangeNode("created_at"); | |
} | |
- static function creditCardCardType() | |
+ public static function creditCardCardType() | |
{ | |
- return new Braintree_MultipleValueNode("credit_card_card_type", Braintree_CreditCard::allCardTypes()); | |
+ return new MultipleValueNode("credit_card_card_type", CreditCard::allCardTypes()); | |
} | |
- static function status() | |
+ public static function status() | |
{ | |
- return new Braintree_MultipleValueNode("status", Braintree_Result_CreditCardVerification::allStatuses()); | |
+ return new MultipleValueNode("status", Result\CreditCardVerification::allStatuses()); | |
} | |
} | |
+class_alias('Braintree\CreditCardVerificationSearch', 'Braintree_CreditCardVerificationSearch'); | |
Index: braintree_sdk/lib/Braintree/Customer.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Customer.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Customer.php (working copy) | |
@@ -1,4 +1,6 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
/** | |
* Braintree Customer module | |
* Creates and manages Customers | |
@@ -9,7 +11,7 @@ | |
* | |
* @package Braintree | |
* @category Resources | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
* @property-read array $addresses | |
* @property-read array $paymentMethods | |
@@ -18,6 +20,9 @@ | |
* @property-read array $creditCards | |
* @property-read array $paypalAccounts | |
* @property-read array $applePayCards | |
+ * @property-read array $androidPayCards | |
+ * @property-read array $amexExpressCheckoutCards | |
+ * @property-read array $venmoAccounts | |
* @property-read array $coinbaseAccounts | |
* @property-read array $customFields custom fields passed with the request | |
* @property-read string $email | |
@@ -29,56 +34,56 @@ | |
* @property-read string $updatedAt | |
* @property-read string $website | |
*/ | |
-class Braintree_Customer extends Braintree_Base | |
+class Customer extends Base | |
{ | |
/** | |
- * | |
- * @return Braintree_Customer[] | |
+ * | |
+ * @return Customer[] | |
*/ | |
public static function all() | |
{ | |
- return Braintree_Configuration::gateway()->customer()->all(); | |
+ return Configuration::gateway()->customer()->all(); | |
} | |
/** | |
- * | |
+ * | |
* @param string $query | |
* @param int[] $ids | |
- * @return Braintree_Customer|Braintree_Customer[] | |
+ * @return Customer|Customer[] | |
*/ | |
public static function fetch($query, $ids) | |
{ | |
- return Braintree_Configuration::gateway()->customer()->fetch($query, $ids); | |
+ return Configuration::gateway()->customer()->fetch($query, $ids); | |
} | |
/** | |
- * | |
+ * | |
* @param array $attribs | |
- * @return Braintree_Customer | |
+ * @return Customer | |
*/ | |
- public static function create($attribs = array()) | |
+ public static function create($attribs = []) | |
{ | |
- return Braintree_Configuration::gateway()->customer()->create($attribs); | |
+ return Configuration::gateway()->customer()->create($attribs); | |
} | |
/** | |
- * | |
+ * | |
* @param array $attribs | |
- * @return Braintree_Customer | |
+ * @return Customer | |
*/ | |
- public static function createNoValidate($attribs = array()) | |
+ public static function createNoValidate($attribs = []) | |
{ | |
- return Braintree_Configuration::gateway()->customer()->createNoValidate($attribs); | |
+ return Configuration::gateway()->customer()->createNoValidate($attribs); | |
} | |
/** | |
* @deprecated since version 2.3.0 | |
* @param string $queryString | |
- * @return Braintree_Result_Successful | |
+ * @return Result\Successful | |
*/ | |
public static function createFromTransparentRedirect($queryString) | |
{ | |
- return Braintree_Configuration::gateway()->customer()->createFromTransparentRedirect($queryString); | |
+ return Configuration::gateway()->customer()->createFromTransparentRedirect($queryString); | |
} | |
/** | |
@@ -87,130 +92,130 @@ | |
*/ | |
public static function createCustomerUrl() | |
{ | |
- return Braintree_Configuration::gateway()->customer()->createCustomerUrl(); | |
+ return Configuration::gateway()->customer()->createCustomerUrl(); | |
} | |
/** | |
- * | |
- * @throws Braintree_Exception_NotFound | |
- * @param int $id | |
- * @return Braintree_Customer | |
+ * | |
+ * @throws Exception\NotFound | |
+ * @param string $id customer id | |
+ * @return Customer | |
*/ | |
public static function find($id) | |
{ | |
- return Braintree_Configuration::gateway()->customer()->find($id); | |
+ return Configuration::gateway()->customer()->find($id); | |
} | |
/** | |
- * | |
+ * | |
* @param int $customerId | |
* @param array $transactionAttribs | |
- * @return Braintree_Result_Successful|Braintree_Result_Error | |
+ * @return Result\Successful|Result\Error | |
*/ | |
public static function credit($customerId, $transactionAttribs) | |
{ | |
- return Braintree_Configuration::gateway()->customer()->credit($customerId, $transactionAttribs); | |
+ return Configuration::gateway()->customer()->credit($customerId, $transactionAttribs); | |
} | |
/** | |
- * | |
- * @throws Braintree_Exception_ValidationError | |
+ * | |
+ * @throws Exception\ValidationError | |
* @param type $customerId | |
* @param type $transactionAttribs | |
- * @return Braintree_Transaction | |
+ * @return Transaction | |
*/ | |
public static function creditNoValidate($customerId, $transactionAttribs) | |
{ | |
- return Braintree_Configuration::gateway()->customer()->creditNoValidate($customerId, $transactionAttribs); | |
+ return Configuration::gateway()->customer()->creditNoValidate($customerId, $transactionAttribs); | |
} | |
/** | |
- * | |
- * @throws Braintree_Exception on invalid id or non-200 http response code | |
+ * | |
+ * @throws Exception on invalid id or non-200 http response code | |
* @param int $customerId | |
- * @return Braintree_Result_Successful | |
+ * @return Result\Successful | |
*/ | |
public static function delete($customerId) | |
{ | |
- return Braintree_Configuration::gateway()->customer()->delete($customerId); | |
+ return Configuration::gateway()->customer()->delete($customerId); | |
} | |
/** | |
- * | |
+ * | |
* @param int $customerId | |
* @param array $transactionAttribs | |
- * @return Braintree_Transaction | |
+ * @return Transaction | |
*/ | |
public static function sale($customerId, $transactionAttribs) | |
{ | |
- return Braintree_Configuration::gateway()->customer()->sale($customerId, $transactionAttribs); | |
+ return Configuration::gateway()->customer()->sale($customerId, $transactionAttribs); | |
} | |
/** | |
- * | |
+ * | |
* @param int $customerId | |
* @param array $transactionAttribs | |
- * @return Braintree_Transaction | |
- */ | |
+ * @return Transaction | |
+ */ | |
public static function saleNoValidate($customerId, $transactionAttribs) | |
{ | |
- return Braintree_Configuration::gateway()->customer()->saleNoValidate($customerId, $transactionAttribs); | |
+ return Configuration::gateway()->customer()->saleNoValidate($customerId, $transactionAttribs); | |
} | |
/** | |
- * | |
+ * | |
* @throws InvalidArgumentException | |
* @param string $query | |
- * @return Braintree_ResourceCollection | |
+ * @return ResourceCollection | |
*/ | |
public static function search($query) | |
{ | |
- return Braintree_Configuration::gateway()->customer()->search($query); | |
+ return Configuration::gateway()->customer()->search($query); | |
} | |
/** | |
- * | |
- * @throws Braintree_Exception_Unexpected | |
+ * | |
+ * @throws Exception\Unexpected | |
* @param int $customerId | |
* @param array $attributes | |
- * @return Braintree_Result_Successful|Braintree_Result_Error | |
+ * @return Result\Successful|Result\Error | |
*/ | |
public static function update($customerId, $attributes) | |
{ | |
- return Braintree_Configuration::gateway()->customer()->update($customerId, $attributes); | |
+ return Configuration::gateway()->customer()->update($customerId, $attributes); | |
} | |
/** | |
- * | |
- * @throws Braintree_Exception_Unexpected | |
+ * | |
+ * @throws Exception\Unexpected | |
* @param int $customerId | |
* @param array $attributes | |
- * @return Braintree_CustomerGateway | |
+ * @return CustomerGateway | |
*/ | |
public static function updateNoValidate($customerId, $attributes) | |
{ | |
- return Braintree_Configuration::gateway()->customer()->updateNoValidate($customerId, $attributes); | |
+ return Configuration::gateway()->customer()->updateNoValidate($customerId, $attributes); | |
} | |
/** | |
- * | |
+ * | |
* @deprecated since version 2.3.0 | |
* @return string | |
*/ | |
public static function updateCustomerUrl() | |
{ | |
- return Braintree_Configuration::gateway()->customer()->updateCustomerUrl(); | |
+ return Configuration::gateway()->customer()->updateCustomerUrl(); | |
} | |
/** | |
- * | |
+ * | |
* @deprecated since version 2.3.0 | |
* @param string $queryString | |
- * @return Braintree_Result_Successful|Braintree_Result_Error | |
+ * @return Result\Successful|Result\Error | |
*/ | |
public static function updateFromTransparentRedirect($queryString) | |
{ | |
- return Braintree_Configuration::gateway()->customer()->updateFromTransparentRedirect($queryString); | |
+ return Configuration::gateway()->customer()->updateFromTransparentRedirect($queryString); | |
} | |
/* instance methods */ | |
@@ -224,65 +229,82 @@ | |
*/ | |
protected function _initialize($customerAttribs) | |
{ | |
- // set the attributes | |
$this->_attributes = $customerAttribs; | |
- // map each address into its own object | |
- $addressArray = array(); | |
+ $addressArray = []; | |
if (isset($customerAttribs['addresses'])) { | |
foreach ($customerAttribs['addresses'] AS $address) { | |
- $addressArray[] = Braintree_Address::factory($address); | |
+ $addressArray[] = Address::factory($address); | |
} | |
} | |
$this->_set('addresses', $addressArray); | |
- // map each creditCard into its own object | |
- $creditCardArray = array(); | |
+ $creditCardArray = []; | |
if (isset($customerAttribs['creditCards'])) { | |
foreach ($customerAttribs['creditCards'] AS $creditCard) { | |
- $creditCardArray[] = Braintree_CreditCard::factory($creditCard); | |
+ $creditCardArray[] = CreditCard::factory($creditCard); | |
} | |
} | |
$this->_set('creditCards', $creditCardArray); | |
- // map each coinbaseAccount into its own object | |
- $coinbaseAccountArray = array(); | |
+ $coinbaseAccountArray = []; | |
if (isset($customerAttribs['coinbaseAccounts'])) { | |
foreach ($customerAttribs['coinbaseAccounts'] AS $coinbaseAccount) { | |
- $coinbaseAccountArray[] = Braintree_CoinbaseAccount::factory($coinbaseAccount); | |
+ $coinbaseAccountArray[] = CoinbaseAccount::factory($coinbaseAccount); | |
} | |
} | |
$this->_set('coinbaseAccounts', $coinbaseAccountArray); | |
- // map each paypalAccount into its own object | |
- $paypalAccountArray = array(); | |
+ $paypalAccountArray = []; | |
if (isset($customerAttribs['paypalAccounts'])) { | |
foreach ($customerAttribs['paypalAccounts'] AS $paypalAccount) { | |
- $paypalAccountArray[] = Braintree_PayPalAccount::factory($paypalAccount); | |
+ $paypalAccountArray[] = PayPalAccount::factory($paypalAccount); | |
} | |
} | |
$this->_set('paypalAccounts', $paypalAccountArray); | |
- // map each applePayCard into its own object | |
- $applePayCardArray = array(); | |
+ $applePayCardArray = []; | |
if (isset($customerAttribs['applePayCards'])) { | |
foreach ($customerAttribs['applePayCards'] AS $applePayCard) { | |
- $applePayCardArray[] = Braintree_ApplePayCard::factory($applePayCard); | |
+ $applePayCardArray[] = ApplePayCard::factory($applePayCard); | |
} | |
} | |
$this->_set('applePayCards', $applePayCardArray); | |
- // map each androidPayCard into its own object | |
- $androidPayCardArray = array(); | |
+ $androidPayCardArray = []; | |
if (isset($customerAttribs['androidPayCards'])) { | |
foreach ($customerAttribs['androidPayCards'] AS $androidPayCard) { | |
- $androidPayCardArray[] = Braintree_AndroidPayCard::factory($androidPayCard); | |
+ $androidPayCardArray[] = AndroidPayCard::factory($androidPayCard); | |
} | |
} | |
$this->_set('androidPayCards', $androidPayCardArray); | |
- $this->_set('paymentMethods', array_merge($this->creditCards, $this->paypalAccounts, $this->applePayCards, $this->coinbaseAccounts, $this->androidPayCards)); | |
+ $amexExpressCheckoutCardArray = []; | |
+ if (isset($customerAttribs['amexExpressCheckoutCards'])) { | |
+ foreach ($customerAttribs['amexExpressCheckoutCards'] AS $amexExpressCheckoutCard) { | |
+ $amexExpressCheckoutCardArray[] = AmexExpressCheckoutCard::factory($amexExpressCheckoutCard); | |
+ } | |
+ } | |
+ $this->_set('amexExpressCheckoutCards', $amexExpressCheckoutCardArray); | |
+ | |
+ $venmoAccountArray = array(); | |
+ if (isset($customerAttribs['venmoAccounts'])) { | |
+ foreach ($customerAttribs['venmoAccounts'] AS $venmoAccount) { | |
+ $venmoAccountArray[] = VenmoAccount::factory($venmoAccount); | |
+ } | |
+ } | |
+ $this->_set('venmoAccounts', $venmoAccountArray); | |
+ | |
+ $this->_set('paymentMethods', array_merge( | |
+ $this->creditCards, | |
+ $this->paypalAccounts, | |
+ $this->applePayCards, | |
+ $this->coinbaseAccounts, | |
+ $this->androidPayCards, | |
+ $this->amexExpressCheckoutCards, | |
+ $this->venmoAccounts | |
+ )); | |
} | |
/** | |
@@ -292,19 +314,19 @@ | |
public function __toString() | |
{ | |
return __CLASS__ . '[' . | |
- Braintree_Util::attributesToString($this->_attributes) .']'; | |
+ Util::attributesToString($this->_attributes) .']'; | |
} | |
/** | |
- * returns false if comparing object is not a Braintree_Customer, | |
- * or is a Braintree_Customer with a different id | |
+ * returns false if comparing object is not a Customer, | |
+ * or is a Customer with a different id | |
* | |
* @param object $otherCust customer to compare against | |
* @return boolean | |
*/ | |
public function isEqual($otherCust) | |
{ | |
- return !($otherCust instanceof Braintree_Customer) ? false : $this->id === $otherCust->id; | |
+ return !($otherCust instanceof Customer) ? false : $this->id === $otherCust->id; | |
} | |
/** | |
@@ -322,11 +344,11 @@ | |
/** | |
* returns the customer's default payment method | |
* | |
- * @return object Braintree_CreditCard or Braintree_PayPalAccount | |
+ * @return CreditCard|PayPalAccount | |
*/ | |
public function defaultPaymentMethod() | |
{ | |
- $defaultPaymentMethods = array_filter($this->paymentMethods, 'Braintree_Customer::_defaultPaymentMethodFilter'); | |
+ $defaultPaymentMethods = array_filter($this->paymentMethods, 'Braintree\Customer::_defaultPaymentMethodFilter'); | |
return current($defaultPaymentMethods); | |
} | |
@@ -341,7 +363,7 @@ | |
* @access protected | |
* @var array registry of customer data | |
*/ | |
- protected $_attributes = array( | |
+ protected $_attributes = [ | |
'addresses' => '', | |
'company' => '', | |
'creditCards' => '', | |
@@ -354,20 +376,21 @@ | |
'createdAt' => '', | |
'updatedAt' => '', | |
'website' => '', | |
- ); | |
+ ]; | |
/** | |
- * factory method: returns an instance of Braintree_Customer | |
+ * factory method: returns an instance of Customer | |
* to the requesting method, with populated properties | |
* | |
* @ignore | |
* @param array $attributes | |
- * @return Braintree_Customer | |
+ * @return Customer | |
*/ | |
public static function factory($attributes) | |
{ | |
- $instance = new Braintree_Customer(); | |
+ $instance = new Customer(); | |
$instance->_initialize($attributes); | |
return $instance; | |
} | |
} | |
+class_alias('Braintree\Customer', 'Braintree_Customer'); | |
Index: braintree_sdk/lib/Braintree/CustomerGateway.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/CustomerGateway.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/CustomerGateway.php (working copy) | |
@@ -1,4 +1,8 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
+use InvalidArgumentException; | |
+ | |
/** | |
* Braintree CustomerGateway module | |
* Creates and manages Customers | |
@@ -9,9 +13,9 @@ | |
* | |
* @package Braintree | |
* @category Resources | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_CustomerGateway | |
+class CustomerGateway | |
{ | |
private $_gateway; | |
private $_config; | |
@@ -22,33 +26,33 @@ | |
$this->_gateway = $gateway; | |
$this->_config = $gateway->config; | |
$this->_config->assertHasAccessTokenOrKeys(); | |
- $this->_http = new Braintree_Http($gateway->config); | |
+ $this->_http = new Http($gateway->config); | |
} | |
public function all() | |
{ | |
$path = $this->_config->merchantPath() . '/customers/advanced_search_ids'; | |
$response = $this->_http->post($path); | |
- $pager = array( | |
+ $pager = [ | |
'object' => $this, | |
'method' => 'fetch', | |
- 'methodArgs' => array(array()) | |
- ); | |
+ 'methodArgs' => [[]] | |
+ ]; | |
- return new Braintree_ResourceCollection($response, $pager); | |
+ return new ResourceCollection($response, $pager); | |
} | |
public function fetch($query, $ids) | |
{ | |
- $criteria = array(); | |
+ $criteria = []; | |
foreach ($query as $term) { | |
$criteria[$term->name] = $term->toparam(); | |
} | |
- $criteria["ids"] = Braintree_CustomerSearch::ids()->in($ids)->toparam(); | |
+ $criteria["ids"] = CustomerSearch::ids()->in($ids)->toparam(); | |
$path = $this->_config->merchantPath() . '/customers/advanced_search'; | |
- $response = $this->_http->post($path, array('search' => $criteria)); | |
+ $response = $this->_http->post($path, ['search' => $criteria]); | |
- return Braintree_Util::extractattributeasarray( | |
+ return Util::extractattributeasarray( | |
$response['customers'], | |
'customer' | |
); | |
@@ -59,7 +63,7 @@ | |
* the gateway will generate it. | |
* | |
* <code> | |
- * $result = Braintree_Customer::create(array( | |
+ * $result = Customer::create(array( | |
* 'first_name' => 'John', | |
* 'last_name' => 'Smith', | |
* 'company' => 'Smith Co.', | |
@@ -77,27 +81,27 @@ | |
* | |
* @access public | |
* @param array $attribs | |
- * @return object Result, either Successful or Error | |
+ * @return Braintree_Result_Successful|Braintree_Result_Error | |
*/ | |
- public function create($attribs = array()) | |
+ public function create($attribs = []) | |
{ | |
- Braintree_Util::verifyKeys(self::createSignature(), $attribs); | |
- return $this->_doCreate('/customers', array('customer' => $attribs)); | |
+ Util::verifyKeys(self::createSignature(), $attribs); | |
+ return $this->_doCreate('/customers', ['customer' => $attribs]); | |
} | |
/** | |
* attempts the create operation assuming all data will validate | |
- * returns a Braintree_Customer object instead of a Result | |
+ * returns a Customer object instead of a Result | |
* | |
* @access public | |
* @param array $attribs | |
- * @return object | |
- * @throws Braintree_Exception_ValidationError | |
+ * @return Customer | |
+ * @throws Exception\ValidationError | |
*/ | |
- public function createNoValidate($attribs = array()) | |
+ public function createNoValidate($attribs = []) | |
{ | |
$result = $this->create($attribs); | |
- return Braintree_Util::returnObjectOrThrowException(__CLASS__, $result); | |
+ return Util::returnObjectOrThrowException(__CLASS__, $result); | |
} | |
/** | |
* create a customer from a TransparentRedirect operation | |
@@ -105,17 +109,17 @@ | |
* @deprecated since version 2.3.0 | |
* @access public | |
* @param array $attribs | |
- * @return object | |
+ * @return Customer | |
*/ | |
public function createFromTransparentRedirect($queryString) | |
{ | |
- trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::confirm", E_USER_NOTICE); | |
- $params = Braintree_TransparentRedirect::parseAndValidateQueryString( | |
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::confirm", E_USER_NOTICE); | |
+ $params = TransparentRedirect::parseAndValidateQueryString( | |
$queryString | |
); | |
return $this->_doCreate( | |
'/customers/all/confirm_transparent_redirect_request', | |
- array('id' => $params['id']) | |
+ ['id' => $params['id']] | |
); | |
} | |
@@ -128,7 +132,7 @@ | |
*/ | |
public function createCustomerUrl() | |
{ | |
- trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::url", E_USER_NOTICE); | |
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::url", E_USER_NOTICE); | |
return $this->_config->baseUrl() . $this->_config->merchantPath() . | |
'/customers/all/create_via_transparent_redirect_request'; | |
} | |
@@ -141,15 +145,15 @@ | |
public static function createSignature() | |
{ | |
- $creditCardSignature = Braintree_CreditCardGateway::createSignature(); | |
+ $creditCardSignature = CreditCardGateway::createSignature(); | |
unset($creditCardSignature[array_search('customerId', $creditCardSignature)]); | |
- $signature = array( | |
+ $signature = [ | |
'id', 'company', 'email', 'fax', 'firstName', | |
'lastName', 'phone', 'website', 'deviceData', | |
'deviceSessionId', 'fraudMerchantId', 'paymentMethodNonce', | |
- array('creditCard' => $creditCardSignature), | |
- array('customFields' => array('_anyKey_')), | |
- ); | |
+ ['creditCard' => $creditCardSignature], | |
+ ['customFields' => ['_anyKey_']], | |
+ ]; | |
return $signature; | |
} | |
@@ -159,7 +163,7 @@ | |
*/ | |
public static function updateSignature() | |
{ | |
- $creditCardSignature = Braintree_CreditCardGateway::updateSignature(); | |
+ $creditCardSignature = CreditCardGateway::updateSignature(); | |
foreach($creditCardSignature AS $key => $value) { | |
if(is_array($value) and array_key_exists('options', $value)) { | |
@@ -167,13 +171,13 @@ | |
} | |
} | |
- $signature = array( | |
+ $signature = [ | |
'id', 'company', 'email', 'fax', 'firstName', | |
'lastName', 'phone', 'website', 'deviceData', | |
'deviceSessionId', 'fraudMerchantId', 'paymentMethodNonce', | |
- array('creditCard' => $creditCardSignature), | |
- array('customFields' => array('_anyKey_')), | |
- ); | |
+ ['creditCard' => $creditCardSignature], | |
+ ['customFields' => ['_anyKey_']], | |
+ ]; | |
return $signature; | |
} | |
@@ -183,8 +187,8 @@ | |
* | |
* @access public | |
* @param string id customer Id | |
- * @return object Braintree_Customer | |
- * @throws Braintree_Exception_NotFound | |
+ * @return Customer|boolean The customer object or false if the request fails. | |
+ * @throws Exception\NotFound | |
*/ | |
public function find($id) | |
{ | |
@@ -192,13 +196,12 @@ | |
try { | |
$path = $this->_config->merchantPath() . '/customers/' . $id; | |
$response = $this->_http->get($path); | |
- return Braintree_Customer::factory($response['customer']); | |
- } catch (Braintree_Exception_NotFound $e) { | |
- throw new Braintree_Exception_NotFound( | |
+ return Customer::factory($response['customer']); | |
+ } catch (Exception\NotFound $e) { | |
+ throw new Exception\NotFound( | |
'customer with id ' . $id . ' not found' | |
); | |
} | |
- | |
} | |
/** | |
@@ -207,14 +210,14 @@ | |
* @access public | |
* @param int $customerId | |
* @param array $transactionAttribs | |
- * @return Braintree_Result_Successful|Braintree_Result_Error | |
+ * @return Result\Successful|Result\Error | |
*/ | |
public function credit($customerId, $transactionAttribs) | |
{ | |
$this->_validateId($customerId); | |
- return Braintree_Transaction::credit( | |
+ return Transaction::credit( | |
array_merge($transactionAttribs, | |
- array('customerId' => $customerId) | |
+ ['customerId' => $customerId] | |
) | |
); | |
} | |
@@ -222,18 +225,18 @@ | |
/** | |
* credit a customer, assuming validations will pass | |
* | |
- * returns a Braintree_Transaction object on success | |
+ * returns a Transaction object on success | |
* | |
* @access public | |
* @param int $customerId | |
* @param array $transactionAttribs | |
- * @return Braintree_Transaction | |
- * @throws Braintree_Exception_ValidationError | |
+ * @return Transaction | |
+ * @throws Exception\ValidationError | |
*/ | |
public function creditNoValidate($customerId, $transactionAttribs) | |
{ | |
$result = $this->credit($customerId, $transactionAttribs); | |
- return Braintree_Util::returnObjectOrThrowException('Braintree_Transaction', $result); | |
+ return Util::returnObjectOrThrowException('Braintree\Transaction', $result); | |
} | |
/** | |
@@ -246,7 +249,7 @@ | |
$this->_validateId($customerId); | |
$path = $this->_config->merchantPath() . '/customers/' . $customerId; | |
$this->_http->delete($path); | |
- return new Braintree_Result_Successful(); | |
+ return new Result\Successful(); | |
} | |
/** | |
@@ -254,15 +257,15 @@ | |
* | |
* @param string $customerId | |
* @param array $transactionAttribs | |
- * @return object Braintree_Result_Successful or Braintree_Result_Error | |
- * @see Braintree_Transaction::sale() | |
+ * @return Result\Successful|Result\Error | |
+ * @see Transaction::sale() | |
*/ | |
public function sale($customerId, $transactionAttribs) | |
{ | |
$this->_validateId($customerId); | |
- return Braintree_Transaction::sale( | |
+ return Transaction::sale( | |
array_merge($transactionAttribs, | |
- array('customerId' => $customerId) | |
+ ['customerId' => $customerId] | |
) | |
); | |
} | |
@@ -270,18 +273,18 @@ | |
/** | |
* create a new sale for a customer, assuming validations will pass | |
* | |
- * returns a Braintree_Transaction object on success | |
+ * returns a Transaction object on success | |
* @access public | |
* @param string $customerId | |
* @param array $transactionAttribs | |
- * @return object Braintree_Transaction | |
- * @throws Braintree_Exception_ValidationsFailed | |
- * @see Braintree_Transaction::sale() | |
+ * @return Transaction | |
+ * @throws Exception\ValidationsFailed | |
+ * @see Transaction::sale() | |
*/ | |
public function saleNoValidate($customerId, $transactionAttribs) | |
{ | |
$result = $this->sale($customerId, $transactionAttribs); | |
- return Braintree_Util::returnObjectOrThrowException('Braintree_Transaction', $result); | |
+ return Util::returnObjectOrThrowException('Braintree\Transaction', $result); | |
} | |
/** | |
@@ -292,12 +295,12 @@ | |
* For more detailed information and examples, see {@link http://www.braintreepayments.com/gateway/customer-api#searching http://www.braintreepaymentsolutions.com/gateway/customer-api} | |
* | |
* @param mixed $query search query | |
- * @return object Braintree_ResourceCollection | |
+ * @return ResourceCollection | |
* @throws InvalidArgumentException | |
*/ | |
public function search($query) | |
{ | |
- $criteria = array(); | |
+ $criteria = []; | |
foreach ($query as $term) { | |
$result = $term->toparam(); | |
if(is_null($result) || empty($result)) { | |
@@ -308,14 +311,14 @@ | |
} | |
$path = $this->_config->merchantPath() . '/customers/advanced_search_ids'; | |
- $response = $this->_http->post($path, array('search' => $criteria)); | |
- $pager = array( | |
+ $response = $this->_http->post($path, ['search' => $criteria]); | |
+ $pager = [ | |
'object' => $this, | |
'method' => 'fetch', | |
- 'methodArgs' => array($query) | |
- ); | |
+ 'methodArgs' => [$query] | |
+ ]; | |
- return new Braintree_ResourceCollection($response, $pager); | |
+ return new ResourceCollection($response, $pager); | |
} | |
/** | |
@@ -327,16 +330,16 @@ | |
* @access public | |
* @param string $customerId (optional) | |
* @param array $attributes | |
- * @return object Braintree_Result_Successful or Braintree_Result_Error | |
+ * @return Result\Successful|Result\Error | |
*/ | |
public function update($customerId, $attributes) | |
{ | |
- Braintree_Util::verifyKeys(self::updateSignature(), $attributes); | |
+ Util::verifyKeys(self::updateSignature(), $attributes); | |
$this->_validateId($customerId); | |
return $this->_doUpdate( | |
'put', | |
'/customers/' . $customerId, | |
- array('customer' => $attributes) | |
+ ['customer' => $attributes] | |
); | |
} | |
@@ -345,18 +348,18 @@ | |
* | |
* if calling this method in static context, customerId | |
* is the 2nd attribute. customerId is not sent in object context. | |
- * returns a Braintree_Customer object on success | |
+ * returns a Customer object on success | |
* | |
* @access public | |
* @param string $customerId | |
* @param array $attributes | |
- * @return object Braintree_Customer | |
- * @throws Braintree_Exception_ValidationsFailed | |
+ * @return Customer | |
+ * @throws Exception\ValidationsFailed | |
*/ | |
public function updateNoValidate($customerId, $attributes) | |
{ | |
$result = $this->update($customerId, $attributes); | |
- return Braintree_Util::returnObjectOrThrowException(__CLASS__, $result); | |
+ return Util::returnObjectOrThrowException(__CLASS__, $result); | |
} | |
/** | |
* | |
@@ -366,7 +369,7 @@ | |
*/ | |
public function updateCustomerUrl() | |
{ | |
- trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::url", E_USER_NOTICE); | |
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::url", E_USER_NOTICE); | |
return $this->_config->baseUrl() . $this->_config->merchantPath() . | |
'/customers/all/update_via_transparent_redirect_request'; | |
} | |
@@ -381,14 +384,14 @@ | |
*/ | |
public function updateFromTransparentRedirect($queryString) | |
{ | |
- trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::confirm", E_USER_NOTICE); | |
- $params = Braintree_TransparentRedirect::parseAndValidateQueryString( | |
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::confirm", E_USER_NOTICE); | |
+ $params = TransparentRedirect::parseAndValidateQueryString( | |
$queryString | |
); | |
return $this->_doUpdate( | |
'post', | |
'/customers/all/confirm_transparent_redirect_request', | |
- array('id' => $params['id']) | |
+ ['id' => $params['id']] | |
); | |
} | |
@@ -400,7 +403,7 @@ | |
* @ignore | |
* @access protected | |
* @param array $customerAttribs array of customer data | |
- * @return none | |
+ * @return void | |
*/ | |
protected function _initialize($customerAttribs) | |
{ | |
@@ -408,56 +411,56 @@ | |
$this->_attributes = $customerAttribs; | |
// map each address into its own object | |
- $addressArray = array(); | |
+ $addressArray = []; | |
if (isset($customerAttribs['addresses'])) { | |
foreach ($customerAttribs['addresses'] AS $address) { | |
- $addressArray[] = Braintree_Address::factory($address); | |
+ $addressArray[] = Address::factory($address); | |
} | |
} | |
$this->_set('addresses', $addressArray); | |
// map each creditCard into its own object | |
- $creditCardArray = array(); | |
+ $creditCardArray = []; | |
if (isset($customerAttribs['creditCards'])) { | |
foreach ($customerAttribs['creditCards'] AS $creditCard) { | |
- $creditCardArray[] = Braintree_CreditCard::factory($creditCard); | |
+ $creditCardArray[] = CreditCard::factory($creditCard); | |
} | |
} | |
$this->_set('creditCards', $creditCardArray); | |
// map each coinbaseAccount into its own object | |
- $coinbaseAccountArray = array(); | |
+ $coinbaseAccountArray = []; | |
if (isset($customerAttribs['coinbaseAccounts'])) { | |
foreach ($customerAttribs['coinbaseAccounts'] AS $coinbaseAccount) { | |
- $coinbaseAccountArray[] = Braintree_CoinbaseAccount::factory($coinbaseAccount); | |
+ $coinbaseAccountArray[] = CoinbaseAccount::factory($coinbaseAccount); | |
} | |
} | |
$this->_set('coinbaseAccounts', $coinbaseAccountArray); | |
// map each paypalAccount into its own object | |
- $paypalAccountArray = array(); | |
+ $paypalAccountArray = []; | |
if (isset($customerAttribs['paypalAccounts'])) { | |
foreach ($customerAttribs['paypalAccounts'] AS $paypalAccount) { | |
- $paypalAccountArray[] = Braintree_PayPalAccount::factory($paypalAccount); | |
+ $paypalAccountArray[] = PayPalAccount::factory($paypalAccount); | |
} | |
} | |
$this->_set('paypalAccounts', $paypalAccountArray); | |
// map each applePayCard into its own object | |
- $applePayCardArray = array(); | |
+ $applePayCardArray = []; | |
if (isset($customerAttribs['applePayCards'])) { | |
foreach ($customerAttribs['applePayCards'] AS $applePayCard) { | |
- $applePayCardArray[] = Braintree_applePayCard::factory($applePayCard); | |
+ $applePayCardArray[] = ApplePayCard::factory($applePayCard); | |
} | |
} | |
$this->_set('applePayCards', $applePayCardArray); | |
// map each androidPayCard into its own object | |
- $androidPayCardArray = array(); | |
+ $androidPayCardArray = []; | |
if (isset($customerAttribs['androidPayCards'])) { | |
foreach ($customerAttribs['androidPayCards'] AS $androidPayCard) { | |
- $androidPayCardArray[] = Braintree_AndroidPayCard::factory($androidPayCard); | |
+ $androidPayCardArray[] = AndroidPayCard::factory($androidPayCard); | |
} | |
} | |
$this->_set('androidPayCards', $androidPayCardArray); | |
@@ -472,19 +475,19 @@ | |
public function __toString() | |
{ | |
return __CLASS__ . '[' . | |
- Braintree_Util::attributesToString($this->_attributes) .']'; | |
+ Util::attributesToString($this->_attributes) .']'; | |
} | |
/** | |
- * returns false if comparing object is not a Braintree_Customer, | |
- * or is a Braintree_Customer with a different id | |
+ * returns false if comparing object is not a Customer, | |
+ * or is a Customer with a different id | |
* | |
* @param object $otherCust customer to compare against | |
* @return boolean | |
*/ | |
public function isEqual($otherCust) | |
{ | |
- return !($otherCust instanceof Braintree_Customer) ? false : $this->id === $otherCust->id; | |
+ return !($otherCust instanceof Customer) ? false : $this->id === $otherCust->id; | |
} | |
/** | |
@@ -500,11 +503,11 @@ | |
/** | |
* returns the customer's default payment method | |
* | |
- * @return object Braintree_CreditCard | Braintree_PayPalAccount | Braintree_ApplePayCard | Braintree_AndroidPayCard | |
+ * @return CreditCard|PayPalAccount|ApplePayCard|AndroidPayCard | |
*/ | |
public function defaultPaymentMethod() | |
{ | |
- $defaultPaymentMethods = array_filter($this->paymentMethods, 'Braintree_Customer::_defaultPaymentMethodFilter'); | |
+ $defaultPaymentMethods = array_filter($this->paymentMethods, 'Braintree\\Customer::_defaultPaymentMethodFilter'); | |
return current($defaultPaymentMethods); | |
} | |
@@ -519,7 +522,7 @@ | |
* @access protected | |
* @var array registry of customer data | |
*/ | |
- protected $_attributes = array( | |
+ protected $_attributes = [ | |
'addresses' => '', | |
'company' => '', | |
'creditCards' => '', | |
@@ -532,7 +535,7 @@ | |
'createdAt' => '', | |
'updatedAt' => '', | |
'website' => '', | |
- ); | |
+ ]; | |
/** | |
* sends the create request to the gateway | |
@@ -591,29 +594,30 @@ | |
/** | |
* generic method for validating incoming gateway responses | |
* | |
- * creates a new Braintree_Customer object and encapsulates | |
- * it inside a Braintree_Result_Successful object, or | |
- * encapsulates a Braintree_Errors object inside a Result_Error | |
+ * creates a new Customer object and encapsulates | |
+ * it inside a Result\Successful object, or | |
+ * encapsulates a Errors object inside a Result\Error | |
* alternatively, throws an Unexpected exception if the response is invalid. | |
* | |
* @ignore | |
* @param array $response gateway response values | |
- * @return object Result_Successful or Result_Error | |
- * @throws Braintree_Exception_Unexpected | |
+ * @return Result\Successful|Result\Error | |
+ * @throws Exception\Unexpected | |
*/ | |
private function _verifyGatewayResponse($response) | |
{ | |
if (isset($response['customer'])) { | |
- // return a populated instance of Braintree_Customer | |
- return new Braintree_Result_Successful( | |
- Braintree_Customer::factory($response['customer']) | |
+ // return a populated instance of Customer | |
+ return new Result\Successful( | |
+ Customer::factory($response['customer']) | |
); | |
} else if (isset($response['apiErrorResponse'])) { | |
- return new Braintree_Result_Error($response['apiErrorResponse']); | |
+ return new Result\Error($response['apiErrorResponse']); | |
} else { | |
- throw new Braintree_Exception_Unexpected( | |
+ throw new Exception\Unexpected( | |
"Expected customer or apiErrorResponse" | |
); | |
} | |
} | |
} | |
+class_alias('Braintree\CustomerGateway', 'Braintree_CustomerGateway'); | |
Index: braintree_sdk/lib/Braintree/CustomerSearch.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/CustomerSearch.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/CustomerSearch.php (working copy) | |
@@ -1,31 +1,34 @@ | |
<?php | |
-class Braintree_CustomerSearch | |
+namespace Braintree; | |
+ | |
+class CustomerSearch | |
{ | |
- static function addressCountryName() { return new Braintree_TextNode('address_country_name'); } | |
- static function addressExtendedAddress() { return new Braintree_TextNode('address_extended_address'); } | |
- static function addressFirstName() { return new Braintree_TextNode('address_first_name'); } | |
- static function addressLastName() { return new Braintree_TextNode('address_last_name'); } | |
- static function addressLocality() { return new Braintree_TextNode('address_locality'); } | |
- static function addressPostalCode() { return new Braintree_TextNode('address_postal_code'); } | |
- static function addressRegion() { return new Braintree_TextNode('address_region'); } | |
- static function addressStreetAddress() { return new Braintree_TextNode('address_street_address'); } | |
- static function cardholderName() { return new Braintree_TextNode('cardholder_name'); } | |
- static function company() { return new Braintree_TextNode('company'); } | |
- static function email() { return new Braintree_TextNode('email'); } | |
- static function fax() { return new Braintree_TextNode('fax'); } | |
- static function firstName() { return new Braintree_TextNode('first_name'); } | |
- static function id() { return new Braintree_TextNode('id'); } | |
- static function lastName() { return new Braintree_TextNode('last_name'); } | |
- static function paymentMethodToken() { return new Braintree_TextNode('payment_method_token'); } | |
- static function paymentMethodTokenWithDuplicates() { return new Braintree_IsNode('payment_method_token_with_duplicates'); } | |
- static function paypalAccountEmail() { return new Braintree_IsNode('paypal_account_email'); } | |
- static function phone() { return new Braintree_TextNode('phone'); } | |
- static function website() { return new Braintree_TextNode('website'); } | |
+ public static function addressCountryName() { return new TextNode('address_country_name'); } | |
+ public static function addressExtendedAddress() { return new TextNode('address_extended_address'); } | |
+ public static function addressFirstName() { return new TextNode('address_first_name'); } | |
+ public static function addressLastName() { return new TextNode('address_last_name'); } | |
+ public static function addressLocality() { return new TextNode('address_locality'); } | |
+ public static function addressPostalCode() { return new TextNode('address_postal_code'); } | |
+ public static function addressRegion() { return new TextNode('address_region'); } | |
+ public static function addressStreetAddress() { return new TextNode('address_street_address'); } | |
+ public static function cardholderName() { return new TextNode('cardholder_name'); } | |
+ public static function company() { return new TextNode('company'); } | |
+ public static function email() { return new TextNode('email'); } | |
+ public static function fax() { return new TextNode('fax'); } | |
+ public static function firstName() { return new TextNode('first_name'); } | |
+ public static function id() { return new TextNode('id'); } | |
+ public static function lastName() { return new TextNode('last_name'); } | |
+ public static function paymentMethodToken() { return new TextNode('payment_method_token'); } | |
+ public static function paymentMethodTokenWithDuplicates() { return new IsNode('payment_method_token_with_duplicates'); } | |
+ public static function paypalAccountEmail() { return new IsNode('paypal_account_email'); } | |
+ public static function phone() { return new TextNode('phone'); } | |
+ public static function website() { return new TextNode('website'); } | |
- static function creditCardExpirationDate() { return new Braintree_EqualityNode('credit_card_expiration_date'); } | |
- static function creditCardNumber() { return new Braintree_PartialMatchNode('credit_card_number'); } | |
+ public static function creditCardExpirationDate() { return new EqualityNode('credit_card_expiration_date'); } | |
+ public static function creditCardNumber() { return new PartialMatchNode('credit_card_number'); } | |
- static function ids() { return new Braintree_MultipleValueNode('ids'); } | |
+ public static function ids() { return new MultipleValueNode('ids'); } | |
- static function createdAt() { return new Braintree_RangeNode("created_at"); } | |
+ public static function createdAt() { return new RangeNode("created_at"); } | |
} | |
+class_alias('Braintree\CustomerSearch', 'Braintree_CustomerSearch'); | |
Index: braintree_sdk/lib/Braintree/Descriptor.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Descriptor.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Descriptor.php (working copy) | |
@@ -1,4 +1,7 @@ | |
<?php | |
-class Braintree_Descriptor extends Braintree_Instance | |
+namespace Braintree; | |
+ | |
+class Descriptor extends Instance | |
{ | |
} | |
+class_alias('Braintree\Descriptor', 'Braintree_Descriptor'); | |
Index: braintree_sdk/lib/Braintree/Digest.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Digest.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Digest.php (working copy) | |
@@ -1,11 +1,13 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
/** | |
* Digest encryption module | |
* Digest creates an HMAC-SHA1 hash for encrypting messages | |
* | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_Digest | |
+class Digest | |
{ | |
public static function hexDigestSha1($key, $string) | |
{ | |
@@ -57,3 +59,4 @@ | |
return sha1($outerPad.pack($pack, sha1($innerPad.$message))); | |
} | |
} | |
+class_alias('Braintree\Digest', 'Braintree_Digest'); | |
Index: braintree_sdk/lib/Braintree/Disbursement.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Disbursement.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Disbursement.php (working copy) | |
@@ -1,5 +1,7 @@ | |
<?php | |
-final class Braintree_Disbursement extends Braintree_Base | |
+namespace Braintree; | |
+ | |
+final class Disbursement extends Base | |
{ | |
private $_merchantAccount; | |
@@ -10,16 +12,16 @@ | |
if (isset($disbursementAttribs['merchantAccount'])) { | |
$this->_set('merchantAccount', | |
- Braintree_MerchantAccount::factory($disbursementAttribs['merchantAccount']) | |
+ MerchantAccount::factory($disbursementAttribs['merchantAccount']) | |
); | |
} | |
} | |
public function transactions() | |
{ | |
- $collection = Braintree_Transaction::search(array( | |
- Braintree_TransactionSearch::ids()->in($this->transactionIds) | |
- )); | |
+ $collection = Transaction::search([ | |
+ TransactionSearch::ids()->in($this->transactionIds), | |
+ ]); | |
return $collection; | |
} | |
@@ -33,17 +35,18 @@ | |
public function __toString() | |
{ | |
- $display = array( | |
+ $display = [ | |
'id', 'merchantAccountDetails', 'exceptionMessage', 'amount', | |
'disbursementDate', 'followUpAction', 'retry', 'success', | |
'transactionIds' | |
- ); | |
+ ]; | |
- $displayAttributes = array(); | |
+ $displayAttributes = []; | |
foreach ($display AS $attrib) { | |
$displayAttributes[$attrib] = $this->$attrib; | |
} | |
return __CLASS__ . '[' . | |
- Braintree_Util::attributesToString($displayAttributes) .']'; | |
+ Util::attributesToString($displayAttributes) .']'; | |
} | |
} | |
+class_alias('Braintree\Disbursement', 'Braintree_Disbursement'); | |
Index: braintree_sdk/lib/Braintree/DisbursementDetails.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/DisbursementDetails.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/DisbursementDetails.php (working copy) | |
@@ -1,11 +1,13 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
/** | |
* Disbursement details from a transaction | |
* Creates an instance of DisbursementDetails as returned from a transaction | |
* | |
* | |
* @package Braintree | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
* @property-read string $settlementAmount | |
* @property-read string $settlementCurrencyIsoCode | |
@@ -13,13 +15,11 @@ | |
* @property-read string $fundsHeld | |
* @property-read string $success | |
* @property-read string $disbursementDate | |
- * @uses Braintree_Instance inherits methods | |
*/ | |
-class Braintree_DisbursementDetails extends Braintree_Instance | |
+class DisbursementDetails extends Instance | |
{ | |
- protected $_attributes = array(); | |
- | |
- function isValid() { | |
+ public function isValid() { | |
return !is_null($this->disbursementDate); | |
} | |
} | |
+class_alias('Braintree\DisbursementDetails', 'Braintree_DisbursementDetails'); | |
Index: braintree_sdk/lib/Braintree/Discount.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Discount.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Discount.php (working copy) | |
@@ -1,5 +1,7 @@ | |
<?php | |
-class Braintree_Discount extends Braintree_Modification | |
+namespace Braintree; | |
+ | |
+class Discount extends Modification | |
{ | |
public static function factory($attributes) | |
{ | |
@@ -13,6 +15,7 @@ | |
public static function all() | |
{ | |
- return Braintree_Configuration::gateway()->discount()->all(); | |
+ return Configuration::gateway()->discount()->all(); | |
} | |
} | |
+class_alias('Braintree\Discount', 'Braintree_Discount'); | |
Index: braintree_sdk/lib/Braintree/DiscountGateway.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/DiscountGateway.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/DiscountGateway.php (working copy) | |
@@ -1,5 +1,7 @@ | |
<?php | |
-class Braintree_DiscountGateway | |
+namespace Braintree; | |
+ | |
+class DiscountGateway | |
{ | |
private $_gateway; | |
private $_config; | |
@@ -10,7 +12,7 @@ | |
$this->_gateway = $gateway; | |
$this->_config = $gateway->config; | |
$this->_config->assertHasAccessTokenOrKeys(); | |
- $this->_http = new Braintree_Http($gateway->config); | |
+ $this->_http = new Http($gateway->config); | |
} | |
public function all() | |
@@ -18,11 +20,12 @@ | |
$path = $this->_config->merchantPath() . '/discounts'; | |
$response = $this->_http->get($path); | |
- $discounts = array("discount" => $response['discounts']); | |
+ $discounts = ["discount" => $response['discounts']]; | |
- return Braintree_Util::extractAttributeAsArray( | |
+ return Util::extractAttributeAsArray( | |
$discounts, | |
'discount' | |
); | |
} | |
} | |
+class_alias('Braintree\DiscountGateway', 'Braintree_DiscountGateway'); | |
Index: braintree_sdk/lib/Braintree/Dispute/TransactionDetails.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Dispute/TransactionDetails.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Dispute/TransactionDetails.php (working copy) | |
@@ -1,4 +1,8 @@ | |
<?php | |
+namespace Braintree\Dispute; | |
+ | |
+use Braintree\Instance; | |
+ | |
/** | |
* Transaction details for a dispute | |
* | |
@@ -15,8 +19,9 @@ | |
* | |
* @property-read string $amount | |
* @property-read string $id | |
- * @uses Braintree_Instance inherits methods | |
*/ | |
-class Braintree_Dispute_TransactionDetails extends Braintree_Instance | |
+class TransactionDetails extends Instance | |
{ | |
} | |
+ | |
+class_alias('Braintree\Dispute\TransactionDetails', 'Braintree_Dispute_TransactionDetails'); | |
Index: braintree_sdk/lib/Braintree/Dispute.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Dispute.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Dispute.php (working copy) | |
@@ -1,10 +1,12 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
/** | |
* Creates an instance of Dispute as returned from a transaction | |
* | |
* | |
* @package Braintree | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
* @property-read string $amount | |
* @property-read string $currencyIsoCode | |
@@ -14,9 +16,9 @@ | |
* @property-read string $disbursementDate | |
* @property-read object $transactionDetails | |
*/ | |
-final class Braintree_Dispute extends Braintree_Base | |
+final class Dispute extends Base | |
{ | |
- protected $_attributes = array(); | |
+ protected $_attributes = []; | |
/* Dispute Status */ | |
const OPEN = 'open'; | |
@@ -39,6 +41,10 @@ | |
const TRANSACTION_AMOUNT_DIFFERS = "transaction_amount_differs"; | |
const RETRIEVAL = "retrieval"; | |
+ /* Dispute Kind */ | |
+ const CHARGEBACK = 'chargeback'; | |
+ const PRE_ARBITRATION = 'pre_arbitration'; | |
+ // RETRIEVAL for kind already defined under Dispute Reason | |
protected function _initialize($disputeAttribs) | |
{ | |
@@ -46,7 +52,7 @@ | |
if (isset($disputeAttribs['transaction'])) { | |
$this->_set('transactionDetails', | |
- new Braintree_Dispute_TransactionDetails($disputeAttribs['transaction']) | |
+ new Dispute\TransactionDetails($disputeAttribs['transaction']) | |
); | |
} | |
} | |
@@ -60,16 +66,17 @@ | |
public function __toString() | |
{ | |
- $display = array( | |
+ $display = [ | |
'amount', 'reason', 'status', | |
'replyByDate', 'receivedDate', 'currencyIsoCode' | |
- ); | |
+ ]; | |
- $displayAttributes = array(); | |
+ $displayAttributes = []; | |
foreach ($display AS $attrib) { | |
$displayAttributes[$attrib] = $this->$attrib; | |
} | |
return __CLASS__ . '[' . | |
- Braintree_Util::attributesToString($displayAttributes) .']'; | |
+ Util::attributesToString($displayAttributes) .']'; | |
} | |
} | |
+class_alias('Braintree\Dispute', 'Braintree_Dispute'); | |
Index: braintree_sdk/lib/Braintree/EqualityNode.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/EqualityNode.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/EqualityNode.php (working copy) | |
@@ -1,6 +1,7 @@ | |
<?php | |
+namespace Braintree; | |
-class Braintree_EqualityNode extends Braintree_IsNode | |
+class EqualityNode extends IsNode | |
{ | |
function isNot($value) | |
{ | |
@@ -8,3 +9,4 @@ | |
return $this; | |
} | |
} | |
+class_alias('Braintree\EqualityNode', 'Braintree_EqualityNode'); | |
Index: braintree_sdk/lib/Braintree/Error/Codes.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Error/Codes.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Error/Codes.php (working copy) | |
@@ -1,4 +1,6 @@ | |
<?php | |
+namespace Braintree\Error; | |
+ | |
/** | |
* | |
* Validation Error codes and messages | |
@@ -12,9 +14,9 @@ | |
* @package Braintree | |
* @subpackage Errors | |
* @category Validation | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_Error_Codes | |
+class Codes | |
{ | |
const ADDRESS_CANNOT_BE_BLANK = '81801'; | |
const ADDRESS_COMPANY_IS_INVALID = '91821'; | |
@@ -106,6 +108,7 @@ | |
const CREDIT_CARD_INVALID_VENMO_SDK_PAYMENT_METHOD_CODE = '91727'; | |
const CREDIT_CARD_NUMBER_INVALID_LENGTH = '81716'; | |
const CREDIT_CARD_NUMBER_IS_INVALID = '81715'; | |
+ const CREDIT_CARD_NUMBER_IS_PROHIBITED = '81750'; | |
const CREDIT_CARD_NUMBER_IS_REQUIRED = '81714'; | |
const CREDIT_CARD_NUMBER_LENGTH_IS_INVALID = '81716'; | |
const CREDIT_CARD_NUMBER_MUST_BE_TEST_NUMBER = '81717'; | |
@@ -423,6 +426,7 @@ | |
const TRANSACTION_CANNOT_REFUND_WITH_SUSPENDED_MERCHANT_ACCOUNT = '91538'; | |
const TRANSACTION_CANNOT_RELEASE_FROM_ESCROW = '91561'; | |
const TRANSACTION_CANNOT_SIMULATE_SETTLEMENT = '91575'; | |
+ const TRANSACTION_CANNOT_SUBMIT_FOR_PARTIAL_SETTLEMENT = '915103'; | |
const TRANSACTION_CANNOT_SUBMIT_FOR_SETTLEMENT = '91507'; | |
const TRANSACTION_CHANNEL_IS_TOO_LONG = '91550'; | |
const TRANSACTION_CREDIT_CARD_IS_REQUIRED = '91508'; | |
@@ -445,6 +449,7 @@ | |
const TRANSACTION_OPTIONS_VAULT_IS_DISABLED = '91525'; | |
const TRANSACTION_ORDER_ID_IS_TOO_LONG = '91501'; | |
const TRANSACTION_PAYMENT_INSTRUMENT_NOT_SUPPORTED_BY_MERCHANT_ACCOUNT = '91577'; | |
+ const TRANSACTION_PAYMENT_INSTRUMENT_TYPE_IS_NOT_ACCEPTED = '915101'; | |
const TRANSACTION_PAYMENT_METHOD_CONFLICT = '91515'; | |
const TRANSACTION_PAYMENT_METHOD_CONFLICT_WITH_VENMO_SDK = '91549'; | |
const TRANSACTION_PAYMENT_METHOD_DOES_NOT_BELONG_TO_CUSTOMER = '91516'; | |
@@ -461,7 +466,11 @@ | |
const TRANSACTION_PAY_PAL_VAULT_RECORD_MISSING_DATA = '91583'; | |
const TRANSACTION_PROCESSOR_AUTHORIZATION_CODE_CANNOT_BE_SET = '91519'; | |
const TRANSACTION_PROCESSOR_AUTHORIZATION_CODE_IS_INVALID = '81520'; | |
+ const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_AUTHS = '915104'; | |
const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_CREDITS = '91546'; | |
+ const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_PARTIAL_SETTLEMENT = '915102'; | |
+ const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_UPDATING_ORDER_ID = '915107'; | |
+ const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_UPDATING_DESCRIPTOR = '915108'; | |
const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_VOICE_AUTHORIZATIONS = '91545'; | |
const TRANSACTION_PURCHASE_ORDER_NUMBER_IS_INVALID = '91548'; | |
const TRANSACTION_PURCHASE_ORDER_NUMBER_IS_TOO_LONG = '91537'; | |
@@ -489,4 +498,12 @@ | |
const TRANSACTION_TYPE_IS_INVALID = '91523'; | |
const TRANSACTION_TYPE_IS_REQUIRED = '91524'; | |
const TRANSACTION_UNSUPPORTED_VOICE_AUTHORIZATION = '91539'; | |
+ | |
+ const VERIFICATION_OPTIONS_AMOUNT_CANNOT_BE_NEGATIVE = '94201'; | |
+ const VERIFICATION_OPTIONS_AMOUNT_FORMAT_IS_INVALID = '94202'; | |
+ const VERIFICATION_OPTIONS_AMOUNT_NOT_SUPPORTED_BY_PROCESSOR = '94203'; | |
+ const VERIFICATION_OPTIONS_MERCHANT_ACCOUNT_ID_IS_INVALID = '94204'; | |
+ const VERIFICATION_OPTIONS_MERCHANT_ACCOUNT_IS_SUSPENDED = '94205'; | |
+ const VERIFICATION_OPTIONS_MERCHANT_ACCOUNT_IS_FORBIDDEN = '94206'; | |
} | |
+class_alias('Braintree\Error\Codes', 'Braintree_Error_Codes'); | |
Index: braintree_sdk/lib/Braintree/Error/ErrorCollection.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Error/ErrorCollection.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Error/ErrorCollection.php (working copy) | |
@@ -1,4 +1,8 @@ | |
<?php | |
+namespace Braintree\Error; | |
+ | |
+use Braintree\Util; | |
+ | |
/** | |
* | |
* Error handler | |
@@ -9,18 +13,18 @@ | |
* @package Braintree | |
* @subpackage Errors | |
* @category Errors | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
* @property-read object $errors | |
*/ | |
-class Braintree_Error_ErrorCollection | |
+class ErrorCollection | |
{ | |
private $_errors; | |
public function __construct($errorData) | |
{ | |
$this->_errors = | |
- new Braintree_Error_ValidationErrorCollection($errorData); | |
+ new ValidationErrorCollection($errorData); | |
} | |
@@ -68,10 +72,10 @@ | |
$pieces = preg_split("/[\[\]]+/", $field, 0, PREG_SPLIT_NO_EMPTY); | |
$errors = $this; | |
foreach(array_slice($pieces, 0, -1) as $key) { | |
- $errors = $errors->forKey(Braintree_Util::delimiterToCamelCase($key)); | |
- if (!isset($errors)) { return array(); } | |
+ $errors = $errors->forKey(Util::delimiterToCamelCase($key)); | |
+ if (!isset($errors)) { return []; } | |
} | |
- $finalKey = Braintree_Util::delimiterToCamelCase(end($pieces)); | |
+ $finalKey = Util::delimiterToCamelCase(end($pieces)); | |
return $errors->onAttribute($finalKey); | |
} | |
@@ -79,7 +83,7 @@ | |
* Returns the errors at the given nesting level (see forKey) in a single, flat array: | |
* | |
* <code> | |
- * $result = Braintree_Customer::create(...); | |
+ * $result = Customer::create(...); | |
* $customerErrors = $result->errors->forKey('customer')->shallowAll(); | |
* </code> | |
*/ | |
@@ -107,3 +111,4 @@ | |
return sprintf('%s', $this->_errors); | |
} | |
} | |
+class_alias('Braintree\Error\ErrorCollection', 'Braintree_Error_ErrorCollection'); | |
Index: braintree_sdk/lib/Braintree/Error/Validation.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Error/Validation.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Error/Validation.php (working copy) | |
@@ -1,4 +1,8 @@ | |
<?php | |
+namespace Braintree\Error; | |
+ | |
+use Braintree\Util; | |
+ | |
/** | |
* error object returned as part of a validation error collection | |
* provides read-only access to $attribute, $code, and $message | |
@@ -9,17 +13,17 @@ | |
* | |
* @package Braintree | |
* @subpackage Error | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
* @property-read string $attribute | |
* @property-read string $code | |
* @property-read string $message | |
*/ | |
-class Braintree_Error_Validation | |
+class Validation | |
{ | |
- private $_attribute; | |
- private $_code; | |
- private $_message; | |
+ private $_attribute; | |
+ private $_code; | |
+ private $_message; | |
/** | |
* @ignore | |
@@ -34,13 +38,13 @@ | |
* @ignore | |
* @access protected | |
* @param array $attributes array of properties to set - single level | |
- * @return none | |
+ * @return void | |
*/ | |
private function _initializeFromArray($attributes) | |
{ | |
foreach($attributes AS $name => $value) { | |
$varName = "_$name"; | |
- $this->$varName = Braintree_Util::delimiterToCamelCase($value, '_'); | |
+ $this->$varName = Util::delimiterToCamelCase($value, '_'); | |
} | |
} | |
@@ -54,3 +58,4 @@ | |
return isset($this->$varName) ? $this->$varName : null; | |
} | |
} | |
+class_alias('Braintree\Error\Validation', 'Braintree_Error_Validation'); | |
Index: braintree_sdk/lib/Braintree/Error/ValidationErrorCollection.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Error/ValidationErrorCollection.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Error/ValidationErrorCollection.php (working copy) | |
@@ -1,4 +1,8 @@ | |
<?php | |
+namespace Braintree\Error; | |
+ | |
+use Braintree\Collection; | |
+ | |
/** | |
* collection of errors enumerating all validation errors for a given request | |
* | |
@@ -8,15 +12,15 @@ | |
* | |
* @package Braintree | |
* @subpackage Error | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
* @property-read array $errors | |
* @property-read array $nested | |
*/ | |
-class Braintree_Error_ValidationErrorCollection extends Braintree_Collection | |
+class ValidationErrorCollection extends Collection | |
{ | |
- private $_errors = array(); | |
- private $_nested = array(); | |
+ private $_errors = []; | |
+ private $_nested = []; | |
/** | |
* @ignore | |
@@ -27,17 +31,17 @@ | |
// map errors to new collections recursively | |
if ($key == 'errors') { | |
foreach ($errorData AS $error) { | |
- $this->_errors[] = new Braintree_Error_Validation($error); | |
+ $this->_errors[] = new Validation($error); | |
} | |
} else { | |
- $this->_nested[$key] = new Braintree_Error_ValidationErrorCollection($errorData); | |
+ $this->_nested[$key] = new ValidationErrorCollection($errorData); | |
} | |
} | |
public function deepAll() | |
{ | |
- $validationErrors = array_merge(array(), $this->_errors); | |
+ $validationErrors = array_merge([], $this->_errors); | |
foreach($this->_nested as $nestedErrors) | |
{ | |
$validationErrors = array_merge($validationErrors, $nestedErrors->deepAll()); | |
@@ -67,7 +71,7 @@ | |
public function onAttribute($attribute) | |
{ | |
- $matches = array(); | |
+ $matches = []; | |
foreach ($this->_errors AS $key => $error) { | |
if($error->attribute == $attribute) { | |
$matches[] = $error; | |
@@ -97,7 +101,7 @@ | |
*/ | |
public function __toString() | |
{ | |
- $output = array(); | |
+ $output = []; | |
// TODO: implement scope | |
if (!empty($this->_errors)) { | |
@@ -125,3 +129,4 @@ | |
return $eOutput; | |
} | |
} | |
+class_alias('Braintree\Error\ValidationErrorCollection', 'Braintree_Error_ValidationErrorCollection'); | |
Index: braintree_sdk/lib/Braintree/EuropeBankAccount.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/EuropeBankAccount.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/EuropeBankAccount.php (working copy) | |
@@ -1,4 +1,6 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
/** | |
* Braintree EuropeBankAccount module | |
* Creates and manages Braintree Europe Bank Accounts | |
@@ -9,17 +11,18 @@ | |
* | |
* @package Braintree | |
* @category Resources | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
- * @property-read string $token | |
+ * @property-read string $account-holder-name | |
+ * @property-read string $bic | |
+ * @property-read string $customerId | |
* @property-read string $default | |
+ * @property-read string $image-url | |
+ * @property-read string $mandate-reference-number | |
* @property-read string $masked-iban | |
- * @property-read string $bic | |
- * @property-read string $mandate-reference-number | |
- * @property-read string $account-holder-name | |
- * @property-read string $image-url | |
+ * @property-read string $token | |
*/ | |
-class Braintree_EuropeBankAccount extends Braintree_Base | |
+class EuropeBankAccount extends Base | |
{ | |
/* instance methods */ | |
@@ -34,16 +37,16 @@ | |
} | |
/** | |
- * factory method: returns an instance of Braintree_EuropeBankAccount | |
+ * factory method: returns an instance of EuropeBankAccount | |
* to the requesting method, with populated properties | |
* | |
* @ignore | |
- * @return object instance of Braintree_EuropeBankAccount | |
+ * @return EuropeBankAccount | |
*/ | |
public static function factory($attributes) | |
{ | |
- $defaultAttributes = array( | |
- ); | |
+ $defaultAttributes = [ | |
+ ]; | |
$instance = new self(); | |
$instance->_initialize(array_merge($defaultAttributes, $attributes)); | |
@@ -55,10 +58,11 @@ | |
* | |
* @access protected | |
* @param array $europeBankAccountAttribs array of EuropeBankAccount properties | |
- * @return none | |
+ * @return void | |
*/ | |
protected function _initialize($europeBankAccountAttribs) | |
{ | |
$this->_attributes = $europeBankAccountAttribs; | |
} | |
} | |
+class_alias('Braintree\EuropeBankAccount', 'Braintree_EuropeBankAccount'); | |
Index: braintree_sdk/lib/Braintree/Exception/Authentication.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Exception/Authentication.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Exception/Authentication.php (working copy) | |
@@ -1,13 +1,18 @@ | |
<?php | |
+namespace Braintree\Exception; | |
+ | |
+use Braintree\Exception; | |
+ | |
/** | |
* Raised when authentication fails. | |
- * This may be caused by an incorrect Braintree_Configuration | |
+ * This may be caused by an incorrect Configuration | |
* | |
* @package Braintree | |
* @subpackage Exception | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_Exception_Authentication extends Braintree_Exception | |
+class Authentication extends Exception | |
{ | |
} | |
+class_alias('Braintree\Exception\Authentication', 'Braintree_Exception_Authentication'); | |
Index: braintree_sdk/lib/Braintree/Exception/Authorization.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Exception/Authorization.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Exception/Authorization.php (working copy) | |
@@ -1,4 +1,8 @@ | |
<?php | |
+namespace Braintree\Exception; | |
+ | |
+use Braintree\Exception; | |
+ | |
/** | |
* Raised when authorization fails | |
* Raised when the API key being used is not authorized to perform | |
@@ -7,9 +11,10 @@ | |
* | |
* @package Braintree | |
* @subpackage Exception | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_Exception_Authorization extends Braintree_Exception | |
+class Authorization extends Exception | |
{ | |
} | |
+class_alias('Braintree\Exception\Authorization', 'Braintree_Exception_Authorization'); | |
Index: braintree_sdk/lib/Braintree/Exception/Configuration.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Exception/Configuration.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Exception/Configuration.php (working copy) | |
@@ -1,12 +1,17 @@ | |
<?php | |
+namespace Braintree\Exception; | |
+ | |
+use Braintree\Exception; | |
+ | |
/** | |
* Raised when the Braintree library is not completely configured. | |
* | |
* @package Braintree | |
* @subpackage Exception | |
- * @see Braintree_Configuration | |
+ * @see Configuration | |
*/ | |
-class Braintree_Exception_Configuration extends Braintree_Exception | |
+class Configuration extends Exception | |
{ | |
} | |
+class_alias('Braintree\Exception\Configuration', 'Braintree_Exception_Configuration'); | |
Index: braintree_sdk/lib/Braintree/Exception/DownForMaintenance.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Exception/DownForMaintenance.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Exception/DownForMaintenance.php (working copy) | |
@@ -1,12 +1,17 @@ | |
<?php | |
+namespace Braintree\Exception; | |
+ | |
+use Braintree\Exception; | |
+ | |
/** | |
* Raised when the gateway is down for maintenance. | |
* | |
* @package Braintree | |
* @subpackage Exception | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_Exception_DownForMaintenance extends Braintree_Exception | |
+class DownForMaintenance extends Exception | |
{ | |
} | |
+class_alias('Braintree\Exception\DownForMaintenance', 'Braintree_Exception_DownForMaintenance'); | |
Index: braintree_sdk/lib/Braintree/Exception/ForgedQueryString.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Exception/ForgedQueryString.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Exception/ForgedQueryString.php (working copy) | |
@@ -1,4 +1,8 @@ | |
<?php | |
+namespace Braintree\Exception; | |
+ | |
+use Braintree\Exception; | |
+ | |
/** | |
* Raised when a suspected forged query string is present | |
* Raised from methods that confirm transparent redirect requests | |
@@ -8,9 +12,10 @@ | |
* | |
* @package Braintree | |
* @subpackage Exception | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_Exception_ForgedQueryString extends Braintree_Exception | |
+class ForgedQueryString extends Exception | |
{ | |
} | |
+class_alias('Braintree\Exception\ForgedQueryString', 'Braintree_Exception_ForgedQueryString'); | |
Index: braintree_sdk/lib/Braintree/Exception/InvalidChallenge.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Exception/InvalidChallenge.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Exception/InvalidChallenge.php (working copy) | |
@@ -1,5 +1,9 @@ | |
<?php | |
-class Braintree_Exception_InvalidChallenge extends Braintree_Exception | |
+namespace Braintree\Exception; | |
+ | |
+use Braintree\Exception; | |
+ | |
+class InvalidChallenge extends Exception | |
{ | |
- | |
} | |
+class_alias('Braintree\Exception\InvalidChallenge', 'Braintree_Exception_InvalidChallenge'); | |
Index: braintree_sdk/lib/Braintree/Exception/InvalidSignature.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Exception/InvalidSignature.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Exception/InvalidSignature.php (working copy) | |
@@ -1,5 +1,9 @@ | |
<?php | |
-class Braintree_Exception_InvalidSignature extends Braintree_Exception | |
+namespace Braintree\Exception; | |
+ | |
+use Braintree\Exception; | |
+ | |
+class InvalidSignature extends Exception | |
{ | |
- | |
} | |
+class_alias('Braintree\Exception\InvalidSignature', 'Braintree_Exception_InvalidSignature'); | |
Index: braintree_sdk/lib/Braintree/Exception/NotFound.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Exception/NotFound.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Exception/NotFound.php (working copy) | |
@@ -1,12 +1,17 @@ | |
<?php | |
+namespace Braintree\Exception; | |
+ | |
+use Braintree\Exception; | |
+ | |
/** | |
* Raised when a record could not be found. | |
* | |
* @package Braintree | |
* @subpackage Exception | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_Exception_NotFound extends Braintree_Exception | |
+class NotFound extends Exception | |
{ | |
} | |
+class_alias('Braintree\Exception\NotFound', 'Braintree_Exception_NotFound'); | |
Index: braintree_sdk/lib/Braintree/Exception/SSLCaFileNotFound.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Exception/SSLCaFileNotFound.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Exception/SSLCaFileNotFound.php (working copy) | |
@@ -1,12 +1,17 @@ | |
<?php | |
+namespace Braintree\Exception; | |
+ | |
+use Braintree\Exception; | |
+ | |
/** | |
* Raised when the SSL CaFile is not found. | |
* | |
* @package Braintree | |
* @subpackage Exception | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_Exception_SSLCaFileNotFound extends Braintree_Exception | |
+class SSLCaFileNotFound extends Exception | |
{ | |
} | |
+class_alias('Braintree\Exception\SSLCaFileNotFound', 'Braintree_Exception_SSLCaFileNotFound'); | |
Index: braintree_sdk/lib/Braintree/Exception/SSLCertificate.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Exception/SSLCertificate.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Exception/SSLCertificate.php (working copy) | |
@@ -1,12 +1,17 @@ | |
<?php | |
+namespace Braintree\Exception; | |
+ | |
+use Braintree\Exception; | |
+ | |
/** | |
* Raised when the SSL certificate fails verification. | |
* | |
* @package Braintree | |
* @subpackage Exception | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_Exception_SSLCertificate extends Braintree_Exception | |
+class SSLCertificate extends Exception | |
{ | |
} | |
+class_alias('Braintree\Exception\SSLCertificate', 'Braintree_Exception_SSLCertificate'); | |
Index: braintree_sdk/lib/Braintree/Exception/ServerError.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Exception/ServerError.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Exception/ServerError.php (working copy) | |
@@ -1,12 +1,17 @@ | |
<?php | |
+namespace Braintree\Exception; | |
+ | |
+use Braintree\Exception; | |
+ | |
/** | |
* Raised when an unexpected server error occurs. | |
* | |
* @package Braintree | |
* @subpackage Exception | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_Exception_ServerError extends Braintree_Exception | |
+class ServerError extends Exception | |
{ | |
} | |
+class_alias('Braintree\Exception\ServerError', 'Braintree_Exception_ServerError'); | |
Index: braintree_sdk/lib/Braintree/Exception/TestOperationPerformedInProduction.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Exception/TestOperationPerformedInProduction.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Exception/TestOperationPerformedInProduction.php (working copy) | |
@@ -1,11 +1,16 @@ | |
<?php | |
+namespace Braintree\Exception; | |
+ | |
+use Braintree\Exception; | |
+ | |
/** | |
* Raised when a test method is used in production. | |
* | |
* @package Braintree | |
* @subpackage Exception | |
-* @copyright 2014 Braintree, a division of PayPal, Inc. | |
+* @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_Exception_TestOperationPerformedInProduction extends Braintree_Exception | |
+class TestOperationPerformedInProduction extends Exception | |
{ | |
} | |
+class_alias('Braintree\Exception\TestOperationPerformedInProduction', 'Braintree_Exception_TestOperationPerformedInProduction'); | |
Index: braintree_sdk/lib/Braintree/Exception/Unexpected.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Exception/Unexpected.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Exception/Unexpected.php (working copy) | |
@@ -1,13 +1,18 @@ | |
<?php | |
+namespace Braintree\Exception; | |
+ | |
+use Braintree\Exception; | |
+ | |
/** | |
* Raised when an error occurs that the client library is not built to handle. | |
* This shouldn't happen. | |
* | |
* @package Braintree | |
* @subpackage Exception | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_Exception_Unexpected extends Braintree_Exception | |
+class Unexpected extends Exception | |
{ | |
} | |
+class_alias('Braintree\Exception\Unexpected', 'Braintree_Exception_Unexpected'); | |
Index: braintree_sdk/lib/Braintree/Exception/UpgradeRequired.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Exception/UpgradeRequired.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Exception/UpgradeRequired.php (working copy) | |
@@ -1,12 +1,17 @@ | |
<?php | |
+namespace Braintree\Exception; | |
+ | |
+use Braintree\Exception; | |
+ | |
/** | |
* Raised when a client library must be upgraded. | |
* | |
* @package Braintree | |
* @subpackage Exception | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_Exception_UpgradeRequired extends Braintree_Exception | |
+class UpgradeRequired extends Exception | |
{ | |
} | |
+class_alias('Braintree\Exception\UpgradeRequired', 'Braintree_Exception_UpgradeRequired'); | |
Index: braintree_sdk/lib/Braintree/Exception/ValidationsFailed.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Exception/ValidationsFailed.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Exception/ValidationsFailed.php (working copy) | |
@@ -1,12 +1,17 @@ | |
<?php | |
+namespace Braintree\Exception; | |
+ | |
+use Braintree\Exception; | |
+ | |
/** | |
* Raised from non-validating methods when gateway validations fail. | |
* | |
* @package Braintree | |
* @subpackage Exception | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_Exception_ValidationsFailed extends Braintree_Exception | |
+class ValidationsFailed extends Exception | |
{ | |
} | |
+class_alias('Braintree\Exception\ValidationsFailed', 'Braintree_Exception_ValidationsFailed'); | |
Index: braintree_sdk/lib/Braintree/Exception.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Exception.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Exception.php (working copy) | |
@@ -1,11 +1,14 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
/** | |
* super class for all Braintree exceptions | |
* | |
* @package Braintree | |
* @subpackage Exception | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_Exception extends Exception | |
+class Exception extends \Exception | |
{ | |
} | |
+class_alias('Braintree\Exception', 'Braintree_Exception'); | |
Index: braintree_sdk/lib/Braintree/FacilitatorDetails.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/FacilitatorDetails.php (revision 0) | |
+++ braintree_sdk/lib/Braintree/FacilitatorDetails.php (working copy) | |
@@ -0,0 +1,30 @@ | |
+<?php | |
+namespace Braintree; | |
+ | |
+class FacilitatorDetails extends Base | |
+{ | |
+ public static function factory($attributes) | |
+ { | |
+ $instance = new self(); | |
+ $instance->_initialize($attributes); | |
+ | |
+ return $instance; | |
+ } | |
+ | |
+ protected function _initialize($attributes) | |
+ { | |
+ $this->_attributes = $attributes; | |
+ } | |
+ | |
+ /** | |
+ * returns a string representation of the three d secure info | |
+ * @return string | |
+ */ | |
+ public function __toString() | |
+ { | |
+ return __CLASS__ . '[' . | |
+ Util::attributesToString($this->_attributes) .']'; | |
+ } | |
+ | |
+} | |
+class_alias('Braintree\FacilitatorDetails', 'Braintree_FacilitatorDetails'); | |
Index: braintree_sdk/lib/Braintree/Gateway.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Gateway.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Gateway.php (working copy) | |
@@ -1,195 +1,198 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
/** | |
* Braintree Gateway module | |
* | |
* @package Braintree | |
* @category Resources | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_Gateway | |
+class Gateway | |
{ | |
/** | |
* | |
- * @var Braintree_Configuration | |
+ * @var Configuration | |
*/ | |
public $config; | |
public function __construct($config) | |
{ | |
if (is_array($config)) { | |
- $config = new Braintree_Configuration($config); | |
+ $config = new Configuration($config); | |
} | |
$this->config = $config; | |
} | |
/** | |
* | |
- * @return \Braintree_AddOnGateway | |
+ * @return AddOnGateway | |
*/ | |
public function addOn() | |
{ | |
- return new Braintree_AddOnGateway($this); | |
+ return new AddOnGateway($this); | |
} | |
/** | |
* | |
- * @return \Braintree_AddressGateway | |
+ * @return AddressGateway | |
*/ | |
public function address() | |
{ | |
- return new Braintree_AddressGateway($this); | |
+ return new AddressGateway($this); | |
} | |
/** | |
* | |
- * @return \Braintree_ClientTokenGateway | |
+ * @return ClientTokenGateway | |
*/ | |
public function clientToken() | |
{ | |
- return new Braintree_ClientTokenGateway($this); | |
+ return new ClientTokenGateway($this); | |
} | |
/** | |
* | |
- * @return \Braintree_CreditCardGateway | |
+ * @return CreditCardGateway | |
*/ | |
public function creditCard() | |
{ | |
- return new Braintree_CreditCardGateway($this); | |
+ return new CreditCardGateway($this); | |
} | |
/** | |
* | |
- * @return \Braintree_CreditCardVerificationGateway | |
+ * @return CreditCardVerificationGateway | |
*/ | |
public function creditCardVerification() | |
{ | |
- return new Braintree_CreditCardVerificationGateway($this); | |
+ return new CreditCardVerificationGateway($this); | |
} | |
/** | |
* | |
- * @return \Braintree_CustomerGateway | |
+ * @return CustomerGateway | |
*/ | |
public function customer() | |
{ | |
- return new Braintree_CustomerGateway($this); | |
+ return new CustomerGateway($this); | |
} | |
/** | |
* | |
- * @return \Braintree_DiscountGateway | |
+ * @return DiscountGateway | |
*/ | |
public function discount() | |
{ | |
- return new Braintree_DiscountGateway($this); | |
+ return new DiscountGateway($this); | |
} | |
/** | |
* | |
- * @return \Braintree_MerchantGateway | |
+ * @return MerchantGateway | |
*/ | |
public function merchant() | |
{ | |
- return new Braintree_MerchantGateway($this); | |
+ return new MerchantGateway($this); | |
} | |
/** | |
* | |
- * @return \Braintree_MerchantAccountGateway | |
+ * @return MerchantAccountGateway | |
*/ | |
public function merchantAccount() | |
{ | |
- return new Braintree_MerchantAccountGateway($this); | |
+ return new MerchantAccountGateway($this); | |
} | |
/** | |
* | |
- * @return \Braintree_OAuthGateway | |
+ * @return OAuthGateway | |
*/ | |
public function oauth() | |
{ | |
- return new Braintree_OAuthGateway($this); | |
+ return new OAuthGateway($this); | |
} | |
/** | |
* | |
- * @return \Braintree_PaymentMethodGateway | |
+ * @return PaymentMethodGateway | |
*/ | |
public function paymentMethod() | |
{ | |
- return new Braintree_PaymentMethodGateway($this); | |
+ return new PaymentMethodGateway($this); | |
} | |
/** | |
* | |
- * @return \Braintree_PaymentMethodNonceGateway | |
+ * @return PaymentMethodNonceGateway | |
*/ | |
public function paymentMethodNonce() | |
{ | |
- return new Braintree_PaymentMethodNonceGateway($this); | |
+ return new PaymentMethodNonceGateway($this); | |
} | |
/** | |
* | |
- * @return \Braintree_PayPalAccountGateway | |
+ * @return PayPalAccountGateway | |
*/ | |
public function payPalAccount() | |
{ | |
- return new Braintree_PayPalAccountGateway($this); | |
+ return new PayPalAccountGateway($this); | |
} | |
/** | |
* | |
- * @return \Braintree_PlanGateway | |
+ * @return PlanGateway | |
*/ | |
public function plan() | |
{ | |
- return new Braintree_PlanGateway($this); | |
+ return new PlanGateway($this); | |
} | |
/** | |
* | |
- * @return \Braintree_SettlementBatchSummaryGateway | |
+ * @return SettlementBatchSummaryGateway | |
*/ | |
public function settlementBatchSummary() | |
{ | |
- return new Braintree_SettlementBatchSummaryGateway($this); | |
+ return new SettlementBatchSummaryGateway($this); | |
} | |
/** | |
* | |
- * @return \Braintree_SubscriptionGateway | |
+ * @return SubscriptionGateway | |
*/ | |
public function subscription() | |
{ | |
- return new Braintree_SubscriptionGateway($this); | |
+ return new SubscriptionGateway($this); | |
} | |
/** | |
* | |
- * @return \Braintree_TestingGateway | |
+ * @return TestingGateway | |
*/ | |
public function testing() | |
{ | |
- return new Braintree_TestingGateway($this); | |
+ return new TestingGateway($this); | |
} | |
/** | |
* | |
- * @return \Braintree_TransactionGateway | |
+ * @return TransactionGateway | |
*/ | |
public function transaction() | |
{ | |
- return new Braintree_TransactionGateway($this); | |
+ return new TransactionGateway($this); | |
} | |
/** | |
* | |
- * @return \Braintree_TransparentRedirectGateway | |
+ * @return TransparentRedirectGateway | |
*/ | |
public function transparentRedirect() | |
{ | |
- return new Braintree_TransparentRedirectGateway($this); | |
+ return new TransparentRedirectGateway($this); | |
} | |
} | |
+class_alias('Braintree\Gateway', 'Braintree_Gateway'); | |
Index: braintree_sdk/lib/Braintree/Http.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Http.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Http.php (working copy) | |
@@ -1,11 +1,13 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
/** | |
* Braintree HTTP Client | |
* processes Http requests using curl | |
* | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_Http | |
+class Http | |
{ | |
protected $_config; | |
private $_useClientCredentials = false; | |
@@ -21,17 +23,17 @@ | |
if($response['status'] === 200) { | |
return true; | |
} else { | |
- Braintree_Util::throwStatusCodeException($response['status']); | |
+ Util::throwStatusCodeException($response['status']); | |
} | |
} | |
public function get($path) | |
{ | |
$response = $this->_doRequest('GET', $path); | |
- if($response['status'] === 200) { | |
- return Braintree_Xml::buildArrayFromXml($response['body']); | |
+ if ($response['status'] === 200) { | |
+ return Xml::buildArrayFromXml($response['body']); | |
} else { | |
- Braintree_Util::throwStatusCodeException($response['status']); | |
+ Util::throwStatusCodeException($response['status']); | |
} | |
} | |
@@ -40,9 +42,9 @@ | |
$response = $this->_doRequest('POST', $path, $this->_buildXml($params)); | |
$responseCode = $response['status']; | |
if($responseCode === 200 || $responseCode === 201 || $responseCode === 422 || $responseCode == 400) { | |
- return Braintree_Xml::buildArrayFromXml($response['body']); | |
+ return Xml::buildArrayFromXml($response['body']); | |
} else { | |
- Braintree_Util::throwStatusCodeException($responseCode); | |
+ Util::throwStatusCodeException($responseCode); | |
} | |
} | |
@@ -51,41 +53,41 @@ | |
$response = $this->_doRequest('PUT', $path, $this->_buildXml($params)); | |
$responseCode = $response['status']; | |
if($responseCode === 200 || $responseCode === 201 || $responseCode === 422 || $responseCode == 400) { | |
- return Braintree_Xml::buildArrayFromXml($response['body']); | |
+ return Xml::buildArrayFromXml($response['body']); | |
} else { | |
- Braintree_Util::throwStatusCodeException($responseCode); | |
+ Util::throwStatusCodeException($responseCode); | |
} | |
} | |
private function _buildXml($params) | |
{ | |
- return empty($params) ? null : Braintree_Xml::buildXmlFromArray($params); | |
+ return empty($params) ? null : Xml::buildXmlFromArray($params); | |
} | |
private function _getHeaders() | |
{ | |
- return array( | |
+ return [ | |
'Accept: application/xml', | |
'Content-Type: application/xml', | |
- ); | |
+ ]; | |
} | |
private function _getAuthorization() | |
{ | |
if ($this->_useClientCredentials) { | |
- return array( | |
+ return [ | |
'user' => $this->_config->getClientId(), | |
'password' => $this->_config->getClientSecret(), | |
- ); | |
+ ]; | |
} else if ($this->_config->isAccessToken()) { | |
- return array( | |
+ return [ | |
'token' => $this->_config->getAccessToken(), | |
- ); | |
+ ]; | |
} else { | |
- return array( | |
+ return [ | |
'user' => $this->_config->getPublicKey(), | |
'password' => $this->_config->getPrivateKey(), | |
- ); | |
+ ]; | |
} | |
} | |
@@ -108,8 +110,8 @@ | |
curl_setopt($curl, CURLOPT_ENCODING, 'gzip'); | |
$headers = $this->_getHeaders($curl); | |
- $headers[] = 'User-Agent: Braintree PHP Library ' . Braintree_Version::get(); | |
- $headers[] = 'X-ApiVersion: ' . Braintree_Configuration::API_VERSION; | |
+ $headers[] = 'User-Agent: Braintree PHP Library ' . Version::get(); | |
+ $headers[] = 'X-ApiVersion: ' . Configuration::API_VERSION; | |
$authorization = $this->_getAuthorization(); | |
if (isset($authorization['user'])) { | |
@@ -124,22 +126,57 @@ | |
if ($this->_config->sslOn()) { | |
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true); | |
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2); | |
- curl_setopt($curl, CURLOPT_CAINFO, $this->_config->caFile()); | |
+ curl_setopt($curl, CURLOPT_CAINFO, $this->getCaFile()); | |
} | |
if(!empty($requestBody)) { | |
curl_setopt($curl, CURLOPT_POSTFIELDS, $requestBody); | |
} | |
+ if($this->_config->isUsingProxy()) { | |
+ $proxyHost = $this->_config->getProxyHost(); | |
+ $proxyPort = $this->_config->getProxyPort(); | |
+ $proxyType = $this->_config->getProxyType(); | |
+ curl_setopt($curl, CURLOPT_PROXY, $proxyHost . ':' . $proxyPort); | |
+ if(!empty($proxyType)) { | |
+ curl_setopt($curl, CURLOPT_PROXYTYPE, $proxyType); | |
+ } | |
+ } | |
+ | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); | |
$response = curl_exec($curl); | |
$httpStatus = curl_getinfo($curl, CURLINFO_HTTP_CODE); | |
curl_close($curl); | |
if ($this->_config->sslOn()) { | |
if ($httpStatus == 0) { | |
- throw new Braintree_Exception_SSLCertificate(); | |
+ throw new Exception\SSLCertificate(); | |
} | |
} | |
- return array('status' => $httpStatus, 'body' => $response); | |
+ return ['status' => $httpStatus, 'body' => $response]; | |
} | |
+ | |
+ private function getCaFile() | |
+ { | |
+ static $memo; | |
+ | |
+ if ($memo === null) { | |
+ $caFile = $this->_config->caFile(); | |
+ | |
+ if (substr($caFile, 0, 7) !== 'phar://') { | |
+ return $caFile; | |
+ } | |
+ | |
+ $extractedCaFile = sys_get_temp_dir() . '/api_braintreegateway_com.ca.crt'; | |
+ | |
+ if (!file_exists($extractedCaFile) || sha1_file($extractedCaFile) != sha1_file($caFile)) { | |
+ if (!copy($caFile, $extractedCaFile)) { | |
+ throw new Exception\SSLCaFileNotFound(); | |
+ } | |
+ } | |
+ $memo = $extractedCaFile; | |
+ } | |
+ | |
+ return $memo; | |
+ } | |
} | |
+class_alias('Braintree\Http', 'Braintree_Http'); | |
Index: braintree_sdk/lib/Braintree/Instance.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Instance.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Instance.php (working copy) | |
@@ -1,16 +1,19 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
/** | |
* Braintree Class Instance template | |
- * @package Braintree | |
- * @subpackage Utility | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* @abstract | |
*/ | |
-abstract class Braintree_Instance | |
+abstract class Instance | |
{ | |
+ protected $_attributes = []; | |
+ | |
/** | |
* | |
- * @param array $aAttribs | |
+ * @param array $attributes | |
*/ | |
public function __construct($attributes) | |
{ | |
@@ -19,11 +22,10 @@ | |
} | |
} | |
- | |
/** | |
* returns private/nonexistent instance properties | |
* @access public | |
- * @param var $name property name | |
+ * @param string $name property name | |
* @return mixed contents of instance properties | |
*/ | |
public function __get($name) | |
@@ -50,19 +52,19 @@ | |
/** | |
* create a printable representation of the object as: | |
* ClassName[property=value, property=value] | |
- * @return var | |
+ * @return string | |
*/ | |
public function __toString() | |
{ | |
- $objOutput = Braintree_Util::implodeAssociativeArray($this->_attributes); | |
- return get_class($this) .'['.$objOutput.']'; | |
+ $objOutput = Util::implodeAssociativeArray($this->_attributes); | |
+ return get_class($this) .'[' . $objOutput . ']'; | |
} | |
/** | |
* initializes instance properties from the keys/values of an array | |
* @ignore | |
* @access protected | |
* @param <type> $aAttribs array of properties to set - single level | |
- * @return none | |
+ * @return void | |
*/ | |
private function _initializeFromArray($attributes) | |
{ | |
@@ -70,3 +72,4 @@ | |
} | |
} | |
+class_alias('Braintree\Instance', 'Braintree_Instance'); | |
Index: braintree_sdk/lib/Braintree/IsNode.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/IsNode.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/IsNode.php (working copy) | |
@@ -1,21 +1,24 @@ | |
<?php | |
+namespace Braintree; | |
-class Braintree_IsNode | |
+class IsNode | |
{ | |
- function __construct($name) | |
+ public function __construct($name) | |
{ | |
$this->name = $name; | |
- $this->searchTerms = array(); | |
+ $this->searchTerms = []; | |
} | |
- function is($value) | |
+ public function is($value) | |
{ | |
$this->searchTerms['is'] = strval($value); | |
+ | |
return $this; | |
} | |
- function toParam() | |
+ public function toParam() | |
{ | |
return $this->searchTerms; | |
} | |
} | |
+class_alias('Braintree\IsNode', 'Braintree_IsNode'); | |
Index: braintree_sdk/lib/Braintree/KeyValueNode.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/KeyValueNode.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/KeyValueNode.php (working copy) | |
@@ -1,22 +1,23 @@ | |
<?php | |
+namespace Braintree; | |
-class Braintree_KeyValueNode | |
+class KeyValueNode | |
{ | |
- function __construct($name) | |
+ public function __construct($name) | |
{ | |
$this->name = $name; | |
$this->searchTerm = True; | |
- | |
} | |
- function is($value) | |
+ public function is($value) | |
{ | |
$this->searchTerm = $value; | |
return $this; | |
} | |
- function toParam() | |
+ public function toParam() | |
{ | |
return $this->searchTerm; | |
} | |
} | |
+class_alias('Braintree\KeyValueNode', 'Braintree_KeyValueNode'); | |
Index: braintree_sdk/lib/Braintree/Merchant.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Merchant.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Merchant.php (working copy) | |
@@ -1,6 +1,7 @@ | |
<?php | |
+namespace Braintree; | |
-final class Braintree_Merchant extends Braintree_Base | |
+final class Merchant extends Base | |
{ | |
protected function _initialize($attribs) | |
{ | |
@@ -21,6 +22,7 @@ | |
public function __toString() | |
{ | |
return __CLASS__ . '[' . | |
- Braintree_Util::attributesToString($this->_attributes) .']'; | |
+ Util::attributesToString($this->_attributes) .']'; | |
} | |
} | |
+class_alias('Braintree\Merchant', 'Braintree_Merchant'); | |
Index: braintree_sdk/lib/Braintree/MerchantAccount/AddressDetails.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/MerchantAccount/AddressDetails.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/MerchantAccount/AddressDetails.php (working copy) | |
@@ -1,5 +1,10 @@ | |
<?php | |
+namespace Braintree\MerchantAccount; | |
-final class Braintree_MerchantAccount_AddressDetails extends Braintree_Instance { | |
- protected $_attributes = array(); | |
+use Braintree\Instance; | |
+ | |
+final class AddressDetails extends Instance | |
+{ | |
+ protected $_attributes = []; | |
} | |
+class_alias('Braintree\MerchantAccount\AddressDetails', 'Braintree_MerchantAccount_AddressDetails'); | |
Index: braintree_sdk/lib/Braintree/MerchantAccount/BusinessDetails.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/MerchantAccount/BusinessDetails.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/MerchantAccount/BusinessDetails.php (working copy) | |
@@ -1,12 +1,15 @@ | |
<?php | |
+namespace Braintree\MerchantAccount; | |
-final class Braintree_MerchantAccount_BusinessDetails extends Braintree_Base | |
+use Braintree\Base; | |
+ | |
+final class BusinessDetails extends Base | |
{ | |
protected function _initialize($businessAttribs) | |
{ | |
$this->_attributes = $businessAttribs; | |
if (isset($businessAttribs['address'])) { | |
- $this->_set('addressDetails', new Braintree_MerchantAccount_AddressDetails($businessAttribs['address'])); | |
+ $this->_set('addressDetails', new AddressDetails($businessAttribs['address'])); | |
} | |
} | |
@@ -17,3 +20,4 @@ | |
return $instance; | |
} | |
} | |
+class_alias('Braintree\MerchantAccount\BusinessDetails', 'Braintree_MerchantAccount_BusinessDetails'); | |
Index: braintree_sdk/lib/Braintree/MerchantAccount/FundingDetails.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/MerchantAccount/FundingDetails.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/MerchantAccount/FundingDetails.php (working copy) | |
@@ -1,6 +1,10 @@ | |
<?php | |
+namespace Braintree\MerchantAccount; | |
-final class Braintree_MerchantAccount_FundingDetails extends Braintree_Instance | |
+use Braintree\Instance; | |
+ | |
+final class FundingDetails extends Instance | |
{ | |
- protected $_attributes = array(); | |
+ protected $_attributes = []; | |
} | |
+class_alias('Braintree\MerchantAccount\FundingDetails', 'Braintree_MerchantAccount_FundingDetails'); | |
Index: braintree_sdk/lib/Braintree/MerchantAccount/IndividualDetails.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/MerchantAccount/IndividualDetails.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/MerchantAccount/IndividualDetails.php (working copy) | |
@@ -1,12 +1,15 @@ | |
<?php | |
+namespace Braintree\MerchantAccount; | |
-final class Braintree_MerchantAccount_IndividualDetails extends Braintree_Base | |
+use Braintree\Base; | |
+ | |
+final class IndividualDetails extends Base | |
{ | |
protected function _initialize($individualAttribs) | |
{ | |
$this->_attributes = $individualAttribs; | |
if (isset($individualAttribs['address'])) { | |
- $this->_set('addressDetails', new Braintree_MerchantAccount_AddressDetails($individualAttribs['address'])); | |
+ $this->_set('addressDetails', new AddressDetails($individualAttribs['address'])); | |
} | |
} | |
@@ -17,3 +20,4 @@ | |
return $instance; | |
} | |
} | |
+class_alias('Braintree\MerchantAccount\IndividualDetails', 'Braintree_MerchantAccount_IndividualDetails'); | |
Index: braintree_sdk/lib/Braintree/MerchantAccount.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/MerchantAccount.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/MerchantAccount.php (working copy) | |
@@ -1,6 +1,7 @@ | |
<?php | |
+namespace Braintree; | |
-final class Braintree_MerchantAccount extends Braintree_Base | |
+final class MerchantAccount extends Base | |
{ | |
const STATUS_ACTIVE = 'active'; | |
const STATUS_PENDING = 'pending'; | |
@@ -23,22 +24,22 @@ | |
if (isset($merchantAccountAttribs['individual'])) { | |
$individual = $merchantAccountAttribs['individual']; | |
- $this->_set('individualDetails', Braintree_MerchantAccount_IndividualDetails::Factory($individual)); | |
+ $this->_set('individualDetails', MerchantAccount\IndividualDetails::Factory($individual)); | |
} | |
if (isset($merchantAccountAttribs['business'])) { | |
$business = $merchantAccountAttribs['business']; | |
- $this->_set('businessDetails', Braintree_MerchantAccount_BusinessDetails::Factory($business)); | |
+ $this->_set('businessDetails', MerchantAccount\BusinessDetails::Factory($business)); | |
} | |
if (isset($merchantAccountAttribs['funding'])) { | |
$funding = $merchantAccountAttribs['funding']; | |
- $this->_set('fundingDetails', new Braintree_MerchantAccount_FundingDetails($funding)); | |
+ $this->_set('fundingDetails', new MerchantAccount\FundingDetails($funding)); | |
} | |
if (isset($merchantAccountAttribs['masterMerchantAccount'])) { | |
$masterMerchantAccount = $merchantAccountAttribs['masterMerchantAccount']; | |
- $this->_set('masterMerchantAccount', Braintree_MerchantAccount::Factory($masterMerchantAccount)); | |
+ $this->_set('masterMerchantAccount', self::Factory($masterMerchantAccount)); | |
} | |
} | |
@@ -47,16 +48,17 @@ | |
public static function create($attribs) | |
{ | |
- return Braintree_Configuration::gateway()->merchantAccount()->create($attribs); | |
+ return Configuration::gateway()->merchantAccount()->create($attribs); | |
} | |
public static function find($merchant_account_id) | |
{ | |
- return Braintree_Configuration::gateway()->merchantAccount()->find($merchant_account_id); | |
+ return Configuration::gateway()->merchantAccount()->find($merchant_account_id); | |
} | |
public static function update($merchant_account_id, $attributes) | |
{ | |
- return Braintree_Configuration::gateway()->merchantAccount()->update($merchant_account_id, $attributes); | |
+ return Configuration::gateway()->merchantAccount()->update($merchant_account_id, $attributes); | |
} | |
} | |
+class_alias('Braintree\MerchantAccount', 'Braintree_MerchantAccount'); | |
Index: braintree_sdk/lib/Braintree/MerchantAccountGateway.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/MerchantAccountGateway.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/MerchantAccountGateway.php (working copy) | |
@@ -1,6 +1,7 @@ | |
<?php | |
+namespace Braintree; | |
-final class Braintree_MerchantAccountGateway | |
+final class MerchantAccountGateway | |
{ | |
private $_gateway; | |
private $_config; | |
@@ -11,13 +12,13 @@ | |
$this->_gateway = $gateway; | |
$this->_config = $gateway->config; | |
$this->_config->assertHasAccessTokenOrKeys(); | |
- $this->_http = new Braintree_Http($gateway->config); | |
+ $this->_http = new Http($gateway->config); | |
} | |
public function create($attribs) | |
{ | |
- Braintree_Util::verifyKeys(self::detectSignature($attribs), $attribs); | |
- return $this->_doCreate('/merchant_accounts/create_via_api', array('merchant_account' => $attribs)); | |
+ Util::verifyKeys(self::detectSignature($attribs), $attribs); | |
+ return $this->_doCreate('/merchant_accounts/create_via_api', ['merchant_account' => $attribs]); | |
} | |
public function find($merchant_account_id) | |
@@ -25,16 +26,16 @@ | |
try { | |
$path = $this->_config->merchantPath() . '/merchant_accounts/' . $merchant_account_id; | |
$response = $this->_http->get($path); | |
- return Braintree_MerchantAccount::factory($response['merchantAccount']); | |
- } catch (Braintree_Exception_NotFound $e) { | |
- throw new Braintree_Exception_NotFound('merchant account with id ' . $merchant_account_id . ' not found'); | |
+ return MerchantAccount::factory($response['merchantAccount']); | |
+ } catch (Exception\NotFound $e) { | |
+ throw new Exception\NotFound('merchant account with id ' . $merchant_account_id . ' not found'); | |
} | |
} | |
public function update($merchant_account_id, $attributes) | |
{ | |
- Braintree_Util::verifyKeys(self::updateSignature(), $attributes); | |
- return $this->_doUpdate('/merchant_accounts/' . $merchant_account_id . '/update_via_api', array('merchant_account' => $attributes)); | |
+ Util::verifyKeys(self::updateSignature(), $attributes); | |
+ return $this->_doUpdate('/merchant_accounts/' . $merchant_account_id . '/update_via_api', ['merchant_account' => $attributes]); | |
} | |
public static function detectSignature($attribs) | |
@@ -56,47 +57,47 @@ | |
public static function createSignature() | |
{ | |
- $addressSignature = array('streetAddress', 'postalCode', 'locality', 'region'); | |
- $individualSignature = array( | |
+ $addressSignature = ['streetAddress', 'postalCode', 'locality', 'region']; | |
+ $individualSignature = [ | |
'firstName', | |
'lastName', | |
'email', | |
'phone', | |
'dateOfBirth', | |
'ssn', | |
- array('address' => $addressSignature) | |
- ); | |
+ ['address' => $addressSignature] | |
+ ]; | |
- $businessSignature = array( | |
+ $businessSignature = [ | |
'dbaName', | |
'legalName', | |
'taxId', | |
- array('address' => $addressSignature) | |
- ); | |
+ ['address' => $addressSignature] | |
+ ]; | |
- $fundingSignature = array( | |
+ $fundingSignature = [ | |
'routingNumber', | |
'accountNumber', | |
'destination', | |
'email', | |
'mobilePhone', | |
'descriptor', | |
- ); | |
+ ]; | |
- return array( | |
+ return [ | |
'id', | |
'tosAccepted', | |
'masterMerchantAccountId', | |
- array('individual' => $individualSignature), | |
- array('funding' => $fundingSignature), | |
- array('business' => $businessSignature) | |
- ); | |
+ ['individual' => $individualSignature], | |
+ ['funding' => $fundingSignature], | |
+ ['business' => $businessSignature] | |
+ ]; | |
} | |
public static function createDeprecatedSignature() | |
{ | |
- $applicantDetailsAddressSignature = array('streetAddress', 'postalCode', 'locality', 'region'); | |
- $applicantDetailsSignature = array( | |
+ $applicantDetailsAddressSignature = ['streetAddress', 'postalCode', 'locality', 'region']; | |
+ $applicantDetailsSignature = [ | |
'companyName', | |
'firstName', | |
'lastName', | |
@@ -107,15 +108,15 @@ | |
'taxId', | |
'routingNumber', | |
'accountNumber', | |
- array('address' => $applicantDetailsAddressSignature) | |
- ); | |
+ ['address' => $applicantDetailsAddressSignature] | |
+ ]; | |
- return array( | |
- array('applicantDetails' => $applicantDetailsSignature), | |
+ return [ | |
+ ['applicantDetails' => $applicantDetailsSignature], | |
'id', | |
'tosAccepted', | |
'masterMerchantAccountId' | |
- ); | |
+ ]; | |
} | |
public function _doCreate($subPath, $params) | |
@@ -137,16 +138,17 @@ | |
private function _verifyGatewayResponse($response) | |
{ | |
if (isset($response['merchantAccount'])) { | |
- // return a populated instance of Braintree_merchantAccount | |
- return new Braintree_Result_Successful( | |
- Braintree_MerchantAccount::factory($response['merchantAccount']) | |
+ // return a populated instance of merchantAccount | |
+ return new Result\Successful( | |
+ MerchantAccount::factory($response['merchantAccount']) | |
); | |
} else if (isset($response['apiErrorResponse'])) { | |
- return new Braintree_Result_Error($response['apiErrorResponse']); | |
+ return new Result\Error($response['apiErrorResponse']); | |
} else { | |
- throw new Braintree_Exception_Unexpected( | |
+ throw new Exception\Unexpected( | |
"Expected merchant account or apiErrorResponse" | |
); | |
} | |
} | |
} | |
+class_alias('Braintree\MerchantAccountGateway', 'Braintree_MerchantAccountGateway'); | |
Index: braintree_sdk/lib/Braintree/MerchantGateway.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/MerchantGateway.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/MerchantGateway.php (working copy) | |
@@ -1,6 +1,7 @@ | |
<?php | |
+namespace Braintree; | |
-final class Braintree_MerchantGateway | |
+final class MerchantGateway | |
{ | |
private $_gateway; | |
private $_config; | |
@@ -11,30 +12,31 @@ | |
$this->_gateway = $gateway; | |
$this->_config = $gateway->config; | |
$this->_config->assertHasClientCredentials(); | |
- $this->_http = new Braintree_Http($gateway->config); | |
+ $this->_http = new Http($gateway->config); | |
$this->_http->useClientCredentials(); | |
} | |
public function create($attribs) | |
{ | |
- $response = $this->_http->post('/merchants/create_via_api', array('merchant' => $attribs)); | |
+ $response = $this->_http->post('/merchants/create_via_api', ['merchant' => $attribs]); | |
return $this->_verifyGatewayResponse($response); | |
} | |
private function _verifyGatewayResponse($response) | |
{ | |
if (isset($response['response']['merchant'])) { | |
- // return a populated instance of Braintree_merchant | |
- return new Braintree_Result_Successful(array( | |
- Braintree_Merchant::factory($response['response']['merchant']), | |
- Braintree_OAuthCredentials::factory($response['response']['credentials']), | |
- )); | |
+ // return a populated instance of merchant | |
+ return new Result\Successful([ | |
+ Merchant::factory($response['response']['merchant']), | |
+ OAuthCredentials::factory($response['response']['credentials']), | |
+ ]); | |
} else if (isset($response['apiErrorResponse'])) { | |
- return new Braintree_Result_Error($response['apiErrorResponse']); | |
+ return new Result\Error($response['apiErrorResponse']); | |
} else { | |
- throw new Braintree_Exception_Unexpected( | |
+ throw new Exception\Unexpected( | |
"Expected merchant or apiErrorResponse" | |
); | |
} | |
} | |
} | |
+class_alias('Braintree\MerchantGateway', 'Braintree_MerchantGateway'); | |
Index: braintree_sdk/lib/Braintree/Modification.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Modification.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Modification.php (working copy) | |
@@ -1,5 +1,7 @@ | |
<?php | |
-class Braintree_Modification extends Braintree_Base | |
+namespace Braintree; | |
+ | |
+class Modification extends Base | |
{ | |
protected function _initialize($attributes) | |
{ | |
@@ -14,6 +16,7 @@ | |
} | |
public function __toString() { | |
- return get_called_class() . '[' . Braintree_Util::attributesToString($this->_attributes) . ']'; | |
+ return get_called_class() . '[' . Util::attributesToString($this->_attributes) . ']'; | |
} | |
} | |
+class_alias('Braintree\Modification', 'Braintree_Modification'); | |
Index: braintree_sdk/lib/Braintree/MultipleValueNode.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/MultipleValueNode.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/MultipleValueNode.php (working copy) | |
@@ -1,15 +1,18 @@ | |
<?php | |
+namespace Braintree; | |
-class Braintree_MultipleValueNode | |
+use InvalidArgumentException; | |
+ | |
+class MultipleValueNode | |
{ | |
- function __construct($name, $allowedValues = array()) | |
+ public function __construct($name, $allowedValues = []) | |
{ | |
$this->name = $name; | |
- $this->items = array(); | |
+ $this->items = []; | |
$this->allowedValues = $allowedValues; | |
} | |
- function in($values) | |
+ public function in($values) | |
{ | |
$bad_values = array_diff($values, $this->allowedValues); | |
if (count($this->allowedValues) > 0 && count($bad_values) > 0) { | |
@@ -25,13 +28,14 @@ | |
return $this; | |
} | |
- function is($value) | |
+ public function is($value) | |
{ | |
- return $this->in(array($value)); | |
+ return $this->in([$value]); | |
} | |
- function toParam() | |
+ public function toParam() | |
{ | |
return $this->items; | |
} | |
} | |
+class_alias('Braintree\MultipleValueNode', 'Braintree_MultipleValueNode'); | |
Index: braintree_sdk/lib/Braintree/MultipleValueOrTextNode.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/MultipleValueOrTextNode.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/MultipleValueOrTextNode.php (working copy) | |
@@ -1,45 +1,47 @@ | |
<?php | |
+namespace Braintree; | |
-class Braintree_MultipleValueOrTextNode extends Braintree_MultipleValueNode | |
+class MultipleValueOrTextNode extends MultipleValueNode | |
{ | |
- function __construct($name) | |
+ public function __construct($name) | |
{ | |
parent::__construct($name); | |
- $this->textNode = new Braintree_TextNode($name); | |
+ $this->textNode = new TextNode($name); | |
} | |
- function contains($value) | |
+ public function contains($value) | |
{ | |
$this->textNode->contains($value); | |
return $this; | |
} | |
- function endsWith($value) | |
+ public function endsWith($value) | |
{ | |
$this->textNode->endsWith($value); | |
return $this; | |
} | |
- function is($value) | |
+ public function is($value) | |
{ | |
$this->textNode->is($value); | |
return $this; | |
} | |
- function isNot($value) | |
+ public function isNot($value) | |
{ | |
$this->textNode->isNot($value); | |
return $this; | |
} | |
- function startsWith($value) | |
+ public function startsWith($value) | |
{ | |
$this->textNode->startsWith($value); | |
return $this; | |
} | |
- function toParam() | |
+ public function toParam() | |
{ | |
return array_merge(parent::toParam(), $this->textNode->toParam()); | |
} | |
} | |
+class_alias('Braintree\MultipleValueOrTextNode', 'Braintree_MultipleValueOrTextNode'); | |
Index: braintree_sdk/lib/Braintree/OAuthCredentials.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/OAuthCredentials.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/OAuthCredentials.php (working copy) | |
@@ -1,13 +1,15 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
/** | |
* Braintree OAuthCredentials module | |
* | |
* @package Braintree | |
* @category Resources | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
*/ | |
-class Braintree_OAuthCredentials extends Braintree_Base | |
+class OAuthCredentials extends Base | |
{ | |
protected function _initialize($attribs) | |
{ | |
@@ -25,9 +27,10 @@ | |
* returns a string representation of the access token | |
* @return string | |
*/ | |
- public function __toString() | |
+ public function __toString() | |
{ | |
return __CLASS__ . '[' . | |
- Braintree_Util::attributesToString($this->_attributes) .']'; | |
+ Util::attributesToString($this->_attributes) .']'; | |
} | |
} | |
+class_alias('Braintree\OAuthCredentials', 'Braintree_OAuthCredentials'); | |
Index: braintree_sdk/lib/Braintree/OAuthGateway.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/OAuthGateway.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/OAuthGateway.php (working copy) | |
@@ -1,13 +1,15 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
/** | |
* Braintree OAuthGateway module | |
* PHP Version 5 | |
* Creates and manages Braintree Addresses | |
* | |
* @package Braintree | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_OAuthGateway | |
+class OAuthGateway | |
{ | |
private $_gateway; | |
private $_config; | |
@@ -17,7 +19,7 @@ | |
{ | |
$this->_gateway = $gateway; | |
$this->_config = $gateway->config; | |
- $this->_http = new Braintree_Http($gateway->config); | |
+ $this->_http = new Http($gateway->config); | |
$this->_http->useClientCredentials(); | |
$this->_config->assertHasClientCredentials(); | |
@@ -37,7 +39,7 @@ | |
private function _createToken($params) | |
{ | |
- $params = array('credentials' => $params); | |
+ $params = ['credentials' => $params]; | |
$response = $this->_http->post('/oauth/access_tokens', $params); | |
return $this->_verifyGatewayResponse($response); | |
} | |
@@ -45,15 +47,15 @@ | |
private function _verifyGatewayResponse($response) | |
{ | |
if (isset($response['credentials'])) { | |
- $result = new Braintree_Result_Successful( | |
- Braintree_OAuthCredentials::factory($response['credentials']) | |
+ $result = new Result\Successful( | |
+ OAuthCredentials::factory($response['credentials']) | |
); | |
return $this->_mapSuccess($result); | |
} else if (isset($response['apiErrorResponse'])) { | |
- $result = new Braintree_Result_Error($response['apiErrorResponse']); | |
+ $result = new Result\Error($response['apiErrorResponse']); | |
return $this->_mapError($result); | |
} else { | |
- throw new Braintree_Exception_Unexpected( | |
+ throw new Exception\Unexpected( | |
"Expected credentials or apiErrorResponse" | |
); | |
} | |
@@ -63,11 +65,11 @@ | |
{ | |
$error = $result->errors->deepAll()[0]; | |
- if ($error->code == Braintree_Error_Codes::OAUTH_INVALID_GRANT) { | |
+ if ($error->code == Error\Codes::OAUTH_INVALID_GRANT) { | |
$result->error = 'invalid_grant'; | |
- } else if ($error->code == Braintree_Error_Codes::OAUTH_INVALID_CREDENTIALS) { | |
+ } else if ($error->code == Error\Codes::OAUTH_INVALID_CREDENTIALS) { | |
$result->error = 'invalid_credentials'; | |
- } else if ($error->code == Braintree_Error_Codes::OAUTH_INVALID_SCOPE) { | |
+ } else if ($error->code == Error\Codes::OAUTH_INVALID_SCOPE) { | |
$result->error = 'invalid_scope'; | |
} | |
$result->errorDescription = explode(': ', $error->message)[1]; | |
@@ -84,9 +86,9 @@ | |
return $result; | |
} | |
- public function connectUrl($params = array()) | |
+ public function connectUrl($params = []) | |
{ | |
- $query = Braintree_Util::camelCaseToDelimiterArray($params, '_'); | |
+ $query = Util::camelCaseToDelimiterArray($params, '_'); | |
$query['client_id'] = $this->_config->getClientId(); | |
$queryString = preg_replace('/\%5B\d+\%5D/', '%5B%5D', http_build_query($query)); | |
$url = $this->_config->baseUrl() . '/oauth/connect?' . $queryString; | |
@@ -100,3 +102,4 @@ | |
return hash_hmac('sha256', $url, $key); | |
} | |
} | |
+class_alias('Braintree\OAuthGateway', 'Braintree_OAuthGateway'); | |
Index: braintree_sdk/lib/Braintree/PartialMatchNode.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/PartialMatchNode.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/PartialMatchNode.php (working copy) | |
@@ -1,16 +1,18 @@ | |
<?php | |
+namespace Braintree; | |
-class Braintree_PartialMatchNode extends Braintree_EqualityNode | |
+class PartialMatchNode extends EqualityNode | |
{ | |
- function startsWith($value) | |
+ public function startsWith($value) | |
{ | |
$this->searchTerms["starts_with"] = strval($value); | |
return $this; | |
} | |
- function endsWith($value) | |
+ public function endsWith($value) | |
{ | |
$this->searchTerms["ends_with"] = strval($value); | |
return $this; | |
} | |
} | |
+class_alias('Braintree\PartialMatchNode', 'Braintree_PartialMatchNode'); | |
Index: braintree_sdk/lib/Braintree/PartnerMerchant.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/PartnerMerchant.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/PartnerMerchant.php (working copy) | |
@@ -1,4 +1,6 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
/** | |
* Partner Merchant information that is generated when a partner is connected | |
* to or disconnected from a user. | |
@@ -6,18 +8,17 @@ | |
* Creates an instance of PartnerMerchants | |
* | |
* @package Braintree | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
* @property-read string $merchantPublicId | |
* @property-read string $publicKey | |
* @property-read string $privateKey | |
* @property-read string $clientSideEncryptionKey | |
* @property-read string $partnerMerchantId | |
- * @uses Braintree_Instance inherits methods | |
*/ | |
-class Braintree_PartnerMerchant extends Braintree_Base | |
+class PartnerMerchant extends Base | |
{ | |
- protected $_attributes = array(); | |
+ protected $_attributes = []; | |
/** | |
* @ignore | |
@@ -38,3 +39,4 @@ | |
$this->_attributes = $attributes; | |
} | |
} | |
+class_alias('Braintree\PartnerMerchant', 'Braintree_PartnerMerchant'); | |
Index: braintree_sdk/lib/Braintree/PayPalAccount.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/PayPalAccount.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/PayPalAccount.php (working copy) | |
@@ -1,10 +1,12 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
/** | |
* Braintree PayPalAccount module | |
* | |
* @package Braintree | |
* @category Resources | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
/** | |
@@ -15,20 +17,21 @@ | |
* | |
* @package Braintree | |
* @category Resources | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
+ * @property-read string $customerId | |
* @property-read string $email | |
* @property-read string $token | |
* @property-read string $imageUrl | |
*/ | |
-class Braintree_PayPalAccount extends Braintree_Base | |
+class PayPalAccount extends Base | |
{ | |
/** | |
- * factory method: returns an instance of Braintree_PayPalAccount | |
+ * factory method: returns an instance of PayPalAccount | |
* to the requesting method, with populated properties | |
* | |
* @ignore | |
- * @return object instance of Braintree_PayPalAccount | |
+ * @return PayPalAccount | |
*/ | |
public static function factory($attributes) | |
{ | |
@@ -54,17 +57,17 @@ | |
* | |
* @access protected | |
* @param array $paypalAccountAttribs array of paypalAccount data | |
- * @return none | |
+ * @return void | |
*/ | |
protected function _initialize($paypalAccountAttribs) | |
{ | |
// set the attributes | |
$this->_attributes = $paypalAccountAttribs; | |
- $subscriptionArray = array(); | |
+ $subscriptionArray = []; | |
if (isset($paypalAccountAttribs['subscriptions'])) { | |
foreach ($paypalAccountAttribs['subscriptions'] AS $subscription) { | |
- $subscriptionArray[] = Braintree_Subscription::factory($subscription); | |
+ $subscriptionArray[] = Subscription::factory($subscription); | |
} | |
} | |
@@ -79,7 +82,7 @@ | |
public function __toString() | |
{ | |
return __CLASS__ . '[' . | |
- Braintree_Util::attributesToString($this->_attributes) .']'; | |
+ Util::attributesToString($this->_attributes) . ']'; | |
} | |
@@ -87,21 +90,22 @@ | |
public static function find($token) | |
{ | |
- return Braintree_Configuration::gateway()->payPalAccount()->find($token); | |
+ return Configuration::gateway()->payPalAccount()->find($token); | |
} | |
public static function update($token, $attributes) | |
{ | |
- return Braintree_Configuration::gateway()->payPalAccount()->update($token, $attributes); | |
+ return Configuration::gateway()->payPalAccount()->update($token, $attributes); | |
} | |
public static function delete($token) | |
{ | |
- return Braintree_Configuration::gateway()->payPalAccount()->delete($token); | |
+ return Configuration::gateway()->payPalAccount()->delete($token); | |
} | |
public static function sale($token, $transactionAttribs) | |
{ | |
- return Braintree_Configuration::gateway()->payPalAccount()->sale($token, $transactionAttribs); | |
+ return Configuration::gateway()->payPalAccount()->sale($token, $transactionAttribs); | |
} | |
} | |
+class_alias('Braintree\PayPalAccount', 'Braintree_PayPalAccount'); | |
Index: braintree_sdk/lib/Braintree/PayPalAccountGateway.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/PayPalAccountGateway.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/PayPalAccountGateway.php (working copy) | |
@@ -1,10 +1,14 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
+use InvalidArgumentException; | |
+ | |
/** | |
* Braintree PayPalAccountGateway module | |
* | |
* @package Braintree | |
* @category Resources | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
/** | |
@@ -15,9 +19,9 @@ | |
* | |
* @package Braintree | |
* @category Resources | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_PayPalAccountGateway | |
+class PayPalAccountGateway | |
{ | |
private $_gateway; | |
private $_config; | |
@@ -28,7 +32,7 @@ | |
$this->_gateway = $gateway; | |
$this->_config = $gateway->config; | |
$this->_config->assertHasAccessTokenOrKeys(); | |
- $this->_http = new Braintree_Http($gateway->config); | |
+ $this->_http = new Http($gateway->config); | |
} | |
@@ -37,8 +41,8 @@ | |
* | |
* @access public | |
* @param string $token paypal accountunique id | |
- * @return object Braintree_PayPalAccount | |
- * @throws Braintree_Exception_NotFound | |
+ * @return PayPalAccount | |
+ * @throws Exception\NotFound | |
*/ | |
public function find($token) | |
{ | |
@@ -46,9 +50,9 @@ | |
try { | |
$path = $this->_config->merchantPath() . '/payment_methods/paypal_account/' . $token; | |
$response = $this->_http->get($path); | |
- return Braintree_PayPalAccount::factory($response['paypalAccount']); | |
- } catch (Braintree_Exception_NotFound $e) { | |
- throw new Braintree_Exception_NotFound( | |
+ return PayPalAccount::factory($response['paypalAccount']); | |
+ } catch (Exception\NotFound $e) { | |
+ throw new Exception\NotFound( | |
'paypal account with token ' . $token . ' not found' | |
); | |
} | |
@@ -64,13 +68,13 @@ | |
* @access public | |
* @param array $attributes | |
* @param string $token (optional) | |
- * @return object Braintree_Result_Successful or Braintree_Result_Error | |
+ * @return Result\Successful or Result\Error | |
*/ | |
public function update($token, $attributes) | |
{ | |
- Braintree_Util::verifyKeys(self::updateSignature(), $attributes); | |
+ Util::verifyKeys(self::updateSignature(), $attributes); | |
$this->_validateId($token); | |
- return $this->_doUpdate('put', '/payment_methods/paypal_account/' . $token, array('paypalAccount' => $attributes)); | |
+ return $this->_doUpdate('put', '/payment_methods/paypal_account/' . $token, ['paypalAccount' => $attributes]); | |
} | |
public function delete($token) | |
@@ -78,7 +82,7 @@ | |
$this->_validateId($token); | |
$path = $this->_config->merchantPath() . '/payment_methods/paypal_account/' . $token; | |
$this->_http->delete($path); | |
- return new Braintree_Result_Successful(); | |
+ return new Result\Successful(); | |
} | |
/** | |
@@ -86,26 +90,26 @@ | |
* | |
* @param string $token | |
* @param array $transactionAttribs | |
- * @return object Braintree_Result_Successful or Braintree_Result_Error | |
- * @see Braintree_Transaction::sale() | |
+ * @return Result\Successful|Result\Error | |
+ * @see Transaction::sale() | |
*/ | |
public function sale($token, $transactionAttribs) | |
{ | |
$this->_validateId($token); | |
- return Braintree_Transaction::sale( | |
+ return Transaction::sale( | |
array_merge( | |
$transactionAttribs, | |
- array('paymentMethodToken' => $token) | |
+ ['paymentMethodToken' => $token] | |
) | |
); | |
} | |
public static function updateSignature() | |
{ | |
- return array( | |
+ return [ | |
'token', | |
- array('options' => array('makeDefault')) | |
- ); | |
+ ['options' => ['makeDefault']] | |
+ ]; | |
} | |
/** | |
@@ -126,27 +130,27 @@ | |
/** | |
* generic method for validating incoming gateway responses | |
* | |
- * creates a new Braintree_PayPalAccount object and encapsulates | |
- * it inside a Braintree_Result_Successful object, or | |
- * encapsulates a Braintree_Errors object inside a Result_Error | |
+ * creates a new PayPalAccount object and encapsulates | |
+ * it inside a Result\Successful object, or | |
+ * encapsulates a Errors object inside a Result\Error | |
* alternatively, throws an Unexpected exception if the response is invalid. | |
* | |
* @ignore | |
* @param array $response gateway response values | |
- * @return object Result_Successful or Result_Error | |
- * @throws Braintree_Exception_Unexpected | |
+ * @return Result\Successful|Result\Error | |
+ * @throws Exception\Unexpected | |
*/ | |
private function _verifyGatewayResponse($response) | |
{ | |
if (isset($response['paypalAccount'])) { | |
- // return a populated instance of Braintree_PayPalAccount | |
- return new Braintree_Result_Successful( | |
- Braintree_PayPalAccount::factory($response['paypalAccount']) | |
+ // return a populated instance of PayPalAccount | |
+ return new Result\Successful( | |
+ PayPalAccount::factory($response['paypalAccount']) | |
); | |
} else if (isset($response['apiErrorResponse'])) { | |
- return new Braintree_Result_Error($response['apiErrorResponse']); | |
+ return new Result\Error($response['apiErrorResponse']); | |
} else { | |
- throw new Braintree_Exception_Unexpected( | |
+ throw new Exception\Unexpected( | |
'Expected paypal account or apiErrorResponse' | |
); | |
} | |
@@ -173,3 +177,4 @@ | |
} | |
} | |
} | |
+class_alias('Braintree\PayPalAccountGateway', 'Braintree_PayPalAccountGateway'); | |
Index: braintree_sdk/lib/Braintree/PaymentInstrumentType.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/PaymentInstrumentType.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/PaymentInstrumentType.php (working copy) | |
@@ -1,6 +1,7 @@ | |
<?php | |
+namespace Braintree; | |
-final class Braintree_PaymentInstrumentType | |
+final class PaymentInstrumentType | |
{ | |
const PAYPAL_ACCOUNT = 'paypal_account'; | |
const COINBASE_ACCOUNT = 'coinbase_account'; | |
@@ -9,3 +10,4 @@ | |
const APPLE_PAY_CARD = 'apple_pay_card'; | |
const ANDROID_PAY_CARD = 'android_pay_card'; | |
} | |
+class_alias('Braintree\PaymentInstrumentType', 'Braintree_PaymentInstrumentType'); | |
Index: braintree_sdk/lib/Braintree/PaymentMethod.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/PaymentMethod.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/PaymentMethod.php (working copy) | |
@@ -1,10 +1,12 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
/** | |
* Braintree PaymentMethod module | |
* | |
* @package Braintree | |
* @category Resources | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
/** | |
@@ -15,30 +17,31 @@ | |
* | |
* @package Braintree | |
* @category Resources | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
*/ | |
-class Braintree_PaymentMethod extends Braintree_Base | |
+class PaymentMethod extends Base | |
{ | |
// static methods redirecting to gateway | |
public static function create($attribs) | |
{ | |
- return Braintree_Configuration::gateway()->paymentMethod()->create($attribs); | |
+ return Configuration::gateway()->paymentMethod()->create($attribs); | |
} | |
public static function find($token) | |
{ | |
- return Braintree_Configuration::gateway()->paymentMethod()->find($token); | |
+ return Configuration::gateway()->paymentMethod()->find($token); | |
} | |
public static function update($token, $attribs) | |
{ | |
- return Braintree_Configuration::gateway()->paymentMethod()->update($token, $attribs); | |
+ return Configuration::gateway()->paymentMethod()->update($token, $attribs); | |
} | |
public static function delete($token) | |
{ | |
- return Braintree_Configuration::gateway()->paymentMethod()->delete($token); | |
+ return Configuration::gateway()->paymentMethod()->delete($token); | |
} | |
} | |
+class_alias('Braintree\PaymentMethod', 'Braintree_PaymentMethod'); | |
Index: braintree_sdk/lib/Braintree/PaymentMethodGateway.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/PaymentMethodGateway.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/PaymentMethodGateway.php (working copy) | |
@@ -1,10 +1,14 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
+use InvalidArgumentException; | |
+ | |
/** | |
* Braintree PaymentMethodGateway module | |
* | |
* @package Braintree | |
* @category Resources | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
/** | |
@@ -15,10 +19,10 @@ | |
* | |
* @package Braintree | |
* @category Resources | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
*/ | |
-class Braintree_PaymentMethodGateway | |
+class PaymentMethodGateway | |
{ | |
private $_gateway; | |
private $_config; | |
@@ -29,23 +33,22 @@ | |
$this->_gateway = $gateway; | |
$this->_config = $gateway->config; | |
$this->_config->assertHasAccessTokenOrKeys(); | |
- $this->_http = new Braintree_Http($gateway->config); | |
+ $this->_http = new Http($gateway->config); | |
} | |
public function create($attribs) | |
{ | |
- Braintree_Util::verifyKeys(self::createSignature(), $attribs); | |
- return $this->_doCreate('/payment_methods', array('payment_method' => $attribs)); | |
+ Util::verifyKeys(self::createSignature(), $attribs); | |
+ return $this->_doCreate('/payment_methods', ['payment_method' => $attribs]); | |
} | |
/** | |
* find a PaymentMethod by token | |
* | |
- * @access public | |
* @param string $token payment method unique id | |
- * @return object Braintree_CreditCard or Braintree_PayPalAccount | |
- * @throws Braintree_Exception_NotFound | |
+ * @return CreditCard|PayPalAccount | |
+ * @throws Exception\NotFound | |
*/ | |
public function find($token) | |
{ | |
@@ -54,32 +57,35 @@ | |
$path = $this->_config->merchantPath() . '/payment_methods/any/' . $token; | |
$response = $this->_http->get($path); | |
if (isset($response['creditCard'])) { | |
- return Braintree_CreditCard::factory($response['creditCard']); | |
+ return CreditCard::factory($response['creditCard']); | |
} else if (isset($response['paypalAccount'])) { | |
- return Braintree_PayPalAccount::factory($response['paypalAccount']); | |
+ return PayPalAccount::factory($response['paypalAccount']); | |
} else if (isset($response['coinbaseAccount'])) { | |
- return Braintree_CoinbaseAccount::factory($response['coinbaseAccount']); | |
+ return CoinbaseAccount::factory($response['coinbaseAccount']); | |
} else if (isset($response['applePayCard'])) { | |
- return Braintree_ApplePayCard::factory($response['applePayCard']); | |
+ return ApplePayCard::factory($response['applePayCard']); | |
} else if (isset($response['androidPayCard'])) { | |
- return Braintree_AndroidPayCard::factory($response['androidPayCard']); | |
+ return AndroidPayCard::factory($response['androidPayCard']); | |
+ } else if (isset($response['amexExpressCheckoutCard'])) { | |
+ return AmexExpressCheckoutCard::factory($response['amexExpressCheckoutCard']); | |
} else if (isset($response['europeBankAccount'])) { | |
- return Braintree_EuropeBankAccount::factory($response['europeBankAccount']); | |
+ return EuropeBankAccount::factory($response['europeBankAccount']); | |
+ } else if (isset($response['venmoAccount'])) { | |
+ return VenmoAccount::factory($response['venmoAccount']); | |
} else if (is_array($response)) { | |
- return Braintree_UnknownPaymentMethod::factory($response); | |
+ return UnknownPaymentMethod::factory($response); | |
} | |
- } catch (Braintree_Exception_NotFound $e) { | |
- throw new Braintree_Exception_NotFound( | |
+ } catch (Exception\NotFound $e) { | |
+ throw new Exception\NotFound( | |
'payment method with token ' . $token . ' not found' | |
); | |
} | |
- | |
} | |
public function update($token, $attribs) | |
{ | |
- Braintree_Util::verifyKeys(self::updateSignature(), $attribs); | |
- return $this->_doUpdate('/payment_methods/any/' . $token, array('payment_method' => $attribs)); | |
+ Util::verifyKeys(self::updateSignature(), $attribs); | |
+ return $this->_doUpdate('/payment_methods/any/' . $token, ['payment_method' => $attribs]); | |
} | |
public function delete($token) | |
@@ -87,19 +93,45 @@ | |
$this->_validateId($token); | |
$path = $this->_config->merchantPath() . '/payment_methods/any/' . $token; | |
$this->_http->delete($path); | |
- return new Braintree_Result_Successful(); | |
+ return new Result\Successful(); | |
} | |
+ public function grant($sharedPaymentMethodToken, $allowVaulting) | |
+ { | |
+ return $this->_doCreate( | |
+ '/payment_methods/grant', | |
+ [ | |
+ 'payment_method' => [ | |
+ 'shared_payment_method_token' => $sharedPaymentMethodToken, | |
+ 'allow_vaulting' => $allowVaulting | |
+ ] | |
+ ] | |
+ ); | |
+ } | |
+ | |
+ public function revoke($sharedPaymentMethodToken) | |
+ { | |
+ return $this->_doCreate( | |
+ '/payment_methods/revoke', | |
+ [ | |
+ 'payment_method' => [ | |
+ 'shared_payment_method_token' => $sharedPaymentMethodToken | |
+ ] | |
+ ] | |
+ ); | |
+ } | |
+ | |
private static function baseSignature() | |
{ | |
- $billingAddressSignature = Braintree_AddressGateway::createSignature(); | |
- $optionsSignature = array( | |
+ $billingAddressSignature = AddressGateway::createSignature(); | |
+ $optionsSignature = [ | |
'failOnDuplicatePaymentMethod', | |
'makeDefault', | |
'verificationMerchantAccountId', | |
- 'verifyCard' | |
- ); | |
- return array( | |
+ 'verifyCard', | |
+ 'verificationAmount' | |
+ ]; | |
+ return [ | |
'billingAddressId', | |
'cardholderName', | |
'cvv', | |
@@ -110,31 +142,31 @@ | |
'number', | |
'paymentMethodNonce', | |
'token', | |
- array('options' => $optionsSignature), | |
- array('billingAddress' => $billingAddressSignature) | |
- ); | |
+ ['options' => $optionsSignature], | |
+ ['billingAddress' => $billingAddressSignature] | |
+ ]; | |
} | |
public static function createSignature() | |
{ | |
- $signature = array_merge(self::baseSignature(), array('customerId')); | |
+ $signature = array_merge(self::baseSignature(), ['customerId']); | |
return $signature; | |
} | |
public static function updateSignature() | |
{ | |
- $billingAddressSignature = Braintree_AddressGateway::updateSignature(); | |
- array_push($billingAddressSignature, array( | |
- 'options' => array( | |
+ $billingAddressSignature = AddressGateway::updateSignature(); | |
+ array_push($billingAddressSignature, [ | |
+ 'options' => [ | |
'updateExisting' | |
- ) | |
- )); | |
- $signature = array_merge(self::baseSignature(), array( | |
+ ] | |
+ ]); | |
+ $signature = array_merge(self::baseSignature(), [ | |
'deviceSessionId', | |
'venmoSdkPaymentMethodCode', | |
'fraudMerchantId', | |
- array('billingAddress' => $billingAddressSignature) | |
- )); | |
+ ['billingAddress' => $billingAddressSignature] | |
+ ]); | |
return $signature; | |
} | |
@@ -173,63 +205,72 @@ | |
/** | |
* generic method for validating incoming gateway responses | |
* | |
- * creates a new Braintree_CreditCard or Braintree_PayPalAccount object | |
- * and encapsulates it inside a Braintree_Result_Successful object, or | |
- * encapsulates a Braintree_Errors object inside a Result_Error | |
+ * creates a new CreditCard or PayPalAccount object | |
+ * and encapsulates it inside a Result\Successful object, or | |
+ * encapsulates a Errors object inside a Result\Error | |
* alternatively, throws an Unexpected exception if the response is invalid. | |
* | |
* @ignore | |
* @param array $response gateway response values | |
- * @return object Result_Successful or Result_Error | |
- * @throws Braintree_Exception_Unexpected | |
+ * @return Result\Successful|Result\Error | |
+ * @throws Exception\Unexpected | |
*/ | |
private function _verifyGatewayResponse($response) | |
{ | |
if (isset($response['creditCard'])) { | |
- // return a populated instance of Braintree_CreditCard | |
- return new Braintree_Result_Successful( | |
- Braintree_CreditCard::factory($response['creditCard']), | |
- "paymentMethod" | |
+ return new Result\Successful( | |
+ CreditCard::factory($response['creditCard']), | |
+ 'paymentMethod' | |
); | |
} else if (isset($response['paypalAccount'])) { | |
- // return a populated instance of Braintree_PayPalAccount | |
- return new Braintree_Result_Successful( | |
- Braintree_PayPalAccount::factory($response['paypalAccount']), | |
+ return new Result\Successful( | |
+ PayPalAccount::factory($response['paypalAccount']), | |
"paymentMethod" | |
); | |
} else if (isset($response['coinbaseAccount'])) { | |
- // return a populated instance of Braintree_CoinbaseAccount | |
- return new Braintree_Result_Successful( | |
- Braintree_CoinbaseAccount::factory($response['coinbaseAccount']), | |
+ return new Result\Successful( | |
+ CoinbaseAccount::factory($response['coinbaseAccount']), | |
"paymentMethod" | |
); | |
} else if (isset($response['applePayCard'])) { | |
- // return a populated instance of Braintree_ApplePayCard | |
- return new Braintree_Result_Successful( | |
- Braintree_ApplePayCard::factory($response['applePayCard']), | |
+ return new Result\Successful( | |
+ ApplePayCard::factory($response['applePayCard']), | |
"paymentMethod" | |
); | |
} else if (isset($response['androidPayCard'])) { | |
- // return a populated instance of Braintree_AndroidPayCard | |
- return new Braintree_Result_Successful( | |
- Braintree_AndroidPayCard::factory($response['androidPayCard']), | |
+ return new Result\Successful( | |
+ AndroidPayCard::factory($response['androidPayCard']), | |
"paymentMethod" | |
); | |
+ } else if (isset($response['amexExpressCheckoutCard'])) { | |
+ return new Result\Successful( | |
+ AmexExpressCheckoutCard::factory($response['amexExpressCheckoutCard']), | |
+ "paymentMethod" | |
+ ); | |
} else if (isset($response['europeBankAccount'])) { | |
- // return a populated instance of Braintree_EuropeBankAccount | |
- return new Braintree_Result_Successful( | |
- Braintree_EuropeBankAccount::factory($response['europeBankAccount']), | |
+ return new Result\Successful( | |
+ EuropeBankAccount::factory($response['europeBankAccount']), | |
"paymentMethod" | |
); | |
+ } else if (isset($response['venmoAccount'])) { | |
+ return new Result\Successful( | |
+ VenmoAccount::factory($response['venmoAccount']), | |
+ "paymentMethod" | |
+ ); | |
+ } else if (isset($response['paymentMethodNonce'])) { | |
+ return new Result\Successful( | |
+ PaymentMethodNonce::factory($response['paymentMethodNonce']), | |
+ "paymentMethodNonce" | |
+ ); | |
} else if (isset($response['apiErrorResponse'])) { | |
- return new Braintree_Result_Error($response['apiErrorResponse']); | |
+ return new Result\Error($response['apiErrorResponse']); | |
} else if (is_array($response)) { | |
- return new Braintree_Result_Successful( | |
- Braintree_UnknownPaymentMethod::factory($response), | |
+ return new Result\Successful( | |
+ UnknownPaymentMethod::factory($response), | |
"paymentMethod" | |
); | |
} else { | |
- throw new Braintree_Exception_Unexpected( | |
+ throw new Exception\Unexpected( | |
'Expected payment method or apiErrorResponse' | |
); | |
} | |
@@ -256,3 +297,4 @@ | |
} | |
} | |
} | |
+class_alias('Braintree\PaymentMethodGateway', 'Braintree_PaymentMethodGateway'); | |
Index: braintree_sdk/lib/Braintree/PaymentMethodNonce.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/PaymentMethodNonce.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/PaymentMethodNonce.php (working copy) | |
@@ -1,10 +1,12 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
/** | |
* Braintree PaymentMethodNonce module | |
* | |
* @package Braintree | |
* @category Resources | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
/** | |
@@ -15,21 +17,21 @@ | |
* | |
* @package Braintree | |
* @category Resources | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
*/ | |
-class Braintree_PaymentMethodNonce extends Braintree_Base | |
+class PaymentMethodNonce extends Base | |
{ | |
// static methods redirecting to gateway | |
public static function create($token) | |
{ | |
- return Braintree_Configuration::gateway()->paymentMethodNonce()->create($token); | |
+ return Configuration::gateway()->paymentMethodNonce()->create($token); | |
} | |
public static function find($nonce) | |
{ | |
- return Braintree_Configuration::gateway()->paymentMethodNonce()->find($nonce); | |
+ return Configuration::gateway()->paymentMethodNonce()->find($nonce); | |
} | |
public static function factory($attributes) | |
@@ -46,7 +48,8 @@ | |
$this->_set('type', $nonceAttributes['type']); | |
if(isset($nonceAttributes['threeDSecureInfo'])) { | |
- $this->_set('threeDSecureInfo', Braintree_ThreeDSecureInfo::factory($nonceAttributes['threeDSecureInfo'])); | |
+ $this->_set('threeDSecureInfo', ThreeDSecureInfo::factory($nonceAttributes['threeDSecureInfo'])); | |
} | |
} | |
} | |
+class_alias('Braintree\PaymentMethodNonce', 'Braintree_PaymentMethodNonce'); | |
Index: braintree_sdk/lib/Braintree/PaymentMethodNonceGateway.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/PaymentMethodNonceGateway.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/PaymentMethodNonceGateway.php (working copy) | |
@@ -1,10 +1,12 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
/** | |
* Braintree PaymentMethodNonceGateway module | |
* | |
* @package Braintree | |
* @category Resources | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
/** | |
@@ -15,10 +17,10 @@ | |
* | |
* @package Braintree | |
* @category Resources | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
*/ | |
-class Braintree_PaymentMethodNonceGateway | |
+class PaymentMethodNonceGateway | |
{ | |
private $_gateway; | |
private $_config; | |
@@ -28,7 +30,7 @@ | |
{ | |
$this->_gateway = $gateway; | |
$this->_config = $gateway->config; | |
- $this->_http = new Braintree_Http($gateway->config); | |
+ $this->_http = new Http($gateway->config); | |
} | |
@@ -38,8 +40,8 @@ | |
$fullPath = $this->_config->merchantPath() . $subPath; | |
$response = $this->_http->post($fullPath); | |
- return new Braintree_Result_Successful( | |
- Braintree_PaymentMethodNonce::factory($response['paymentMethodNonce']), | |
+ return new Result\Successful( | |
+ PaymentMethodNonce::factory($response['paymentMethodNonce']), | |
"paymentMethodNonce" | |
); | |
} | |
@@ -53,12 +55,13 @@ | |
try { | |
$path = $this->_config->merchantPath() . '/payment_method_nonces/' . $nonce; | |
$response = $this->_http->get($path); | |
- return Braintree_PaymentMethodNonce::factory($response['paymentMethodNonce']); | |
- } catch (Braintree_Exception_NotFound $e) { | |
- throw new Braintree_Exception_NotFound( | |
+ return PaymentMethodNonce::factory($response['paymentMethodNonce']); | |
+ } catch (Exception\NotFound $e) { | |
+ throw new Exception\NotFound( | |
'payment method nonce with id ' . $nonce . ' not found' | |
); | |
} | |
} | |
} | |
+class_alias('Braintree\PaymentMethodNonceGateway', 'Braintree_PaymentMethodNonceGateway'); | |
Index: braintree_sdk/lib/Braintree/Plan.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Plan.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Plan.php (working copy) | |
@@ -1,5 +1,7 @@ | |
<?php | |
-class Braintree_Plan extends Braintree_Base | |
+namespace Braintree; | |
+ | |
+class Plan extends Base | |
{ | |
public static function factory($attributes) | |
{ | |
@@ -13,26 +15,26 @@ | |
{ | |
$this->_attributes = $attributes; | |
- $addOnArray = array(); | |
+ $addOnArray = []; | |
if (isset($attributes['addOns'])) { | |
foreach ($attributes['addOns'] AS $addOn) { | |
- $addOnArray[] = Braintree_AddOn::factory($addOn); | |
+ $addOnArray[] = AddOn::factory($addOn); | |
} | |
} | |
$this->_attributes['addOns'] = $addOnArray; | |
- $discountArray = array(); | |
+ $discountArray = []; | |
if (isset($attributes['discounts'])) { | |
foreach ($attributes['discounts'] AS $discount) { | |
- $discountArray[] = Braintree_Discount::factory($discount); | |
+ $discountArray[] = Discount::factory($discount); | |
} | |
} | |
$this->_attributes['discounts'] = $discountArray; | |
- $planArray = array(); | |
+ $planArray = []; | |
if (isset($attributes['plans'])) { | |
foreach ($attributes['plans'] AS $plan) { | |
- $planArray[] = Braintree_Plan::factory($plan); | |
+ $planArray[] = self::factory($plan); | |
} | |
} | |
$this->_attributes['plans'] = $planArray; | |
@@ -43,6 +45,7 @@ | |
public static function all() | |
{ | |
- return Braintree_Configuration::gateway()->plan()->all(); | |
+ return Configuration::gateway()->plan()->all(); | |
} | |
} | |
+class_alias('Braintree\Plan', 'Braintree_Plan'); | |
Index: braintree_sdk/lib/Braintree/PlanGateway.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/PlanGateway.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/PlanGateway.php (working copy) | |
@@ -1,5 +1,7 @@ | |
<?php | |
-class Braintree_PlanGateway | |
+namespace Braintree; | |
+ | |
+class PlanGateway | |
{ | |
private $_gateway; | |
private $_config; | |
@@ -10,7 +12,7 @@ | |
$this->_gateway = $gateway; | |
$this->_config = $gateway->config; | |
$this->_config->assertHasAccessTokenOrKeys(); | |
- $this->_http = new Braintree_Http($gateway->config); | |
+ $this->_http = new Http($gateway->config); | |
} | |
public function all() | |
@@ -18,14 +20,15 @@ | |
$path = $this->_config->merchantPath() . '/plans'; | |
$response = $this->_http->get($path); | |
if (key_exists('plans', $response)){ | |
- $plans = array("plan" => $response['plans']); | |
+ $plans = ["plan" => $response['plans']]; | |
} else { | |
- $plans = array("plan" => array()); | |
+ $plans = ["plan" => []]; | |
} | |
- return Braintree_Util::extractAttributeAsArray( | |
+ return Util::extractAttributeAsArray( | |
$plans, | |
'plan' | |
); | |
} | |
} | |
+class_alias('Braintree\PlanGateway', 'Braintree_PlanGateway'); | |
Index: braintree_sdk/lib/Braintree/RangeNode.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/RangeNode.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/RangeNode.php (working copy) | |
@@ -1,38 +1,40 @@ | |
<?php | |
+namespace Braintree; | |
-class Braintree_RangeNode | |
+class RangeNode | |
{ | |
- function __construct($name) | |
+ public function __construct($name) | |
{ | |
$this->name = $name; | |
- $this->searchTerms = array(); | |
+ $this->searchTerms = []; | |
} | |
- function greaterThanOrEqualTo($value) | |
+ public function greaterThanOrEqualTo($value) | |
{ | |
$this->searchTerms['min'] = $value; | |
return $this; | |
} | |
- function lessThanOrEqualTo($value) | |
+ public function lessThanOrEqualTo($value) | |
{ | |
$this->searchTerms['max'] = $value; | |
return $this; | |
} | |
- function is($value) | |
+ public function is($value) | |
{ | |
$this->searchTerms['is'] = $value; | |
return $this; | |
} | |
- function between($min, $max) | |
+ public function between($min, $max) | |
{ | |
return $this->greaterThanOrEqualTo($min)->lessThanOrEqualTo($max); | |
} | |
- function toParam() | |
+ public function toParam() | |
{ | |
return $this->searchTerms; | |
} | |
} | |
+class_alias('Braintree\RangeNode', 'Braintree_RangeNode'); | |
Index: braintree_sdk/lib/Braintree/ResourceCollection.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/ResourceCollection.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/ResourceCollection.php (working copy) | |
@@ -1,4 +1,8 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
+use Iterator; | |
+ | |
/** | |
* Braintree ResourceCollection | |
* ResourceCollection is a container object for result data | |
@@ -7,7 +11,7 @@ | |
* | |
* example: | |
* <code> | |
- * $result = Braintree_Customer::all(); | |
+ * $result = Customer::all(); | |
* | |
* foreach($result as $transaction) { | |
* print_r($transaction->id); | |
@@ -16,9 +20,9 @@ | |
* | |
* @package Braintree | |
* @subpackage Utility | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_ResourceCollection implements Iterator | |
+class ResourceCollection implements Iterator | |
{ | |
private $_index; | |
private $_batchIndex; | |
@@ -31,8 +35,8 @@ | |
* | |
* expects an array of attributes with literal keys | |
* | |
- * @param array $attributes | |
- * @param array $pagerAttribs | |
+ * @param array $response | |
+ * @param array $pager | |
*/ | |
public function __construct($response, $pager) | |
{ | |
@@ -57,7 +61,7 @@ | |
public function firstItem() | |
{ | |
$ids = $this->_ids; | |
- $page = $this->_getPage(array($ids[0])); | |
+ $page = $this->_getPage([$ids[0]]); | |
return $page[0]; | |
} | |
@@ -108,7 +112,7 @@ | |
{ | |
if (empty($this->_ids)) | |
{ | |
- $this->_items = array(); | |
+ $this->_items = []; | |
} | |
else | |
{ | |
@@ -121,21 +125,22 @@ | |
/** | |
* requests the next page of results for the collection | |
* | |
- * @return none | |
+ * @return void | |
*/ | |
private function _getPage($ids) | |
{ | |
$object = $this->_pager['object']; | |
$method = $this->_pager['method']; | |
- $methodArgs = array(); | |
+ $methodArgs = []; | |
foreach ($this->_pager['methodArgs'] as $arg) { | |
array_push($methodArgs, $arg); | |
} | |
array_push($methodArgs, $ids); | |
return call_user_func_array( | |
- array($object, $method), | |
+ [$object, $method], | |
$methodArgs | |
); | |
} | |
} | |
+class_alias('Braintree\ResourceCollection', 'Braintree_ResourceCollection'); | |
Index: braintree_sdk/lib/Braintree/Result/CreditCardVerification.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Result/CreditCardVerification.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Result/CreditCardVerification.php (working copy) | |
@@ -1,4 +1,9 @@ | |
<?php | |
+namespace Braintree\Result; | |
+ | |
+use Braintree\RiskData; | |
+use Braintree\Util; | |
+ | |
/** | |
* Braintree Credit Card Verification Result | |
* | |
@@ -8,7 +13,7 @@ | |
* | |
* @package Braintree | |
* @subpackage Result | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
* @property-read string $avsErrorResponseCode | |
* @property-read string $avsPostalCodeResponseCode | |
@@ -17,7 +22,7 @@ | |
* @property-read string $status | |
* | |
*/ | |
-class Braintree_Result_CreditCardVerification | |
+class CreditCardVerification | |
{ | |
// Status | |
const FAILED = 'failed'; | |
@@ -46,13 +51,13 @@ | |
* @ignore | |
* @access protected | |
* @param <type> $aAttribs array of properties to set - single level | |
- * @return none | |
+ * @return void | |
*/ | |
private function _initializeFromArray($attributes) | |
{ | |
if(isset($attributes['riskData'])) | |
{ | |
- $attributes['riskData'] = Braintree_RiskData::factory($attributes['riskData']); | |
+ $attributes['riskData'] = RiskData::factory($attributes['riskData']); | |
} | |
$this->_attributes = $attributes; | |
@@ -63,7 +68,6 @@ | |
} | |
/** | |
- * | |
* @ignore | |
*/ | |
public function __get($name) | |
@@ -79,16 +83,17 @@ | |
public function __toString() | |
{ | |
return __CLASS__ . '[' . | |
- Braintree_Util::attributesToString($this->_attributes) .']'; | |
+ Util::attributesToString($this->_attributes) . ']'; | |
} | |
public static function allStatuses() | |
{ | |
- return array( | |
- Braintree_Result_creditCardVerification::FAILED, | |
- Braintree_Result_creditCardVerification::GATEWAY_REJECTED, | |
- Braintree_Result_creditCardVerification::PROCESSOR_DECLINED, | |
- Braintree_Result_creditCardVerification::VERIFIED, | |
- ); | |
+ return [ | |
+ CreditCardVerification::FAILED, | |
+ CreditCardVerification::GATEWAY_REJECTED, | |
+ CreditCardVerification::PROCESSOR_DECLINED, | |
+ CreditCardVerification::VERIFIED | |
+ ]; | |
} | |
} | |
+class_alias('Braintree\Result\CreditCardVerification', 'Braintree_Result_CreditCardVerification'); | |
Index: braintree_sdk/lib/Braintree/Result/Error.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Result/Error.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Result/Error.php (working copy) | |
@@ -1,4 +1,13 @@ | |
<?php | |
+namespace Braintree\Result; | |
+ | |
+use Braintree\Base; | |
+use Braintree\Transaction; | |
+use Braintree\Subscription; | |
+use Braintree\MerchantAccount; | |
+use Braintree\Util; | |
+use Braintree\Error\ErrorCollection; | |
+ | |
/** | |
* Braintree Error Result | |
* | |
@@ -9,27 +18,26 @@ | |
* respond to the void request if it failed: | |
* | |
* <code> | |
- * $result = Braintree_Transaction::void('abc123'); | |
+ * $result = Transaction::void('abc123'); | |
* if ($result->success) { | |
* // Successful Result | |
* } else { | |
- * // Braintree_Result_Error | |
+ * // Result\Error | |
* } | |
* </code> | |
* | |
* @package Braintree | |
* @subpackage Result | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
* @property-read array $params original passed params | |
- * @property-read object $errors Braintree_Error_ErrorCollection | |
- * @property-read object $creditCardVerification credit card verification data | |
+ * @property-read Braintree\Error\ErrorCollection $errors | |
+ * @property-read Braintree\Result\CreditCardVerification $creditCardVerification credit card verification data | |
*/ | |
-class Braintree_Result_Error extends Braintree_Base | |
+class Error extends Base | |
{ | |
- /** | |
- * | |
- * @var boolean always false | |
+ /** | |
+ * @var bool always false | |
*/ | |
public $success = false; | |
@@ -46,10 +54,10 @@ | |
$pieces = preg_split("/[\[\]]+/", $field, 0, PREG_SPLIT_NO_EMPTY); | |
$params = $this->params; | |
foreach(array_slice($pieces, 0, -1) as $key) { | |
- $params = $params[Braintree_Util::delimiterToCamelCase($key)]; | |
+ $params = $params[Util::delimiterToCamelCase($key)]; | |
} | |
if ($key != 'custom_fields') { | |
- $finalKey = Braintree_Util::delimiterToCamelCase(end($pieces)); | |
+ $finalKey = Util::delimiterToCamelCase(end($pieces)); | |
} else { | |
$finalKey = end($pieces); | |
} | |
@@ -65,45 +73,52 @@ | |
public function __construct($response) | |
{ | |
$this->_attributes = $response; | |
- $this->_set('errors', new Braintree_Error_ErrorCollection($response['errors'])); | |
+ $this->_set('errors', new ErrorCollection($response['errors'])); | |
if(isset($response['verification'])) { | |
- $this->_set('creditCardVerification', new Braintree_Result_CreditCardVerification($response['verification'])); | |
+ $this->_set('creditCardVerification', new CreditCardVerification($response['verification'])); | |
} else { | |
$this->_set('creditCardVerification', null); | |
} | |
if(isset($response['transaction'])) { | |
- $this->_set('transaction', Braintree_Transaction::factory($response['transaction'])); | |
+ $this->_set('transaction', Transaction::factory($response['transaction'])); | |
} else { | |
$this->_set('transaction', null); | |
} | |
if(isset($response['subscription'])) { | |
- $this->_set('subscription', Braintree_Subscription::factory($response['subscription'])); | |
+ $this->_set('subscription', Subscription::factory($response['subscription'])); | |
} else { | |
$this->_set('subscription', null); | |
} | |
if(isset($response['merchantAccount'])) { | |
- $this->_set('merchantAccount', Braintree_MerchantAccount::factory($response['merchantAccount'])); | |
+ $this->_set('merchantAccount', MerchantAccount::factory($response['merchantAccount'])); | |
} else { | |
$this->_set('merchantAccount', null); | |
} | |
+ | |
+ if(isset($response['verification'])) { | |
+ $this->_set('verification', new CreditCardVerification($response['verification'])); | |
+ } else { | |
+ $this->_set('verification', null); | |
+ } | |
} | |
/** | |
* create a printable representation of the object as: | |
* ClassName[property=value, property=value] | |
* @ignore | |
- * @return var | |
+ * @return string | |
*/ | |
public function __toString() | |
{ | |
- $output = Braintree_Util::attributesToString($this->_attributes); | |
+ $output = Util::attributesToString($this->_attributes); | |
if (isset($this->_creditCardVerification)) { | |
$output .= sprintf('%s', $this->_creditCardVerification); | |
} | |
- return __CLASS__ .'['.$output.']'; | |
+ return __CLASS__ .'[' . $output . ']'; | |
} | |
} | |
+class_alias('Braintree\Result\Error', 'Braintree_Result_Error'); | |
Index: braintree_sdk/lib/Braintree/Result/Successful.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Result/Successful.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Result/Successful.php (working copy) | |
@@ -1,29 +1,34 @@ | |
<?php | |
+namespace Braintree\Result; | |
+ | |
+use Braintree\Instance; | |
+use Braintree\Util; | |
+ | |
/** | |
* Braintree Successful Result | |
* | |
* A Successful Result will be returned from gateway methods when | |
* validations pass. It will provide access to the created resource. | |
* | |
- * For example, when creating a customer, Braintree_Result_Successful will | |
+ * For example, when creating a customer, Successful will | |
* respond to <b>customer</b> like so: | |
* | |
* <code> | |
- * $result = Braintree_Customer::create(array('first_name' => "John")); | |
+ * $result = Customer::create(array('first_name' => "John")); | |
* if ($result->success) { | |
- * // Braintree_Result_Successful | |
+ * // Successful | |
* echo "Created customer {$result->customer->id}"; | |
* } else { | |
- * // Braintree_Result_Error | |
+ * // Error | |
* } | |
* </code> | |
* | |
* | |
* @package Braintree | |
* @subpackage Result | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_Result_Successful extends Braintree_Instance | |
+class Successful extends Instance | |
{ | |
/** | |
* | |
@@ -38,17 +43,18 @@ | |
/** | |
* @ignore | |
- * @param string $classToReturn name of class to instantiate | |
+ * @param array|null $objsToReturn | |
+ * @param array|null $propertyNames | |
*/ | |
- public function __construct($objsToReturn = array(), $propertyNames = array()) | |
+ public function __construct($objsToReturn = [], $propertyNames = []) | |
{ | |
// Sanitize arguments (preserves backwards compatibility) | |
- if (!is_array($objsToReturn)) { $objsToReturn = array($objsToReturn); } | |
- if (!is_array($propertyNames)) { $propertyNames = array($propertyNames); } | |
+ if (!is_array($objsToReturn)) { $objsToReturn = [$objsToReturn]; } | |
+ if (!is_array($propertyNames)) { $propertyNames = [$propertyNames]; } | |
$objects = $this->_mapPropertyNamesToObjsToReturn($propertyNames, $objsToReturn); | |
- $this->_attributes = array(); | |
- $this->_returnObjectNames = array(); | |
+ $this->_attributes = []; | |
+ $this->_returnObjectNames = []; | |
foreach ($objects as $propertyName => $objToReturn) { | |
@@ -67,7 +73,7 @@ | |
*/ | |
public function __toString() | |
{ | |
- $objects = array(); | |
+ $objects = []; | |
foreach ($this->_returnObjectNames as $returnObjectName) { | |
array_push($objects, $this->$returnObjectName); | |
} | |
@@ -76,11 +82,12 @@ | |
private function _mapPropertyNamesToObjsToReturn($propertyNames, $objsToReturn) { | |
if(count($objsToReturn) != count($propertyNames)) { | |
- $propertyNames = array(); | |
+ $propertyNames = []; | |
foreach ($objsToReturn as $obj) { | |
- array_push($propertyNames, Braintree_Util::cleanClassName(get_class($obj))); | |
+ array_push($propertyNames, Util::cleanClassName(get_class($obj))); | |
} | |
} | |
return array_combine($propertyNames, $objsToReturn); | |
} | |
} | |
+class_alias('Braintree\Result\Successful', 'Braintree_Result_Successful'); | |
Index: braintree_sdk/lib/Braintree/RiskData.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/RiskData.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/RiskData.php (working copy) | |
@@ -1,5 +1,7 @@ | |
<?php | |
-class Braintree_RiskData extends Braintree_Base | |
+namespace Braintree; | |
+ | |
+class RiskData extends Base | |
{ | |
public static function factory($attributes) | |
{ | |
@@ -18,10 +20,11 @@ | |
* returns a string representation of the risk data | |
* @return string | |
*/ | |
- public function __toString() | |
+ public function __toString() | |
{ | |
return __CLASS__ . '[' . | |
- Braintree_Util::attributesToString($this->_attributes) .']'; | |
+ Util::attributesToString($this->_attributes) .']'; | |
} | |
} | |
+class_alias('Braintree\RiskData', 'Braintree_RiskData'); | |
Index: braintree_sdk/lib/Braintree/SettlementBatchSummary.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/SettlementBatchSummary.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/SettlementBatchSummary.php (working copy) | |
@@ -1,10 +1,12 @@ | |
<?php | |
-class Braintree_SettlementBatchSummary extends Braintree_Base | |
+namespace Braintree; | |
+ | |
+class SettlementBatchSummary extends Base | |
{ | |
/** | |
- * | |
+ * | |
* @param array $attributes | |
- * @return Braintree_SettlementBatchSummary | |
+ * @return SettlementBatchSummary | |
*/ | |
public static function factory($attributes) | |
{ | |
@@ -30,13 +32,14 @@ | |
/** | |
* static method redirecting to gateway | |
- * | |
+ * | |
* @param string $settlement_date Date YYYY-MM-DD | |
* @param string $groupByCustomField | |
- * @return Braintree_Result_Successful|Braintree_Result_Error | |
+ * @return Result\Successful|Result\Error | |
*/ | |
public static function generate($settlement_date, $groupByCustomField = NULL) | |
{ | |
- return Braintree_Configuration::gateway()->settlementBatchSummary()->generate($settlement_date, $groupByCustomField); | |
+ return Configuration::gateway()->settlementBatchSummary()->generate($settlement_date, $groupByCustomField); | |
} | |
} | |
+class_alias('Braintree\SettlementBatchSummary', 'Braintree_SettlementBatchSummary'); | |
Index: braintree_sdk/lib/Braintree/SettlementBatchSummaryGateway.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/SettlementBatchSummaryGateway.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/SettlementBatchSummaryGateway.php (working copy) | |
@@ -1,51 +1,52 @@ | |
<?php | |
+namespace Braintree; | |
-class Braintree_SettlementBatchSummaryGateway | |
+class SettlementBatchSummaryGateway | |
{ | |
/** | |
* | |
- * @var Braintree_Gateway | |
+ * @var Gateway | |
*/ | |
private $_gateway; | |
- | |
+ | |
/** | |
* | |
- * @var Braintree_Configuration | |
+ * @var Configuration | |
*/ | |
private $_config; | |
- | |
+ | |
/** | |
* | |
- * @var Braintree_Http | |
+ * @var Http | |
*/ | |
private $_http; | |
/** | |
- * | |
- * @param Braintree_Gateway $gateway | |
+ * | |
+ * @param Gateway $gateway | |
*/ | |
public function __construct($gateway) | |
{ | |
$this->_gateway = $gateway; | |
$this->_config = $gateway->config; | |
$this->_config->assertHasAccessTokenOrKeys(); | |
- $this->_http = new Braintree_Http($gateway->config); | |
+ $this->_http = new Http($gateway->config); | |
} | |
/** | |
- * | |
+ * | |
* @param string $settlement_date | |
* @param string $groupByCustomField | |
- * @return Braintree_SettlementBatchSummary|Braintree_Result_Error | |
+ * @return SettlementBatchSummary|Result\Error | |
*/ | |
public function generate($settlement_date, $groupByCustomField = NULL) | |
{ | |
- $criteria = array('settlement_date' => $settlement_date); | |
+ $criteria = ['settlement_date' => $settlement_date]; | |
if (isset($groupByCustomField)) | |
{ | |
$criteria['group_by_custom_field'] = $groupByCustomField; | |
} | |
- $params = array('settlement_batch_summary' => $criteria); | |
+ $params = ['settlement_batch_summary' => $criteria]; | |
$path = $this->_config->merchantPath() . '/settlement_batch_summary'; | |
$response = $this->_http->post($path, $params); | |
@@ -61,18 +62,18 @@ | |
} | |
/** | |
- * | |
+ * | |
* @param string $groupByCustomField | |
* @param array $records | |
- * @return array | |
+ * @return array | |
*/ | |
private function _underscoreCustomField($groupByCustomField, $records) | |
{ | |
- $updatedRecords = array(); | |
+ $updatedRecords = []; | |
foreach ($records as $record) | |
{ | |
- $camelized = Braintree_Util::delimiterToCamelCase($groupByCustomField); | |
+ $camelized = Util::delimiterToCamelCase($groupByCustomField); | |
$record[$groupByCustomField] = $record[$camelized]; | |
unset($record[$camelized]); | |
$updatedRecords[] = $record; | |
@@ -82,23 +83,24 @@ | |
} | |
/** | |
- * | |
+ * | |
* @param array $response | |
- * @return \Braintree_Result_Successful|\Braintree_Result_Error | |
- * @throws Braintree_Exception_Unexpected | |
+ * @return Result\Successful|Result\Error | |
+ * @throws Exception\Unexpected | |
*/ | |
private function _verifyGatewayResponse($response) | |
{ | |
if (isset($response['settlementBatchSummary'])) { | |
- return new Braintree_Result_Successful( | |
- Braintree_SettlementBatchSummary::factory($response['settlementBatchSummary']) | |
+ return new Result\Successful( | |
+ SettlementBatchSummary::factory($response['settlementBatchSummary']) | |
); | |
} else if (isset($response['apiErrorResponse'])) { | |
- return new Braintree_Result_Error($response['apiErrorResponse']); | |
+ return new Result\Error($response['apiErrorResponse']); | |
} else { | |
- throw new Braintree_Exception_Unexpected( | |
+ throw new Exception\Unexpected( | |
"Expected settlementBatchSummary or apiErrorResponse" | |
); | |
} | |
} | |
} | |
+class_alias('Braintree\SettlementBatchSummaryGateway', 'Braintree_SettlementBatchSummaryGateway'); | |
Index: braintree_sdk/lib/Braintree/SignatureService.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/SignatureService.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/SignatureService.php (working copy) | |
@@ -1,6 +1,7 @@ | |
<?php | |
+namespace Braintree; | |
-class Braintree_SignatureService | |
+class SignatureService | |
{ | |
public function __construct($key, $digest) | |
@@ -20,3 +21,4 @@ | |
} | |
} | |
+class_alias('Braintree\SignatureService', 'Braintree_SignatureService'); | |
Index: braintree_sdk/lib/Braintree/Subscription/StatusDetails.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Subscription/StatusDetails.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Subscription/StatusDetails.php (working copy) | |
@@ -1,10 +1,14 @@ | |
<?php | |
+namespace Braintree\Subscription; | |
+ | |
+use Braintree\Instance; | |
+ | |
/** | |
* Status details from a subscription | |
* Creates an instance of StatusDetails, as part of a subscription response | |
* | |
* @package Braintree | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
* @property-read string $price | |
* @property-read string $balance | |
@@ -12,8 +16,8 @@ | |
* @property-read string $timestamp | |
* @property-read string $subscriptionSource | |
* @property-read string $user | |
- * @uses Braintree_Instance inherits methods | |
*/ | |
-class Braintree_Subscription_StatusDetails extends Braintree_Instance | |
+class StatusDetails extends Instance | |
{ | |
} | |
+class_alias('Braintree\Subscription\StatusDetails', 'Braintree_Subscription_StatusDetails'); | |
Index: braintree_sdk/lib/Braintree/Subscription.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Subscription.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Subscription.php (working copy) | |
@@ -1,4 +1,6 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
/** | |
* Braintree Subscription module | |
* | |
@@ -9,9 +11,9 @@ | |
* PHP Version 5 | |
* | |
* @package Braintree | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_Subscription extends Braintree_Base | |
+class Subscription extends Base | |
{ | |
const ACTIVE = 'Active'; | |
const CANCELED = 'Canceled'; | |
@@ -42,38 +44,38 @@ | |
{ | |
$this->_attributes = $attributes; | |
- $addOnArray = array(); | |
+ $addOnArray = []; | |
if (isset($attributes['addOns'])) { | |
foreach ($attributes['addOns'] AS $addOn) { | |
- $addOnArray[] = Braintree_AddOn::factory($addOn); | |
+ $addOnArray[] = AddOn::factory($addOn); | |
} | |
} | |
$this->_attributes['addOns'] = $addOnArray; | |
- $discountArray = array(); | |
+ $discountArray = []; | |
if (isset($attributes['discounts'])) { | |
foreach ($attributes['discounts'] AS $discount) { | |
- $discountArray[] = Braintree_Discount::factory($discount); | |
+ $discountArray[] = Discount::factory($discount); | |
} | |
} | |
$this->_attributes['discounts'] = $discountArray; | |
if (isset($attributes['descriptor'])) { | |
- $this->_set('descriptor', new Braintree_Descriptor($attributes['descriptor'])); | |
+ $this->_set('descriptor', new Descriptor($attributes['descriptor'])); | |
} | |
- $statusHistory = array(); | |
+ $statusHistory = []; | |
if (isset($attributes['statusHistory'])) { | |
foreach ($attributes['statusHistory'] AS $history) { | |
- $statusHistory[] = new Braintree_Subscription_StatusDetails($history); | |
+ $statusHistory[] = new Subscription\StatusDetails($history); | |
} | |
} | |
$this->_attributes['statusHistory'] = $statusHistory; | |
- $transactionArray = array(); | |
+ $transactionArray = []; | |
if (isset($attributes['transactions'])) { | |
foreach ($attributes['transactions'] AS $transaction) { | |
- $transactionArray[] = Braintree_Transaction::factory($transaction); | |
+ $transactionArray[] = Transaction::factory($transaction); | |
} | |
} | |
$this->_attributes['transactions'] = $transactionArray; | |
@@ -85,9 +87,9 @@ | |
*/ | |
public function __toString() | |
{ | |
- $excludedAttributes = array('statusHistory'); | |
+ $excludedAttributes = ['statusHistory']; | |
- $displayAttributes = array(); | |
+ $displayAttributes = []; | |
foreach($this->_attributes as $key => $val) { | |
if (!in_array($key, $excludedAttributes)) { | |
$displayAttributes[$key] = $val; | |
@@ -95,7 +97,7 @@ | |
} | |
return __CLASS__ . '[' . | |
- Braintree_Util::attributesToString($displayAttributes) .']'; | |
+ Util::attributesToString($displayAttributes) .']'; | |
} | |
@@ -103,36 +105,37 @@ | |
public static function create($attributes) | |
{ | |
- return Braintree_Configuration::gateway()->subscription()->create($attributes); | |
+ return Configuration::gateway()->subscription()->create($attributes); | |
} | |
public static function find($id) | |
{ | |
- return Braintree_Configuration::gateway()->subscription()->find($id); | |
+ return Configuration::gateway()->subscription()->find($id); | |
} | |
public static function search($query) | |
{ | |
- return Braintree_Configuration::gateway()->subscription()->search($query); | |
+ return Configuration::gateway()->subscription()->search($query); | |
} | |
public static function fetch($query, $ids) | |
{ | |
- return Braintree_Configuration::gateway()->subscription()->fetch($query, $ids); | |
+ return Configuration::gateway()->subscription()->fetch($query, $ids); | |
} | |
public static function update($subscriptionId, $attributes) | |
{ | |
- return Braintree_Configuration::gateway()->subscription()->update($subscriptionId, $attributes); | |
+ return Configuration::gateway()->subscription()->update($subscriptionId, $attributes); | |
} | |
public static function retryCharge($subscriptionId, $amount = null) | |
{ | |
- return Braintree_Configuration::gateway()->subscription()->retryCharge($subscriptionId, $amount); | |
+ return Configuration::gateway()->subscription()->retryCharge($subscriptionId, $amount); | |
} | |
public static function cancel($subscriptionId) | |
{ | |
- return Braintree_Configuration::gateway()->subscription()->cancel($subscriptionId); | |
+ return Configuration::gateway()->subscription()->cancel($subscriptionId); | |
} | |
} | |
+class_alias('Braintree\Subscription', 'Braintree_Subscription'); | |
Index: braintree_sdk/lib/Braintree/SubscriptionGateway.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/SubscriptionGateway.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/SubscriptionGateway.php (working copy) | |
@@ -1,4 +1,8 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
+use InvalidArgumentException; | |
+ | |
/** | |
* Braintree SubscriptionGateway module | |
* | |
@@ -9,9 +13,9 @@ | |
* PHP Version 5 | |
* | |
* @package Braintree | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_SubscriptionGateway | |
+class SubscriptionGateway | |
{ | |
private $_gateway; | |
private $_config; | |
@@ -22,14 +26,14 @@ | |
$this->_gateway = $gateway; | |
$this->_config = $gateway->config; | |
$this->_config->assertHasAccessTokenOrKeys(); | |
- $this->_http = new Braintree_Http($gateway->config); | |
+ $this->_http = new Http($gateway->config); | |
} | |
public function create($attributes) | |
{ | |
- Braintree_Util::verifyKeys(self::_createSignature(), $attributes); | |
+ Util::verifyKeys(self::_createSignature(), $attributes); | |
$path = $this->_config->merchantPath() . '/subscriptions'; | |
- $response = $this->_http->post($path, array('subscription' => $attributes)); | |
+ $response = $this->_http->post($path, ['subscription' => $attributes]); | |
return $this->_verifyGatewayResponse($response); | |
} | |
@@ -40,43 +44,43 @@ | |
try { | |
$path = $this->_config->merchantPath() . '/subscriptions/' . $id; | |
$response = $this->_http->get($path); | |
- return Braintree_Subscription::factory($response['subscription']); | |
- } catch (Braintree_Exception_NotFound $e) { | |
- throw new Braintree_Exception_NotFound('subscription with id ' . $id . ' not found'); | |
+ return Subscription::factory($response['subscription']); | |
+ } catch (Exception\NotFound $e) { | |
+ throw new Exception\NotFound('subscription with id ' . $id . ' not found'); | |
} | |
} | |
public function search($query) | |
{ | |
- $criteria = array(); | |
+ $criteria = []; | |
foreach ($query as $term) { | |
$criteria[$term->name] = $term->toparam(); | |
} | |
$path = $this->_config->merchantPath() . '/subscriptions/advanced_search_ids'; | |
- $response = $this->_http->post($path, array('search' => $criteria)); | |
- $pager = array( | |
+ $response = $this->_http->post($path, ['search' => $criteria]); | |
+ $pager = [ | |
'object' => $this, | |
'method' => 'fetch', | |
- 'methodArgs' => array($query) | |
- ); | |
+ 'methodArgs' => [$query] | |
+ ]; | |
- return new Braintree_ResourceCollection($response, $pager); | |
+ return new ResourceCollection($response, $pager); | |
} | |
public function fetch($query, $ids) | |
{ | |
- $criteria = array(); | |
+ $criteria = []; | |
foreach ($query as $term) { | |
$criteria[$term->name] = $term->toparam(); | |
} | |
- $criteria["ids"] = Braintree_SubscriptionSearch::ids()->in($ids)->toparam(); | |
+ $criteria["ids"] = SubscriptionSearch::ids()->in($ids)->toparam(); | |
$path = $this->_config->merchantPath() . '/subscriptions/advanced_search'; | |
- $response = $this->_http->post($path, array('search' => $criteria)); | |
+ $response = $this->_http->post($path, ['search' => $criteria]); | |
- return Braintree_Util::extractAttributeAsArray( | |
+ return Util::extractAttributeAsArray( | |
$response['subscriptions'], | |
'subscription' | |
); | |
@@ -84,22 +88,22 @@ | |
public function update($subscriptionId, $attributes) | |
{ | |
- Braintree_Util::verifyKeys(self::_updateSignature(), $attributes); | |
+ Util::verifyKeys(self::_updateSignature(), $attributes); | |
$path = $this->_config->merchantPath() . '/subscriptions/' . $subscriptionId; | |
- $response = $this->_http->put($path, array('subscription' => $attributes)); | |
+ $response = $this->_http->put($path, ['subscription' => $attributes]); | |
return $this->_verifyGatewayResponse($response); | |
} | |
public function retryCharge($subscriptionId, $amount = null) | |
{ | |
- $transaction_params = array('type' => Braintree_Transaction::SALE, | |
- 'subscriptionId' => $subscriptionId); | |
+ $transaction_params = ['type' => Transaction::SALE, | |
+ 'subscriptionId' => $subscriptionId]; | |
if (isset($amount)) { | |
$transaction_params['amount'] = $amount; | |
} | |
$path = $this->_config->merchantPath() . '/transactions'; | |
- $response = $this->_http->post($path, array('transaction' => $transaction_params)); | |
+ $response = $this->_http->post($path, ['transaction' => $transaction_params]); | |
return $this->_verifyGatewayResponse($response); | |
} | |
@@ -113,7 +117,7 @@ | |
private static function _createSignature() | |
{ | |
return array_merge( | |
- array( | |
+ [ | |
'billingDayOfMonth', | |
'firstBillingDate', | |
'createdAt', | |
@@ -129,9 +133,9 @@ | |
'trialDuration', | |
'trialDurationUnit', | |
'trialPeriod', | |
- array('descriptor' => array('name', 'phone', 'url')), | |
- array('options' => array('doNotInheritAddOnsOrDiscounts', 'startImmediately')), | |
- ), | |
+ ['descriptor' => ['name', 'phone', 'url']], | |
+ ['options' => ['doNotInheritAddOnsOrDiscounts', 'startImmediately']], | |
+ ], | |
self::_addOnDiscountSignature() | |
); | |
} | |
@@ -139,34 +143,34 @@ | |
private static function _updateSignature() | |
{ | |
return array_merge( | |
- array( | |
+ [ | |
'merchantAccountId', 'numberOfBillingCycles', 'paymentMethodToken', 'planId', | |
'paymentMethodNonce', 'id', 'neverExpires', 'price', | |
- array('descriptor' => array('name', 'phone', 'url')), | |
- array('options' => array('prorateCharges', 'replaceAllAddOnsAndDiscounts', 'revertSubscriptionOnProrationFailure')), | |
- ), | |
+ ['descriptor' => ['name', 'phone', 'url']], | |
+ ['options' => ['prorateCharges', 'replaceAllAddOnsAndDiscounts', 'revertSubscriptionOnProrationFailure']], | |
+ ], | |
self::_addOnDiscountSignature() | |
); | |
} | |
private static function _addOnDiscountSignature() | |
{ | |
- return array( | |
- array( | |
- 'addOns' => array( | |
- array('add' => array('amount', 'inheritedFromId', 'neverExpires', 'numberOfBillingCycles', 'quantity')), | |
- array('update' => array('amount', 'existingId', 'neverExpires', 'numberOfBillingCycles', 'quantity')), | |
- array('remove' => array('_anyKey_')), | |
- ) | |
- ), | |
- array( | |
- 'discounts' => array( | |
- array('add' => array('amount', 'inheritedFromId', 'neverExpires', 'numberOfBillingCycles', 'quantity')), | |
- array('update' => array('amount', 'existingId', 'neverExpires', 'numberOfBillingCycles', 'quantity')), | |
- array('remove' => array('_anyKey_')), | |
- ) | |
- ) | |
- ); | |
+ return [ | |
+ [ | |
+ 'addOns' => [ | |
+ ['add' => ['amount', 'inheritedFromId', 'neverExpires', 'numberOfBillingCycles', 'quantity']], | |
+ ['update' => ['amount', 'existingId', 'neverExpires', 'numberOfBillingCycles', 'quantity']], | |
+ ['remove' => ['_anyKey_']], | |
+ ] | |
+ ], | |
+ [ | |
+ 'discounts' => [ | |
+ ['add' => ['amount', 'inheritedFromId', 'neverExpires', 'numberOfBillingCycles', 'quantity']], | |
+ ['update' => ['amount', 'existingId', 'neverExpires', 'numberOfBillingCycles', 'quantity']], | |
+ ['remove' => ['_anyKey_']], | |
+ ] | |
+ ] | |
+ ]; | |
} | |
/** | |
@@ -191,20 +195,21 @@ | |
private function _verifyGatewayResponse($response) | |
{ | |
if (isset($response['subscription'])) { | |
- return new Braintree_Result_Successful( | |
- Braintree_Subscription::factory($response['subscription']) | |
+ return new Result\Successful( | |
+ Subscription::factory($response['subscription']) | |
); | |
} else if (isset($response['transaction'])) { | |
- // return a populated instance of Braintree_Transaction, for subscription retryCharge | |
- return new Braintree_Result_Successful( | |
- Braintree_Transaction::factory($response['transaction']) | |
+ // return a populated instance of Transaction, for subscription retryCharge | |
+ return new Result\Successful( | |
+ Transaction::factory($response['transaction']) | |
); | |
} else if (isset($response['apiErrorResponse'])) { | |
- return new Braintree_Result_Error($response['apiErrorResponse']); | |
+ return new Result\Error($response['apiErrorResponse']); | |
} else { | |
- throw new Braintree_Exception_Unexpected( | |
+ throw new Exception\Unexpected( | |
"Expected subscription, transaction, or apiErrorResponse" | |
); | |
} | |
} | |
} | |
+class_alias('Braintree\SubscriptionGateway', 'Braintree_SubscriptionGateway'); | |
Index: braintree_sdk/lib/Braintree/SubscriptionSearch.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/SubscriptionSearch.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/SubscriptionSearch.php (working copy) | |
@@ -1,64 +1,67 @@ | |
<?php | |
-class Braintree_SubscriptionSearch | |
+namespace Braintree; | |
+ | |
+class SubscriptionSearch | |
{ | |
- static function billingCyclesRemaining() | |
+ public static function billingCyclesRemaining() | |
{ | |
- return new Braintree_RangeNode('billing_cycles_remaining'); | |
+ return new RangeNode('billing_cycles_remaining'); | |
} | |
- static function daysPastDue() | |
+ public static function daysPastDue() | |
{ | |
- return new Braintree_RangeNode('days_past_due'); | |
+ return new RangeNode('days_past_due'); | |
} | |
- static function id() | |
+ public static function id() | |
{ | |
- return new Braintree_TextNode('id'); | |
+ return new TextNode('id'); | |
} | |
- static function inTrialPeriod() | |
+ public static function inTrialPeriod() | |
{ | |
- return new Braintree_MultipleValueNode('in_trial_period', array(true, false)); | |
+ return new MultipleValueNode('in_trial_period', [true, false]); | |
} | |
- static function merchantAccountId() | |
+ public static function merchantAccountId() | |
{ | |
- return new Braintree_MultipleValueNode('merchant_account_id'); | |
+ return new MultipleValueNode('merchant_account_id'); | |
} | |
- static function nextBillingDate() | |
+ public static function nextBillingDate() | |
{ | |
- return new Braintree_RangeNode('next_billing_date'); | |
+ return new RangeNode('next_billing_date'); | |
} | |
- static function planId() | |
+ public static function planId() | |
{ | |
- return new Braintree_MultipleValueOrTextNode('plan_id'); | |
+ return new MultipleValueOrTextNode('plan_id'); | |
} | |
- static function price() | |
+ public static function price() | |
{ | |
- return new Braintree_RangeNode('price'); | |
+ return new RangeNode('price'); | |
} | |
- static function status() | |
+ public static function status() | |
{ | |
- return new Braintree_MultipleValueNode("status", array( | |
- Braintree_Subscription::ACTIVE, | |
- Braintree_Subscription::CANCELED, | |
- Braintree_Subscription::EXPIRED, | |
- Braintree_Subscription::PAST_DUE, | |
- Braintree_Subscription::PENDING | |
- )); | |
+ return new MultipleValueNode('status', [ | |
+ Subscription::ACTIVE, | |
+ Subscription::CANCELED, | |
+ Subscription::EXPIRED, | |
+ Subscription::PAST_DUE, | |
+ Subscription::PENDING, | |
+ ]); | |
} | |
- static function transactionId() | |
+ public static function transactionId() | |
{ | |
- return new Braintree_TextNode('transaction_id'); | |
+ return new TextNode('transaction_id'); | |
} | |
- static function ids() | |
+ public static function ids() | |
{ | |
- return new Braintree_MultipleValueNode('ids'); | |
+ return new MultipleValueNode('ids'); | |
} | |
} | |
+class_alias('Braintree\SubscriptionSearch', 'Braintree_SubscriptionSearch'); | |
Index: braintree_sdk/lib/Braintree/Test/CreditCardNumbers.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Test/CreditCardNumbers.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Test/CreditCardNumbers.php (working copy) | |
@@ -1,61 +1,67 @@ | |
<?php | |
+namespace Braintree\Test; | |
/** | |
* Credit card information used for testing purposes | |
* | |
- * The constants contained in the Braintree_Test_CreditCardNumbers class provide | |
+ * The constants contained in the Test\CreditCardNumbers class provide | |
* credit card numbers that should be used when working in the sandbox environment. | |
* The sandbox will not accept any credit card numbers other than the ones listed below. | |
* | |
* @package Braintree | |
* @subpackage Test | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_Test_CreditCardNumbers | |
+class CreditCardNumbers | |
{ | |
- public static $amExes = array( | |
+ public static $amExes = [ | |
'378282246310005', | |
'371449635398431', | |
'378734493671000', | |
- ); | |
- public static $carteBlanches = array('30569309025904',); | |
- public static $dinersClubs = array('38520000023237',); | |
- public static $discoverCards = array( | |
+ ]; | |
+ public static $carteBlanches = ['30569309025904',]; | |
+ public static $dinersClubs = ['38520000023237',]; | |
+ public static $discoverCards = [ | |
'6011111111111117', | |
'6011000990139424', | |
- ); | |
- public static $JCBs = array( | |
+ ]; | |
+ public static $JCBs = [ | |
'3530111333300000', | |
'3566002020360505', | |
- ); | |
+ ]; | |
public static $masterCard = '5555555555554444'; | |
public static $masterCardInternational = '5105105105105100'; | |
- public static $masterCards = array( | |
+ public static $masterCards = [ | |
'5105105105105100', | |
'5555555555554444', | |
- ); | |
+ ]; | |
public static $visa = '4012888888881881'; | |
public static $visaInternational = '4009348888881881'; | |
- public static $visas = array( | |
+ public static $visas = [ | |
'4009348888881881', | |
'4012888888881881', | |
'4111111111111111', | |
'4000111111111115', | |
- ); | |
+ ]; | |
- public static $unknowns = array( | |
+ public static $unknowns = [ | |
'1000000000000008', | |
- ); | |
+ ]; | |
- public static $failsSandboxVerification = array( | |
+ public static $failsSandboxVerification = [ | |
'AmEx' => '378734493671000', | |
'Discover' => '6011000990139424', | |
'MasterCard' => '5105105105105100', | |
'Visa' => '4000111111111115', | |
- ); | |
+ ]; | |
+ public static $amexPayWithPoints = [ | |
+ 'Success' => "371260714673002", | |
+ 'IneligibleCard' => "378267515471109", | |
+ 'InsufficientPoints' => "371544868764018", | |
+ ]; | |
public static function getAll() | |
{ | |
@@ -67,3 +73,4 @@ | |
); | |
} | |
} | |
+class_alias('Braintree\Test\CreditCardNumbers', 'Braintree_Test_CreditCardNumbers'); | |
Index: braintree_sdk/lib/Braintree/Test/MerchantAccount.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Test/MerchantAccount.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Test/MerchantAccount.php (working copy) | |
@@ -1,12 +1,14 @@ | |
<?php | |
+namespace Braintree\Test; | |
+ | |
/** | |
* Merchant Account constants used for testing purposes | |
* | |
* @package Braintree | |
* @subpackage Test | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_Test_MerchantAccount | |
+class MerchantAccount | |
{ | |
public static $approve = "approve_me"; | |
@@ -17,3 +19,4 @@ | |
} | |
+class_alias('Braintree\Test\MerchantAccount', 'Braintree_Test_MerchantAccount'); | |
Index: braintree_sdk/lib/Braintree/Test/Nonces.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Test/Nonces.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Test/Nonces.php (working copy) | |
@@ -1,10 +1,12 @@ | |
<?php | |
+namespace Braintree\Test; | |
+ | |
/** | |
* Nonces used for testing purposes | |
* | |
* @package Braintree | |
* @subpackage Test | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
/** | |
@@ -15,9 +17,9 @@ | |
* | |
* @package Braintree | |
* @subpackage Test | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_Test_Nonces | |
+class Nonces | |
{ | |
public static $transactable = "fake-valid-nonce"; | |
public static $consumed = "fake-consumed-nonce"; | |
@@ -32,6 +34,7 @@ | |
public static $androidPayVisa = "fake-android-pay-visa-nonce"; | |
public static $androidPayMasterCard = "fake-android-pay-mastercard-nonce"; | |
public static $androidPayAmEx = "fake-android-pay-amex-nonce"; | |
+ public static $amexExpressCheckout = "fake-amex-express-checkout-nonce"; | |
public static $abstractTransactable = "fake-abstract-transactable-nonce"; | |
public static $europe = "fake-europe-bank-account-nonce"; | |
public static $coinbase = "fake-coinbase-nonce"; | |
@@ -62,4 +65,6 @@ | |
public static $paypalFuturePaymentRefreshToken = "fake-paypal-future-refresh-token-nonce"; | |
public static $sepa = "fake-sepa-bank-account-nonce"; | |
public static $gatewayRejectedFraud = "fake-gateway-rejected-fraud-nonce"; | |
+ public static $venmoAccount = "fake-venmo-account-nonce"; | |
} | |
+class_alias('Braintree\Test\Nonces', 'Braintree_Test_Nonces'); | |
Index: braintree_sdk/lib/Braintree/Test/Transaction.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Test/Transaction.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Test/Transaction.php (working copy) | |
@@ -1,51 +1,64 @@ | |
<?php | |
-final class Braintree_Test_Transaction | |
+namespace Braintree\Test; | |
+ | |
+use Braintree\Configuration; | |
+ | |
+/** | |
+ * Transaction amounts used for testing purposes | |
+ * | |
+ * The constants in this class can be used to create transactions with | |
+ * the desired status in the sandbox environment. | |
+ * | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
+ */ | |
+final class Transaction | |
{ | |
/** | |
* settle a transaction by id in sandbox | |
* | |
* @param string $id transaction id | |
- * @param Braintree_Configuration $config gateway config | |
- * @return object Braintree_Transaction | |
+ * @param Configuration $config gateway config | |
+ * @return Transaction | |
*/ | |
public static function settle($transactionId) | |
{ | |
- return Braintree_Configuration::gateway()->testing()->settle($transactionId); | |
+ return Configuration::gateway()->testing()->settle($transactionId); | |
} | |
/** | |
* settlement confirm a transaction by id in sandbox | |
* | |
* @param string $id transaction id | |
- * @param Braintree_Configuration $config gateway config | |
- * @return object Braintree_Transaction | |
+ * @param Configuration $config gateway config | |
+ * @return Transaction | |
*/ | |
public static function settlementConfirm($transactionId) | |
{ | |
- return Braintree_Configuration::gateway()->testing()->settlementConfirm($transactionId); | |
+ return Configuration::gateway()->testing()->settlementConfirm($transactionId); | |
} | |
/** | |
* settlement decline a transaction by id in sandbox | |
* | |
* @param string $id transaction id | |
- * @param Braintree_Configuration $config gateway config | |
- * @return object Braintree_Transaction | |
+ * @param Configuration $config gateway config | |
+ * @return Transaction | |
*/ | |
public static function settlementDecline($transactionId) | |
{ | |
- return Braintree_Configuration::gateway()->testing()->settlementDecline($transactionId); | |
+ return Configuration::gateway()->testing()->settlementDecline($transactionId); | |
} | |
/** | |
* settlement pending a transaction by id in sandbox | |
* | |
* @param string $id transaction id | |
- * @param Braintree_Configuration $config gateway config | |
- * @return object Braintree_Transaction | |
+ * @param Configuration $config gateway config | |
+ * @return Transaction | |
*/ | |
public static function settlementPending($transactionId) | |
{ | |
- return Braintree_Configuration::gateway()->testing()->settlementPending($transactionId); | |
+ return Configuration::gateway()->testing()->settlementPending($transactionId); | |
} | |
} | |
+class_alias('Braintree\Test\Transaction', 'Braintree_Test_Transaction'); | |
Index: braintree_sdk/lib/Braintree/Test/TransactionAmounts.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Test/TransactionAmounts.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Test/TransactionAmounts.php (working copy) | |
@@ -1,4 +1,5 @@ | |
<?php | |
+namespace Braintree\Test; | |
/** | |
* Transaction amounts used for testing purposes | |
@@ -8,10 +9,11 @@ | |
* | |
* @package Braintree | |
* @subpackage Test | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_Test_TransactionAmounts | |
+class TransactionAmounts | |
{ | |
public static $authorize = '1000.00'; | |
public static $decline = '2000.00'; | |
} | |
+class_alias('Braintree\Test\TransactionAmounts', 'Braintree_Test_TransactionAmounts'); | |
Index: braintree_sdk/lib/Braintree/Test/VenmoSdk.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Test/VenmoSdk.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Test/VenmoSdk.php (working copy) | |
@@ -1,12 +1,14 @@ | |
<?php | |
+namespace Braintree\Test; | |
+ | |
/** | |
* VenmoSdk payment method codes used for testing purposes | |
* | |
* @package Braintree | |
* @subpackage Test | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_Test_VenmoSdk | |
+class VenmoSdk | |
{ | |
public static $visaPaymentMethodCode = "stub-4111111111111111"; | |
@@ -26,3 +28,4 @@ | |
return "stub-invalid-session"; | |
} | |
} | |
+class_alias('Braintree\Test\VenmoSdk', 'Braintree_Test_VenmoSdk'); | |
Index: braintree_sdk/lib/Braintree/TestingGateway.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/TestingGateway.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/TestingGateway.php (working copy) | |
@@ -1,5 +1,7 @@ | |
<?php | |
-final class Braintree_TestingGateway | |
+namespace Braintree; | |
+ | |
+final class TestingGateway | |
{ | |
private $_gateway; | |
private $_config; | |
@@ -9,7 +11,7 @@ | |
{ | |
$this->_gateway = $gateway; | |
$this->_config = $gateway->config; | |
- $this->_http = new Braintree_Http($this->_config); | |
+ $this->_http = new Http($this->_config); | |
} | |
public function settle($transactionId) | |
@@ -37,13 +39,14 @@ | |
self::_checkEnvironment(); | |
$path = $this->_config->merchantPath() . '/transactions/' . $transactionId . $testPath; | |
$response = $this->_http->put($path); | |
- return Braintree_Transaction::factory($response['transaction']); | |
+ return Transaction::factory($response['transaction']); | |
} | |
private function _checkEnvironment() | |
{ | |
- if (Braintree_Configuration::$global->getEnvironment() == 'production') { | |
- throw new Braintree_Exception_TestOperationPerformedInProduction(); | |
+ if (Configuration::$global->getEnvironment() === 'production') { | |
+ throw new Exception\TestOperationPerformedInProduction(); | |
} | |
} | |
} | |
+class_alias('Braintree\TestingGateway', 'Braintree_TestingGateway'); | |
Index: braintree_sdk/lib/Braintree/TextNode.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/TextNode.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/TextNode.php (working copy) | |
@@ -1,10 +1,12 @@ | |
<?php | |
+namespace Braintree; | |
-class Braintree_TextNode extends Braintree_PartialMatchNode | |
+class TextNode extends PartialMatchNode | |
{ | |
- function contains($value) | |
+ public function contains($value) | |
{ | |
$this->searchTerms["contains"] = strval($value); | |
return $this; | |
} | |
} | |
+class_alias('Braintree\TextNode', 'Braintree_TextNode'); | |
Index: braintree_sdk/lib/Braintree/ThreeDSecureInfo.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/ThreeDSecureInfo.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/ThreeDSecureInfo.php (working copy) | |
@@ -1,5 +1,7 @@ | |
<?php | |
-class Braintree_ThreeDSecureInfo extends Braintree_Base | |
+namespace Braintree; | |
+ | |
+class ThreeDSecureInfo extends Base | |
{ | |
public static function factory($attributes) | |
{ | |
@@ -21,7 +23,8 @@ | |
public function __toString() | |
{ | |
return __CLASS__ . '[' . | |
- Braintree_Util::attributesToString($this->_attributes) .']'; | |
+ Util::attributesToString($this->_attributes) .']'; | |
} | |
} | |
+class_alias('Braintree\ThreeDSecureInfo', 'Braintree_ThreeDSecureInfo'); | |
Index: braintree_sdk/lib/Braintree/Transaction/AddressDetails.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Transaction/AddressDetails.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Transaction/AddressDetails.php (working copy) | |
@@ -1,11 +1,15 @@ | |
<?php | |
+namespace Braintree\Transaction; | |
+ | |
+use Braintree\Instance; | |
+ | |
/** | |
* Creates an instance of AddressDetails as returned from a transaction | |
* | |
* | |
* @package Braintree | |
* @subpackage Transaction | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
* @property-read string $firstName | |
* @property-read string $lastName | |
@@ -16,9 +20,9 @@ | |
* @property-read string $region | |
* @property-read string $postalCode | |
* @property-read string $countryName | |
- * @uses Braintree_Instance inherits methods | |
*/ | |
-class Braintree_Transaction_AddressDetails extends Braintree_Instance | |
+class AddressDetails extends Instance | |
{ | |
- protected $_attributes = array(); | |
+ protected $_attributes = []; | |
} | |
+class_alias('Braintree\Transaction\AddressDetails', 'Braintree_Transaction_AddressDetails'); | |
Index: braintree_sdk/lib/Braintree/Transaction/AmexExpressCheckoutCardDetails.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Transaction/AmexExpressCheckoutCardDetails.php (revision 0) | |
+++ braintree_sdk/lib/Braintree/Transaction/AmexExpressCheckoutCardDetails.php (working copy) | |
@@ -0,0 +1,45 @@ | |
+<?php | |
+namespace Braintree\Transaction; | |
+ | |
+use Braintree\Instance; | |
+/** | |
+ * Amex Express Checkout card details from a transaction | |
+ * | |
+ * @package Braintree | |
+ * @subpackage Transaction | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
+ */ | |
+ | |
+/** | |
+ * creates an instance of AmexExpressCheckoutCardDetails | |
+ * | |
+ * | |
+ * @package Braintree | |
+ * @subpackage Transaction | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
+ * | |
+ * @property-read string $cardType | |
+ * @property-read string $bin | |
+ * @property-read string $cardMemberExpiryDate | |
+ * @property-read string $cardMemberNumber | |
+ * @property-read string $cardType | |
+ * @property-read string $sourceDescription | |
+ * @property-read string $token | |
+ * @property-read string $imageUrl | |
+ * @property-read string $expirationMonth | |
+ * @property-read string $expirationYear | |
+ * @uses Instance inherits methods | |
+ */ | |
+class AmexExpressCheckoutCardDetails extends Instance | |
+{ | |
+ protected $_attributes = []; | |
+ | |
+ /** | |
+ * @ignore | |
+ */ | |
+ public function __construct($attributes) | |
+ { | |
+ parent::__construct($attributes); | |
+ } | |
+} | |
+class_alias('Braintree\Transaction\AmexExpressCheckoutCardDetails', 'Braintree_Transaction_AmexExpressCheckoutCardDetails'); | |
Index: braintree_sdk/lib/Braintree/Transaction/AndroidPayCardDetails.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Transaction/AndroidPayCardDetails.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Transaction/AndroidPayCardDetails.php (working copy) | |
@@ -1,10 +1,14 @@ | |
<?php | |
+namespace Braintree\Transaction; | |
+ | |
+use Braintree\Instance; | |
+ | |
/** | |
* Android Pay card details from a transaction | |
* | |
* @package Braintree | |
* @subpackage Transaction | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
/** | |
@@ -13,7 +17,7 @@ | |
* | |
* @package Braintree | |
* @subpackage Transaction | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
* @property-read string $bin | |
* @property-read string $default | |
@@ -27,11 +31,10 @@ | |
* @property-read string $token | |
* @property-read string $virtualCardLast4 | |
* @property-read string $virtualCardType | |
- * @uses Braintree_Instance inherits methods | |
*/ | |
-class Braintree_Transaction_AndroidPayCardDetails extends Braintree_Instance | |
+class AndroidPayCardDetails extends Instance | |
{ | |
- protected $_attributes = array(); | |
+ protected $_attributes = []; | |
/** | |
* @ignore | |
@@ -43,3 +46,4 @@ | |
$this->_attributes['last4'] = $this->virtualCardLast4; | |
} | |
} | |
+class_alias('Braintree\Transaction\AndroidPayCardDetails', 'Braintree_Transaction_AndroidPayCardDetails'); | |
Index: braintree_sdk/lib/Braintree/Transaction/ApplePayCardDetails.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Transaction/ApplePayCardDetails.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Transaction/ApplePayCardDetails.php (working copy) | |
@@ -1,10 +1,14 @@ | |
<?php | |
+namespace Braintree\Transaction; | |
+ | |
+use Braintree\Instance; | |
+ | |
/** | |
* Apple Pay card details from a transaction | |
* | |
* @package Braintree | |
* @subpackage Transaction | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
/** | |
@@ -13,7 +17,7 @@ | |
* | |
* @package Braintree | |
* @subpackage Transaction | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
* @property-read string $cardType | |
* @property-read string $paymentInstrumentName | |
@@ -21,11 +25,10 @@ | |
* @property-read string $expirationYear | |
* @property-read string $cardholderName | |
* @property-read string $sourceDescription | |
- * @uses Braintree_Instance inherits methods | |
*/ | |
-class Braintree_Transaction_ApplePayCardDetails extends Braintree_Instance | |
+class ApplePayCardDetails extends Instance | |
{ | |
- protected $_attributes = array(); | |
+ protected $_attributes = []; | |
/** | |
* @ignore | |
@@ -35,3 +38,4 @@ | |
parent::__construct($attributes); | |
} | |
} | |
+class_alias('Braintree\Transaction\ApplePayCardDetails', 'Braintree_Transaction_ApplePayCardDetails'); | |
Index: braintree_sdk/lib/Braintree/Transaction/CoinbaseDetails.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Transaction/CoinbaseDetails.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Transaction/CoinbaseDetails.php (working copy) | |
@@ -1,10 +1,14 @@ | |
<?php | |
+namespace Braintree\Transaction; | |
+ | |
+use Braintree\Instance; | |
+ | |
/** | |
* Coinbase details from a transaction | |
* | |
* @package Braintree | |
* @subpackage Transaction | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
/** | |
@@ -13,18 +17,17 @@ | |
* | |
* @package Braintree | |
* @subpackage Transaction | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
* @property-read string $token | |
* @property-read string $userId | |
* @property-read string $userName | |
* @property-read string $userEmail | |
* @property-read string $imageUrl | |
- * @uses Braintree_Instance inherits methods | |
*/ | |
-class Braintree_Transaction_CoinbaseDetails extends Braintree_Instance | |
+class CoinbaseDetails extends Instance | |
{ | |
- protected $_attributes = array(); | |
+ protected $_attributes = []; | |
/** | |
* @ignore | |
@@ -34,3 +37,4 @@ | |
parent::__construct($attributes); | |
} | |
} | |
+class_alias('Braintree\Transaction\CoinbaseDetails', 'Braintree_Transaction_CoinbaseDetails'); | |
Index: braintree_sdk/lib/Braintree/Transaction/CreditCardDetails.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Transaction/CreditCardDetails.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Transaction/CreditCardDetails.php (working copy) | |
@@ -1,11 +1,15 @@ | |
<?php | |
+namespace Braintree\Transaction; | |
+ | |
+use Braintree\Instance; | |
+ | |
/** | |
* CreditCard details from a transaction | |
* creates an instance of CreditCardDetails | |
* | |
* @package Braintree | |
* @subpackage Transaction | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
* @property-read string $bin | |
* @property-read string $cardType | |
@@ -16,11 +20,10 @@ | |
* @property-read string $last4 | |
* @property-read string $maskedNumber | |
* @property-read string $token | |
- * @uses Braintree_Instance inherits methods | |
*/ | |
-class Braintree_Transaction_CreditCardDetails extends Braintree_Instance | |
+class CreditCardDetails extends Instance | |
{ | |
- protected $_attributes = array(); | |
+ protected $_attributes = []; | |
/** | |
* @ignore | |
@@ -33,3 +36,4 @@ | |
} | |
} | |
+class_alias('Braintree\Transaction\CreditCardDetails', 'Braintree_Transaction_CreditCardDetails'); | |
Index: braintree_sdk/lib/Braintree/Transaction/CustomerDetails.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Transaction/CustomerDetails.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Transaction/CustomerDetails.php (working copy) | |
@@ -1,11 +1,15 @@ | |
<?php | |
+namespace Braintree\Transaction; | |
+ | |
+use Braintree\Instance; | |
+ | |
/** | |
* Customer details from a transaction | |
* Creates an instance of customer details as returned from a transaction | |
* | |
* @package Braintree | |
* @subpackage Transaction | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
* @property-read string $company | |
* @property-read string $email | |
@@ -15,8 +19,8 @@ | |
* @property-read string $lastName | |
* @property-read string $phone | |
* @property-read string $website | |
- * @uses Braintree_Instance inherits methods | |
*/ | |
-class Braintree_Transaction_CustomerDetails extends Braintree_Instance | |
+class CustomerDetails extends Instance | |
{ | |
} | |
+class_alias('Braintree\Transaction\CustomerDetails', 'Braintree_Transaction_CustomerDetails'); | |
Index: braintree_sdk/lib/Braintree/Transaction/EuropeBankAccountDetails.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Transaction/EuropeBankAccountDetails.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Transaction/EuropeBankAccountDetails.php (working copy) | |
@@ -1,11 +1,15 @@ | |
<?php | |
+namespace Braintree\Transaction; | |
+ | |
+use Braintree\Instance; | |
+ | |
/** | |
* Europe bank account details from a transaction | |
* Creates an instance of europe bank account details as returned from a transaction | |
* | |
* @package Braintree | |
* @subpackage Transaction | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
* @property-read string $accountHolderName | |
* @property-read string $bic | |
@@ -14,8 +18,8 @@ | |
* @property-read string $mandateReferenceNumber | |
* @property-read string $maskedIban | |
* @property-read string $token | |
- * @uses Braintree_Instance inherits methods | |
*/ | |
-class Braintree_Transaction_EuropeBankAccountDetails extends Braintree_Instance | |
+class EuropeBankAccountDetails extends Instance | |
{ | |
} | |
+class_alias('Braintree\Transaction\EuropeBankAccountDetails', 'Braintree_Transaction_EuropeBankAccountDetails'); | |
Index: braintree_sdk/lib/Braintree/Transaction/PayPalDetails.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Transaction/PayPalDetails.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Transaction/PayPalDetails.php (working copy) | |
@@ -1,10 +1,14 @@ | |
<?php | |
+namespace Braintree\Transaction; | |
+ | |
+use Braintree\Instance; | |
+ | |
/** | |
* PayPal details from a transaction | |
* | |
* @package Braintree | |
* @subpackage Transaction | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
/** | |
@@ -13,7 +17,7 @@ | |
* | |
* @package Braintree | |
* @subpackage Transaction | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
* @property-read string $payerEmail | |
* @property-read string $paymentId | |
@@ -23,11 +27,10 @@ | |
* @property-read string $transactionFeeAmount | |
* @property-read string $transactionFeeCurrencyIsoCode | |
* @property-read string $description | |
- * @uses Braintree_Instance inherits methods | |
*/ | |
-class Braintree_Transaction_PayPalDetails extends Braintree_Instance | |
+class PayPalDetails extends Instance | |
{ | |
- protected $_attributes = array(); | |
+ protected $_attributes = []; | |
/** | |
* @ignore | |
@@ -37,3 +40,4 @@ | |
parent::__construct($attributes); | |
} | |
} | |
+class_alias('Braintree\Transaction\PayPalDetails', 'Braintree_Transaction_PayPalDetails'); | |
Index: braintree_sdk/lib/Braintree/Transaction/StatusDetails.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Transaction/StatusDetails.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Transaction/StatusDetails.php (working copy) | |
@@ -1,18 +1,22 @@ | |
<?php | |
+namespace Braintree\Transaction; | |
+ | |
+use Braintree\Instance; | |
+ | |
/** | |
* Status details from a transaction | |
* Creates an instance of StatusDetails, as part of a transaction response | |
* | |
* @package Braintree | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
* @property-read string $amount | |
* @property-read string $status | |
* @property-read string $timestamp | |
* @property-read string $transactionSource | |
* @property-read string $user | |
- * @uses Braintree_Instance inherits methods | |
*/ | |
-class Braintree_Transaction_StatusDetails extends Braintree_Instance | |
+class StatusDetails extends Instance | |
{ | |
} | |
+class_alias('Braintree\Transaction\StatusDetails', 'Braintree_Transaction_StatusDetails'); | |
Index: braintree_sdk/lib/Braintree/Transaction/SubscriptionDetails.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Transaction/SubscriptionDetails.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Transaction/SubscriptionDetails.php (working copy) | |
@@ -1,15 +1,20 @@ | |
<?php | |
+namespace Braintree\Transaction; | |
+ | |
+use Braintree\Instance; | |
+ | |
/** | |
* Customer details from a transaction | |
* Creates an instance of customer details as returned from a transaction | |
* | |
* @package Braintree | |
* @subpackage Transaction | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
* @property-read string $billing_period_start_date | |
* @property-read string $billing_period_end_date | |
*/ | |
-class Braintree_Transaction_SubscriptionDetails extends Braintree_Instance | |
+class SubscriptionDetails extends Instance | |
{ | |
} | |
+class_alias('Braintree\Transaction\SubscriptionDetails', 'Braintree_Transaction_SubscriptionDetails'); | |
Index: braintree_sdk/lib/Braintree/Transaction/VenmoAccountDetails.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Transaction/VenmoAccountDetails.php (revision 0) | |
+++ braintree_sdk/lib/Braintree/Transaction/VenmoAccountDetails.php (working copy) | |
@@ -0,0 +1,40 @@ | |
+<?php | |
+namespace Braintree\Transaction; | |
+ | |
+use Braintree\Instance; | |
+/** | |
+ * Venmo account details from a transaction | |
+ * | |
+ * @package Braintree | |
+ * @subpackage Transaction | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
+ */ | |
+ | |
+/** | |
+ * creates an instance of VenmoAccountDetails | |
+ * | |
+ * | |
+ * @package Braintree | |
+ * @subpackage Transaction | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
+ * | |
+ * @property-read string $sourceDescription | |
+ * @property-read string $token | |
+ * @property-read string $imageUrl | |
+ * @property-read string $username | |
+ * @property-read string $venmo_user_id | |
+ * @uses Instance inherits methods | |
+ */ | |
+class VenmoAccountDetails extends Instance | |
+{ | |
+ protected $_attributes = array(); | |
+ | |
+ /** | |
+ * @ignore | |
+ */ | |
+ public function __construct($attributes) | |
+ { | |
+ parent::__construct($attributes); | |
+ } | |
+} | |
+class_alias('Braintree\Transaction\VenmoAccountDetails', 'Braintree_Transaction_VenmoAccountDetails'); | |
Index: braintree_sdk/lib/Braintree/Transaction.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Transaction.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Transaction.php (working copy) | |
@@ -1,4 +1,6 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
/** | |
* Braintree Transaction processor | |
* Creates and manages transactions | |
@@ -8,7 +10,7 @@ | |
* | |
* <b>Minimalistic example:</b> | |
* <code> | |
- * Braintree_Transaction::saleNoValidate(array( | |
+ * Transaction::saleNoValidate(array( | |
* 'amount' => '100.00', | |
* 'creditCard' => array( | |
* 'number' => '5105105105105100', | |
@@ -19,7 +21,7 @@ | |
* | |
* <b>Full example:</b> | |
* <code> | |
- * Braintree_Transaction::saleNoValidate(array( | |
+ * Transaction::saleNoValidate(array( | |
* 'amount' => '100.00', | |
* 'orderId' => '123', | |
* 'channel' => 'MyShoppingCardProvider', | |
@@ -75,7 +77,7 @@ | |
* a transaction can be stored in the vault by setting | |
* <i>transaction[options][storeInVault]</i> to true. | |
* <code> | |
- * $transaction = Braintree_Transaction::saleNoValidate(array( | |
+ * $transaction = Transaction::saleNoValidate(array( | |
* 'customer' => array( | |
* 'firstName' => 'Adam', | |
* 'lastName' => 'Williams' | |
@@ -98,7 +100,7 @@ | |
* To also store the billing address in the vault, pass the | |
* <b>addBillingAddressToPaymentMethod</b> option. | |
* <code> | |
- * Braintree_Transaction.saleNoValidate(array( | |
+ * Transaction.saleNoValidate(array( | |
* ... | |
* 'options' => array( | |
* 'storeInVault' => true | |
@@ -119,7 +121,7 @@ | |
* $transaction[options][submitForSettlement] to true. | |
* | |
* <code> | |
- * $transaction = Braintree_Transaction::saleNoValidate(array( | |
+ * $transaction = Transaction::saleNoValidate(array( | |
* 'amount' => '100.00', | |
* 'creditCard' => array( | |
* 'number' => '5105105105105100', | |
@@ -137,7 +139,7 @@ | |
* | |
* @package Braintree | |
* @category Resources | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
* | |
* @property-read string $avsErrorResponseCode | |
@@ -146,29 +148,30 @@ | |
* @property-read string $cvvResponseCode | |
* @property-read string $id transaction id | |
* @property-read string $amount transaction amount | |
- * @property-read object $billingDetails transaction billing address | |
+ * @property-read Braintree\Transaction\AddressDetails $billingDetails transaction billing address | |
* @property-read string $createdAt transaction created timestamp | |
- * @property-read object $applePayCardDetails transaction Apple Pay card info | |
- * @property-read object $androidPayCardDetails transaction Android Pay card info | |
- * @property-read object $creditCardDetails transaction credit card info | |
- * @property-read object $coinbaseDetails transaction Coinbase account info | |
- * @property-read object $paypalDetails transaction paypal account info | |
- * @property-read object $customerDetails transaction customer info | |
+ * @property-read Braintree\ApplePayCardDetails $applePayCardDetails transaction Apple Pay card info | |
+ * @property-read Braintree\AndroidPayCardDetails $androidPayCardDetails transaction Android Pay card info | |
+ * @property-read Braintree\AmexExpressCheckoutCardDetails $amexExpressCheckoutCardDetails transaction Amex Express Checkout card info | |
+ * @property-read Braintree\CreditCardDetails $creditCardDetails transaction credit card info | |
+ * @property-read Braintree\CoinbaseAccountDetails $coinbaseDetails transaction Coinbase account info | |
+ * @property-read Braintree\PayPalAccountDetails $paypalDetails transaction paypal account info | |
+ * @property-read Braintree\Customer $customerDetails transaction customer info | |
+ * @property-read Braintree\VenmoAccount $venmoAccountDetails transaction Venmo Account info | |
* @property-read array $customFields custom fields passed with the request | |
* @property-read string $processorResponseCode gateway response code | |
* @property-read string $additionalProcessorResponse raw response from processor | |
- * @property-read object $shippingDetails transaction shipping address | |
+ * @property-read Braintree\Transaction\AddressDetails $shippingDetails transaction shipping address | |
* @property-read string $status transaction status | |
* @property-read array $statusHistory array of StatusDetails objects | |
* @property-read string $type transaction type | |
* @property-read string $updatedAt transaction updated timestamp | |
- * @property-read object $disbursementDetails populated when transaction is disbursed | |
- * @property-read object $disputes populated when transaction is disputed | |
- * @property-read string $amexRewardsResponse AmEx Rewards response | |
+ * @property-read Braintree\Disbursement $disbursementDetails populated when transaction is disbursed | |
+ * @property-read Braintree\Dispute $disputes populated when transaction is disputed | |
* | |
*/ | |
-final class Braintree_Transaction extends Braintree_Base | |
+final class Transaction extends Base | |
{ | |
// Transaction Status | |
const AUTHORIZATION_EXPIRED = 'authorization_expired'; | |
@@ -225,7 +228,7 @@ | |
* @ignore | |
* @access protected | |
* @param array $transactionAttribs array of transaction data | |
- * @return none | |
+ * @return void | |
*/ | |
protected function _initialize($transactionAttribs) | |
{ | |
@@ -233,7 +236,7 @@ | |
if (isset($transactionAttribs['applePay'])) { | |
$this->_set('applePayCardDetails', | |
- new Braintree_Transaction_ApplePayCardDetails( | |
+ new Transaction\ApplePayCardDetails( | |
$transactionAttribs['applePay'] | |
) | |
); | |
@@ -241,15 +244,31 @@ | |
if (isset($transactionAttribs['androidPayCard'])) { | |
$this->_set('androidPayCardDetails', | |
- new Braintree_Transaction_AndroidPayCardDetails( | |
+ new Transaction\AndroidPayCardDetails( | |
$transactionAttribs['androidPayCard'] | |
) | |
); | |
} | |
+ if (isset($transactionAttribs['amexExpressCheckoutCard'])) { | |
+ $this->_set('amexExpressCheckoutCardDetails', | |
+ new Transaction\AmexExpressCheckoutCardDetails( | |
+ $transactionAttribs['amexExpressCheckoutCard'] | |
+ ) | |
+ ); | |
+ } | |
+ | |
+ if (isset($transactionAttribs['venmoAccount'])) { | |
+ $this->_set('venmoAccountDetails', | |
+ new Transaction\VenmoAccountDetails( | |
+ $transactionAttribs['venmoAccount'] | |
+ ) | |
+ ); | |
+ } | |
+ | |
if (isset($transactionAttribs['creditCard'])) { | |
$this->_set('creditCardDetails', | |
- new Braintree_Transaction_CreditCardDetails( | |
+ new Transaction\CreditCardDetails( | |
$transactionAttribs['creditCard'] | |
) | |
); | |
@@ -257,7 +276,7 @@ | |
if (isset($transactionAttribs['coinbaseAccount'])) { | |
$this->_set('coinbaseDetails', | |
- new Braintree_Transaction_CoinbaseDetails( | |
+ new Transaction\CoinbaseDetails( | |
$transactionAttribs['coinbaseAccount'] | |
) | |
); | |
@@ -265,7 +284,7 @@ | |
if (isset($transactionAttribs['europeBankAccount'])) { | |
$this->_set('europeBankAccount', | |
- new Braintree_Transaction_EuropeBankAccountDetails( | |
+ new Transaction\EuropeBankAccountDetails( | |
$transactionAttribs['europeBankAccount'] | |
) | |
); | |
@@ -273,7 +292,7 @@ | |
if (isset($transactionAttribs['paypal'])) { | |
$this->_set('paypalDetails', | |
- new Braintree_Transaction_PayPalDetails( | |
+ new Transaction\PayPalDetails( | |
$transactionAttribs['paypal'] | |
) | |
); | |
@@ -281,7 +300,7 @@ | |
if (isset($transactionAttribs['customer'])) { | |
$this->_set('customerDetails', | |
- new Braintree_Transaction_CustomerDetails( | |
+ new Transaction\CustomerDetails( | |
$transactionAttribs['customer'] | |
) | |
); | |
@@ -289,7 +308,7 @@ | |
if (isset($transactionAttribs['billing'])) { | |
$this->_set('billingDetails', | |
- new Braintree_Transaction_AddressDetails( | |
+ new Transaction\AddressDetails( | |
$transactionAttribs['billing'] | |
) | |
); | |
@@ -297,7 +316,7 @@ | |
if (isset($transactionAttribs['shipping'])) { | |
$this->_set('shippingDetails', | |
- new Braintree_Transaction_AddressDetails( | |
+ new Transaction\AddressDetails( | |
$transactionAttribs['shipping'] | |
) | |
); | |
@@ -305,7 +324,7 @@ | |
if (isset($transactionAttribs['subscription'])) { | |
$this->_set('subscriptionDetails', | |
- new Braintree_Transaction_SubscriptionDetails( | |
+ new Transaction\SubscriptionDetails( | |
$transactionAttribs['subscription'] | |
) | |
); | |
@@ -313,7 +332,7 @@ | |
if (isset($transactionAttribs['descriptor'])) { | |
$this->_set('descriptor', | |
- new Braintree_Descriptor( | |
+ new Descriptor( | |
$transactionAttribs['descriptor'] | |
) | |
); | |
@@ -321,50 +340,53 @@ | |
if (isset($transactionAttribs['disbursementDetails'])) { | |
$this->_set('disbursementDetails', | |
- new Braintree_DisbursementDetails($transactionAttribs['disbursementDetails']) | |
+ new DisbursementDetails($transactionAttribs['disbursementDetails']) | |
); | |
} | |
- $disputes = array(); | |
+ $disputes = []; | |
if (isset($transactionAttribs['disputes'])) { | |
foreach ($transactionAttribs['disputes'] AS $dispute) { | |
- $disputes[] = Braintree_Dispute::factory($dispute); | |
+ $disputes[] = Dispute::factory($dispute); | |
} | |
} | |
$this->_set('disputes', $disputes); | |
- $statusHistory = array(); | |
+ $statusHistory = []; | |
if (isset($transactionAttribs['statusHistory'])) { | |
foreach ($transactionAttribs['statusHistory'] AS $history) { | |
- $statusHistory[] = new Braintree_Transaction_StatusDetails($history); | |
+ $statusHistory[] = new Transaction\StatusDetails($history); | |
} | |
} | |
$this->_set('statusHistory', $statusHistory); | |
- $addOnArray = array(); | |
+ $addOnArray = []; | |
if (isset($transactionAttribs['addOns'])) { | |
foreach ($transactionAttribs['addOns'] AS $addOn) { | |
- $addOnArray[] = Braintree_AddOn::factory($addOn); | |
+ $addOnArray[] = AddOn::factory($addOn); | |
} | |
} | |
$this->_set('addOns', $addOnArray); | |
- $discountArray = array(); | |
+ $discountArray = []; | |
if (isset($transactionAttribs['discounts'])) { | |
foreach ($transactionAttribs['discounts'] AS $discount) { | |
- $discountArray[] = Braintree_Discount::factory($discount); | |
+ $discountArray[] = Discount::factory($discount); | |
} | |
} | |
$this->_set('discounts', $discountArray); | |
if(isset($transactionAttribs['riskData'])) { | |
- $this->_set('riskData', Braintree_RiskData::factory($transactionAttribs['riskData'])); | |
+ $this->_set('riskData', RiskData::factory($transactionAttribs['riskData'])); | |
} | |
if(isset($transactionAttribs['threeDSecureInfo'])) { | |
- $this->_set('threeDSecureInfo', Braintree_ThreeDSecureInfo::factory($transactionAttribs['threeDSecureInfo'])); | |
+ $this->_set('threeDSecureInfo', ThreeDSecureInfo::factory($transactionAttribs['threeDSecureInfo'])); | |
} | |
+ if(isset($transactionAttribs['facilitatorDetails'])) { | |
+ $this->_set('facilitatorDetails', FacilitatorDetails::factory($transactionAttribs['facilitatorDetails'])); | |
+ } | |
} | |
/** | |
@@ -374,17 +396,17 @@ | |
public function __toString() | |
{ | |
// array of attributes to print | |
- $display = array( | |
+ $display = [ | |
'id', 'type', 'amount', 'status', | |
'createdAt', 'creditCardDetails', 'customerDetails' | |
- ); | |
+ ]; | |
- $displayAttributes = array(); | |
+ $displayAttributes = []; | |
foreach ($display AS $attrib) { | |
$displayAttributes[$attrib] = $this->$attrib; | |
} | |
return __CLASS__ . '[' . | |
- Braintree_Util::attributesToString($displayAttributes) .']'; | |
+ Util::attributesToString($displayAttributes) .']'; | |
} | |
public function isEqual($otherTx) | |
@@ -399,10 +421,11 @@ | |
return null; | |
} | |
else { | |
- return Braintree_CreditCard::find($token); | |
+ return CreditCard::find($token); | |
} | |
} | |
+ /** @return void|Braintree\Customer */ | |
public function vaultCustomer() | |
{ | |
$customerId = $this->customerDetails->id; | |
@@ -410,20 +433,21 @@ | |
return null; | |
} | |
else { | |
- return Braintree_Customer::find($customerId); | |
+ return Customer::find($customerId); | |
} | |
} | |
+ /** @return bool */ | |
public function isDisbursed() { | |
return $this->disbursementDetails->isValid(); | |
} | |
/** | |
- * factory method: returns an instance of Braintree_Transaction | |
+ * factory method: returns an instance of Transaction | |
* to the requesting method, with populated properties | |
* | |
* @ignore | |
- * @return object instance of Braintree_Transaction | |
+ * @return Transaction | |
*/ | |
public static function factory($attributes) | |
{ | |
@@ -437,91 +461,97 @@ | |
public static function cloneTransaction($transactionId, $attribs) | |
{ | |
- return Braintree_Configuration::gateway()->transaction()->cloneTransaction($transactionId, $attribs); | |
+ return Configuration::gateway()->transaction()->cloneTransaction($transactionId, $attribs); | |
} | |
public static function createFromTransparentRedirect($queryString) | |
{ | |
- return Braintree_Configuration::gateway()->transaction()->createFromTransparentRedirect($queryString); | |
+ return Configuration::gateway()->transaction()->createFromTransparentRedirect($queryString); | |
} | |
public static function createTransactionUrl() | |
{ | |
- return Braintree_Configuration::gateway()->transaction()->createTransactionUrl(); | |
+ return Configuration::gateway()->transaction()->createTransactionUrl(); | |
} | |
public static function credit($attribs) | |
{ | |
- return Braintree_Configuration::gateway()->transaction()->credit($attribs); | |
+ return Configuration::gateway()->transaction()->credit($attribs); | |
} | |
public static function creditNoValidate($attribs) | |
{ | |
- return Braintree_Configuration::gateway()->transaction()->creditNoValidate($attribs); | |
+ return Configuration::gateway()->transaction()->creditNoValidate($attribs); | |
} | |
public static function find($id) | |
{ | |
- return Braintree_Configuration::gateway()->transaction()->find($id); | |
+ return Configuration::gateway()->transaction()->find($id); | |
} | |
public static function sale($attribs) | |
{ | |
- return Braintree_Configuration::gateway()->transaction()->sale($attribs); | |
+ return Configuration::gateway()->transaction()->sale($attribs); | |
} | |
public static function saleNoValidate($attribs) | |
{ | |
- return Braintree_Configuration::gateway()->transaction()->saleNoValidate($attribs); | |
+ return Configuration::gateway()->transaction()->saleNoValidate($attribs); | |
} | |
public static function search($query) | |
{ | |
- return Braintree_Configuration::gateway()->transaction()->search($query); | |
+ return Configuration::gateway()->transaction()->search($query); | |
} | |
public static function fetch($query, $ids) | |
{ | |
- return Braintree_Configuration::gateway()->transaction()->fetch($query, $ids); | |
+ return Configuration::gateway()->transaction()->fetch($query, $ids); | |
} | |
public static function void($transactionId) | |
{ | |
- return Braintree_Configuration::gateway()->transaction()->void($transactionId); | |
+ return Configuration::gateway()->transaction()->void($transactionId); | |
} | |
public static function voidNoValidate($transactionId) | |
{ | |
- return Braintree_Configuration::gateway()->transaction()->voidNoValidate($transactionId); | |
+ return Configuration::gateway()->transaction()->voidNoValidate($transactionId); | |
} | |
- public static function submitForSettlement($transactionId, $amount = null) | |
+ public static function submitForSettlement($transactionId, $amount = null, $attribs = []) | |
{ | |
- return Braintree_Configuration::gateway()->transaction()->submitForSettlement($transactionId, $amount); | |
+ return Configuration::gateway()->transaction()->submitForSettlement($transactionId, $amount, $attribs); | |
} | |
- public static function submitForSettlementNoValidate($transactionId, $amount = null) | |
+ public static function submitForSettlementNoValidate($transactionId, $amount = null, $attribs = []) | |
{ | |
- return Braintree_Configuration::gateway()->transaction()->submitForSettlementNoValidate($transactionId, $amount); | |
+ return Configuration::gateway()->transaction()->submitForSettlementNoValidate($transactionId, $amount, $attribs); | |
} | |
+ public static function submitForPartialSettlement($transactionId, $amount, $attribs = []) | |
+ { | |
+ return Configuration::gateway()->transaction()->submitForPartialSettlement($transactionId, $amount, $attribs); | |
+ } | |
+ | |
public static function holdInEscrow($transactionId) | |
{ | |
- return Braintree_Configuration::gateway()->transaction()->holdInEscrow($transactionId); | |
+ return Configuration::gateway()->transaction()->holdInEscrow($transactionId); | |
} | |
public static function releaseFromEscrow($transactionId) | |
{ | |
- return Braintree_Configuration::gateway()->transaction()->releaseFromEscrow($transactionId); | |
+ return Configuration::gateway()->transaction()->releaseFromEscrow($transactionId); | |
} | |
public static function cancelRelease($transactionId) | |
{ | |
- return Braintree_Configuration::gateway()->transaction()->cancelRelease($transactionId); | |
+ return Configuration::gateway()->transaction()->cancelRelease($transactionId); | |
} | |
public static function refund($transactionId, $amount = null) | |
{ | |
- return Braintree_Configuration::gateway()->transaction()->refund($transactionId, $amount); | |
+ return Configuration::gateway()->transaction()->refund($transactionId, $amount); | |
} | |
} | |
+class_alias('Braintree\Transaction', 'Braintree_Transaction'); | |
Index: braintree_sdk/lib/Braintree/TransactionGateway.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/TransactionGateway.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/TransactionGateway.php (working copy) | |
@@ -1,4 +1,8 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
+use InvalidArgumentException; | |
+ | |
/** | |
* Braintree TransactionGateway processor | |
* Creates and manages transactions | |
@@ -10,10 +14,10 @@ | |
* | |
* @package Braintree | |
* @category Resources | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-final class Braintree_TransactionGateway | |
+final class TransactionGateway | |
{ | |
private $_gateway; | |
private $_config; | |
@@ -24,13 +28,13 @@ | |
$this->_gateway = $gateway; | |
$this->_config = $gateway->config; | |
$this->_config->assertHasAccessTokenOrKeys(); | |
- $this->_http = new Braintree_Http($gateway->config); | |
+ $this->_http = new Http($gateway->config); | |
} | |
public function cloneTransaction($transactionId, $attribs) | |
{ | |
- Braintree_Util::verifyKeys(self::cloneSignature(), $attribs); | |
- return $this->_doCreate('/transactions/' . $transactionId . '/clone', array('transactionClone' => $attribs)); | |
+ Util::verifyKeys(self::cloneSignature(), $attribs); | |
+ return $this->_doCreate('/transactions/' . $transactionId . '/clone', ['transactionClone' => $attribs]); | |
} | |
/** | |
@@ -41,56 +45,57 @@ | |
*/ | |
private function create($attribs) | |
{ | |
- Braintree_Util::verifyKeys(self::createSignature(), $attribs); | |
- return $this->_doCreate('/transactions', array('transaction' => $attribs)); | |
+ Util::verifyKeys(self::createSignature(), $attribs); | |
+ return $this->_doCreate('/transactions', ['transaction' => $attribs]); | |
} | |
/** | |
- * | |
* @ignore | |
* @access private | |
* @param array $attribs | |
* @return object | |
- * @throws Braintree_Exception_ValidationError | |
+ * @throws Exception\ValidationError | |
*/ | |
private function createNoValidate($attribs) | |
{ | |
$result = $this->create($attribs); | |
- return Braintree_Util::returnObjectOrThrowException(__CLASS__, $result); | |
+ return Util::returnObjectOrThrowException(__CLASS__, $result); | |
} | |
/** | |
* | |
+ * @deprecated since version 2.3.0 | |
* @access public | |
* @param array $attribs | |
* @return object | |
*/ | |
public function createFromTransparentRedirect($queryString) | |
{ | |
- trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::confirm", E_USER_NOTICE); | |
- $params = Braintree_TransparentRedirect::parseAndValidateQueryString( | |
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::confirm", E_USER_NOTICE); | |
+ $params = TransparentRedirect::parseAndValidateQueryString( | |
$queryString | |
); | |
return $this->_doCreate( | |
'/transactions/all/confirm_transparent_redirect_request', | |
- array('id' => $params['id']) | |
+ ['id' => $params['id']] | |
); | |
} | |
/** | |
* | |
+ * @deprecated since version 2.3.0 | |
* @access public | |
* @param none | |
* @return string | |
*/ | |
public function createTransactionUrl() | |
{ | |
- trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::url", E_USER_NOTICE); | |
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::url", E_USER_NOTICE); | |
return $this->_config->baseUrl() . $this->_config->merchantPath() . | |
'/transactions/all/create_via_transparent_redirect_request'; | |
} | |
public static function cloneSignature() | |
{ | |
- return array('amount', 'channel', array('options' => array('submitForSettlement'))); | |
+ return ['amount', 'channel', ['options' => ['submitForSettlement']]]; | |
} | |
/** | |
@@ -99,7 +104,7 @@ | |
*/ | |
public static function createSignature() | |
{ | |
- return array( | |
+ return [ | |
'amount', | |
'billingAddressId', | |
'channel', | |
@@ -114,36 +119,40 @@ | |
'purchaseOrderNumber', | |
'recurring', | |
'serviceFeeAmount', | |
+ 'sharedPaymentMethodToken', | |
+ 'sharedCustomerId', | |
+ 'sharedShippingAddressId', | |
+ 'sharedBillingAddressId', | |
'shippingAddressId', | |
'taxAmount', | |
'taxExempt', | |
'threeDSecureToken', | |
'type', | |
'venmoSdkPaymentMethodCode', | |
- array('creditCard' => | |
- array('token', 'cardholderName', 'cvv', 'expirationDate', 'expirationMonth', 'expirationYear', 'number'), | |
- ), | |
- array('customer' => | |
- array( | |
+ ['creditCard' => | |
+ ['token', 'cardholderName', 'cvv', 'expirationDate', 'expirationMonth', 'expirationYear', 'number'], | |
+ ], | |
+ ['customer' => | |
+ [ | |
'id', 'company', 'email', 'fax', 'firstName', | |
- 'lastName', 'phone', 'website'), | |
- ), | |
- array('billing' => | |
- array( | |
+ 'lastName', 'phone', 'website'], | |
+ ], | |
+ ['billing' => | |
+ [ | |
'firstName', 'lastName', 'company', 'countryName', | |
'countryCodeAlpha2', 'countryCodeAlpha3', 'countryCodeNumeric', | |
'extendedAddress', 'locality', 'postalCode', 'region', | |
- 'streetAddress'), | |
- ), | |
- array('shipping' => | |
- array( | |
+ 'streetAddress'], | |
+ ], | |
+ ['shipping' => | |
+ [ | |
'firstName', 'lastName', 'company', 'countryName', | |
'countryCodeAlpha2', 'countryCodeAlpha3', 'countryCodeNumeric', | |
'extendedAddress', 'locality', 'postalCode', 'region', | |
- 'streetAddress'), | |
- ), | |
- array('options' => | |
- array( | |
+ 'streetAddress'], | |
+ ], | |
+ ['options' => | |
+ [ | |
'holdInEscrow', | |
'storeInVault', | |
'storeInVaultOnSuccess', | |
@@ -152,35 +161,35 @@ | |
'venmoSdkSession', | |
'storeShippingAddressInVault', | |
'payeeEmail', | |
- array('three_d_secure' => | |
- array('required') | |
- ), | |
- array('paypal' => | |
- array( | |
+ ['three_d_secure' => | |
+ ['required'] | |
+ ], | |
+ ['paypal' => | |
+ [ | |
'payeeEmail', | |
'customField', | |
- 'description' | |
- ) | |
- ), | |
- array('amexRewards' => | |
- array( | |
+ 'description', | |
+ ['supplementaryData' => ['_anyKey_']], | |
+ ] | |
+ ], | |
+ ['amexRewards' => | |
+ [ | |
'requestId', | |
'points', | |
'currencyAmount', | |
'currencyIsoCode' | |
- ) | |
- ) | |
- ), | |
- ), | |
- array('customFields' => array('_anyKey_') | |
- ), | |
- array('descriptor' => array('name', 'phone', 'url')), | |
- array('paypalAccount' => array('payeeEmail')), | |
- array('apple_pay_card' => array('number', 'cardholder_name', 'cryptogram', 'expiration_month', 'expiration_year')), | |
- array('industry' => | |
- array('industryType', | |
- array('data' => | |
- array( | |
+ ] | |
+ ] | |
+ ], | |
+ ], | |
+ ['customFields' => ['_anyKey_']], | |
+ ['descriptor' => ['name', 'phone', 'url']], | |
+ ['paypalAccount' => ['payeeEmail']], | |
+ ['apple_pay_card' => ['number', 'cardholder_name', 'cryptogram', 'expiration_month', 'expiration_year']], | |
+ ['industry' => | |
+ ['industryType', | |
+ ['data' => | |
+ [ | |
'folioNumber', | |
'checkInDate', | |
'checkOutDate', | |
@@ -190,41 +199,46 @@ | |
'lodgingCheckOutDate', | |
'lodgingName', | |
'roomRate' | |
- ) | |
- ) | |
- ) | |
- ) | |
- ); | |
+ ] | |
+ ] | |
+ ] | |
+ ] | |
+ ]; | |
} | |
+ public static function submitForSettlementSignature() | |
+ { | |
+ return ['orderId', ['descriptor' => ['name', 'phone', 'url']]]; | |
+ } | |
+ | |
/** | |
* | |
* @access public | |
* @param array $attribs | |
- * @return object | |
+ * @return Result\Successful|Result\Error | |
*/ | |
public function credit($attribs) | |
{ | |
- return $this->create(array_merge($attribs, array('type' => Braintree_Transaction::CREDIT))); | |
+ return $this->create(array_merge($attribs, ['type' => Transaction::CREDIT])); | |
} | |
/** | |
* | |
* @access public | |
* @param array $attribs | |
- * @return object | |
- * @throws Braintree_Exception_ValidationError | |
+ * @return Result\Successful|Result\Error | |
+ * @throws Exception\ValidationError | |
*/ | |
public function creditNoValidate($attribs) | |
{ | |
$result = $this->credit($attribs); | |
- return Braintree_Util::returnObjectOrThrowException(__CLASS__, $result); | |
+ return Util::returnObjectOrThrowException(__CLASS__, $result); | |
} | |
- | |
/** | |
* @access public | |
- * | |
+ * @param string id | |
+ * @return Transaction | |
*/ | |
public function find($id) | |
{ | |
@@ -232,13 +246,12 @@ | |
try { | |
$path = $this->_config->merchantPath() . '/transactions/' . $id; | |
$response = $this->_http->get($path); | |
- return Braintree_Transaction::factory($response['transaction']); | |
- } catch (Braintree_Exception_NotFound $e) { | |
- throw new Braintree_Exception_NotFound( | |
+ return Transaction::factory($response['transaction']); | |
+ } catch (Exception\NotFound $e) { | |
+ throw new Exception\NotFound( | |
'transaction with id ' . $id . ' not found' | |
); | |
} | |
- | |
} | |
/** | |
* new sale | |
@@ -247,7 +260,7 @@ | |
*/ | |
public function sale($attribs) | |
{ | |
- return $this->create(array_merge(array('type' => Braintree_Transaction::SALE), $attribs)); | |
+ return $this->create(array_merge(['type' => Transaction::SALE], $attribs)); | |
} | |
/** | |
@@ -255,12 +268,12 @@ | |
* @access public | |
* @param array $attribs | |
* @return array | |
- * @throws Braintree_Exception_ValidationsFailed | |
+ * @throws Exception\ValidationsFailed | |
*/ | |
public function saleNoValidate($attribs) | |
{ | |
$result = $this->sale($attribs); | |
- return Braintree_Util::returnObjectOrThrowException(__CLASS__, $result); | |
+ return Util::returnObjectOrThrowException(__CLASS__, $result); | |
} | |
/** | |
@@ -272,42 +285,42 @@ | |
* | |
* @param mixed $query search query | |
* @param array $options options such as page number | |
- * @return object Braintree_ResourceCollection | |
+ * @return ResourceCollection | |
* @throws InvalidArgumentException | |
*/ | |
public function search($query) | |
{ | |
- $criteria = array(); | |
+ $criteria = []; | |
foreach ($query as $term) { | |
$criteria[$term->name] = $term->toparam(); | |
} | |
$path = $this->_config->merchantPath() . '/transactions/advanced_search_ids'; | |
- $response = $this->_http->post($path, array('search' => $criteria)); | |
+ $response = $this->_http->post($path, ['search' => $criteria]); | |
if (array_key_exists('searchResults', $response)) { | |
- $pager = array( | |
+ $pager = [ | |
'object' => $this, | |
'method' => 'fetch', | |
- 'methodArgs' => array($query) | |
- ); | |
+ 'methodArgs' => [$query] | |
+ ]; | |
- return new Braintree_ResourceCollection($response, $pager); | |
+ return new ResourceCollection($response, $pager); | |
} else { | |
- throw new Braintree_Exception_DownForMaintenance(); | |
+ throw new Exception\DownForMaintenance(); | |
} | |
} | |
public function fetch($query, $ids) | |
{ | |
- $criteria = array(); | |
+ $criteria = []; | |
foreach ($query as $term) { | |
$criteria[$term->name] = $term->toparam(); | |
} | |
- $criteria["ids"] = Braintree_TransactionSearch::ids()->in($ids)->toparam(); | |
+ $criteria["ids"] = TransactionSearch::ids()->in($ids)->toparam(); | |
$path = $this->_config->merchantPath() . '/transactions/advanced_search'; | |
- $response = $this->_http->post($path, array('search' => $criteria)); | |
+ $response = $this->_http->post($path, ['search' => $criteria]); | |
- return Braintree_Util::extractattributeasarray( | |
+ return Util::extractattributeasarray( | |
$response['creditCardTransactions'], | |
'transaction' | |
); | |
@@ -317,7 +330,7 @@ | |
* void a transaction by id | |
* | |
* @param string $id transaction id | |
- * @return object Braintree_Result_Successful|Braintree_Result_Error | |
+ * @return Result\Successful|Result\Error | |
*/ | |
public function void($transactionId) | |
{ | |
@@ -333,30 +346,43 @@ | |
public function voidNoValidate($transactionId) | |
{ | |
$result = $this->void($transactionId); | |
- return Braintree_Util::returnObjectOrThrowException(__CLASS__, $result); | |
+ return Util::returnObjectOrThrowException(__CLASS__, $result); | |
} | |
- public function submitForSettlement($transactionId, $amount = null) | |
+ public function submitForSettlement($transactionId, $amount = null, $attribs = []) | |
{ | |
$this->_validateId($transactionId); | |
+ Util::verifyKeys(self::submitForSettlementSignature(), $attribs); | |
+ $attribs['amount'] = $amount; | |
$path = $this->_config->merchantPath() . '/transactions/'. $transactionId . '/submit_for_settlement'; | |
- $response = $this->_http->put($path, array('transaction' => array('amount' => $amount))); | |
+ $response = $this->_http->put($path, ['transaction' => $attribs]); | |
return $this->_verifyGatewayResponse($response); | |
} | |
- public function submitForSettlementNoValidate($transactionId, $amount = null) | |
+ public function submitForSettlementNoValidate($transactionId, $amount = null, $attribs = []) | |
{ | |
- $result = $this->submitForSettlement($transactionId, $amount); | |
- return Braintree_Util::returnObjectOrThrowException(__CLASS__, $result); | |
+ $result = $this->submitForSettlement($transactionId, $amount, $attribs); | |
+ return Util::returnObjectOrThrowException(__CLASS__, $result); | |
} | |
+ public function submitForPartialSettlement($transactionId, $amount, $attribs = []) | |
+ { | |
+ $this->_validateId($transactionId); | |
+ Util::verifyKeys(self::submitForSettlementSignature(), $attribs); | |
+ $attribs['amount'] = $amount; | |
+ | |
+ $path = $this->_config->merchantPath() . '/transactions/'. $transactionId . '/submit_for_partial_settlement'; | |
+ $response = $this->_http->post($path, ['transaction' => $attribs]); | |
+ return $this->_verifyGatewayResponse($response); | |
+ } | |
+ | |
public function holdInEscrow($transactionId) | |
{ | |
$this->_validateId($transactionId); | |
$path = $this->_config->merchantPath() . '/transactions/' . $transactionId . '/hold_in_escrow'; | |
- $response = $this->_http->put($path, array()); | |
+ $response = $this->_http->put($path, []); | |
return $this->_verifyGatewayResponse($response); | |
} | |
@@ -365,7 +391,7 @@ | |
$this->_validateId($transactionId); | |
$path = $this->_config->merchantPath() . '/transactions/' . $transactionId . '/release_from_escrow'; | |
- $response = $this->_http->put($path, array()); | |
+ $response = $this->_http->put($path, []); | |
return $this->_verifyGatewayResponse($response); | |
} | |
@@ -374,7 +400,7 @@ | |
$this->_validateId($transactionId); | |
$path = $this->_config->merchantPath() . '/transactions/' . $transactionId . '/cancel_release'; | |
- $response = $this->_http->put($path, array()); | |
+ $response = $this->_http->put($path, []); | |
return $this->_verifyGatewayResponse($response); | |
} | |
@@ -382,7 +408,7 @@ | |
{ | |
self::_validateId($transactionId); | |
- $params = array('transaction' => array('amount' => $amount)); | |
+ $params = ['transaction' => ['amount' => $amount]]; | |
$path = $this->_config->merchantPath() . '/transactions/' . $transactionId . '/refund'; | |
$response = $this->_http->post($path, $params); | |
return $this->_verifyGatewayResponse($response); | |
@@ -423,33 +449,33 @@ | |
} | |
} | |
- | |
/** | |
* generic method for validating incoming gateway responses | |
* | |
- * creates a new Braintree_Transaction object and encapsulates | |
- * it inside a Braintree_Result_Successful object, or | |
- * encapsulates a Braintree_Errors object inside a Result_Error | |
+ * creates a new Transaction object and encapsulates | |
+ * it inside a Result\Successful object, or | |
+ * encapsulates a Errors object inside a Result\Error | |
* alternatively, throws an Unexpected exception if the response is invalid. | |
* | |
* @ignore | |
* @param array $response gateway response values | |
- * @return object Result_Successful or Result_Error | |
- * @throws Braintree_Exception_Unexpected | |
+ * @return Result\Successful|Result\Error | |
+ * @throws Exception\Unexpected | |
*/ | |
private function _verifyGatewayResponse($response) | |
{ | |
if (isset($response['transaction'])) { | |
- // return a populated instance of Braintree_Transaction | |
- return new Braintree_Result_Successful( | |
- Braintree_Transaction::factory($response['transaction']) | |
+ // return a populated instance of Transaction | |
+ return new Result\Successful( | |
+ Transaction::factory($response['transaction']) | |
); | |
} else if (isset($response['apiErrorResponse'])) { | |
- return new Braintree_Result_Error($response['apiErrorResponse']); | |
+ return new Result\Error($response['apiErrorResponse']); | |
} else { | |
- throw new Braintree_Exception_Unexpected( | |
+ throw new Exception\Unexpected( | |
"Expected transaction or apiErrorResponse" | |
); | |
} | |
} | |
} | |
+class_alias('Braintree\TransactionGateway', 'Braintree_TransactionGateway'); | |
Index: braintree_sdk/lib/Braintree/TransactionSearch.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/TransactionSearch.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/TransactionSearch.php (working copy) | |
@@ -1,130 +1,129 @@ | |
<?php | |
-class Braintree_TransactionSearch | |
+namespace Braintree; | |
+ | |
+class TransactionSearch | |
{ | |
- static function amount() { return new Braintree_RangeNode("amount"); } | |
- static function authorizationExpiredAt() { return new Braintree_RangeNode("authorizationExpiredAt"); } | |
- static function authorizedAt() { return new Braintree_RangeNode("authorizedAt"); } | |
- static function billingCompany() { return new Braintree_TextNode('billing_company'); } | |
- static function billingCountryName() { return new Braintree_TextNode('billing_country_name'); } | |
- static function billingExtendedAddress() { return new Braintree_TextNode('billing_extended_address'); } | |
- static function billingFirstName() { return new Braintree_TextNode('billing_first_name'); } | |
- static function billingLastName() { return new Braintree_TextNode('billing_last_name'); } | |
- static function billingLocality() { return new Braintree_TextNode('billing_locality'); } | |
- static function billingPostalCode() { return new Braintree_TextNode('billing_postal_code'); } | |
- static function billingRegion() { return new Braintree_TextNode('billing_region'); } | |
- static function billingStreetAddress() { return new Braintree_TextNode('billing_street_address'); } | |
- static function createdAt() { return new Braintree_RangeNode("createdAt"); } | |
- static function creditCardCardholderName() { return new Braintree_TextNode('credit_card_cardholderName'); } | |
- static function creditCardExpirationDate() { return new Braintree_EqualityNode('credit_card_expiration_date'); } | |
- static function creditCardNumber() { return new Braintree_PartialMatchNode('credit_card_number'); } | |
- static function creditCardUniqueIdentifier() { return new Braintree_TextNode('credit_card_unique_identifier'); } | |
- static function customerCompany() { return new Braintree_TextNode('customer_company'); } | |
- static function customerEmail() { return new Braintree_TextNode('customer_email'); } | |
- static function customerFax() { return new Braintree_TextNode('customer_fax'); } | |
- static function customerFirstName() { return new Braintree_TextNode('customer_first_name'); } | |
- static function customerId() { return new Braintree_TextNode('customer_id'); } | |
- static function customerLastName() { return new Braintree_TextNode('customer_last_name'); } | |
- static function customerPhone() { return new Braintree_TextNode('customer_phone'); } | |
- static function customerWebsite() { return new Braintree_TextNode('customer_website'); } | |
- static function disbursementDate() { return new Braintree_RangeNode("disbursementDate"); } | |
- static function disputeDate() { return new Braintree_RangeNode("disputeDate"); } | |
- static function europeBankAccountIban() { return new Braintree_TextNode("europeBankAccountIban"); } | |
- static function failedAt() { return new Braintree_RangeNode("failedAt"); } | |
- static function gatewayRejectedAt() { return new Braintree_RangeNode("gatewayRejectedAt"); } | |
- static function id() { return new Braintree_TextNode('id'); } | |
- static function ids() { return new Braintree_MultipleValueNode('ids'); } | |
- static function merchantAccountId() { return new Braintree_MultipleValueNode("merchant_account_id"); } | |
- static function orderId() { return new Braintree_TextNode('order_id'); } | |
- static function paymentInstrumentType() { return new Braintree_MultipleValueNode('paymentInstrumentType'); } | |
- static function paymentMethodToken() { return new Braintree_TextNode('payment_method_token'); } | |
- static function paypalAuthorizationId() { return new Braintree_TextNode('paypal_authorization_id'); } | |
- static function paypalPayerEmail() { return new Braintree_TextNode('paypal_payer_email'); } | |
- static function paypalPaymentId() { return new Braintree_TextNode('paypal_payment_id'); } | |
- static function processorAuthorizationCode() { return new Braintree_TextNode('processor_authorization_code'); } | |
- static function processorDeclinedAt() { return new Braintree_RangeNode("processorDeclinedAt"); } | |
- static function refund() { return new Braintree_KeyValueNode("refund"); } | |
- static function settledAt() { return new Braintree_RangeNode("settledAt"); } | |
- static function settlementBatchId() { return new Braintree_TextNode('settlement_batch_id'); } | |
- static function shippingCompany() { return new Braintree_TextNode('shipping_company'); } | |
- static function shippingCountryName() { return new Braintree_TextNode('shipping_country_name'); } | |
- static function shippingExtendedAddress() { return new Braintree_TextNode('shipping_extended_address'); } | |
- static function shippingFirstName() { return new Braintree_TextNode('shipping_first_name'); } | |
- static function shippingLastName() { return new Braintree_TextNode('shipping_last_name'); } | |
- static function shippingLocality() { return new Braintree_TextNode('shipping_locality'); } | |
- static function shippingPostalCode() { return new Braintree_TextNode('shipping_postal_code'); } | |
- static function shippingRegion() { return new Braintree_TextNode('shipping_region'); } | |
- static function shippingStreetAddress() { return new Braintree_TextNode('shipping_street_address'); } | |
- static function submittedForSettlementAt() { return new Braintree_RangeNode("submittedForSettlementAt"); } | |
- static function user() { return new Braintree_MultipleValueNode('user'); } | |
- static function voidedAt() { return new Braintree_RangeNode("voidedAt"); } | |
+ public static function amount() { return new RangeNode("amount"); } | |
+ public static function authorizationExpiredAt() { return new RangeNode("authorizationExpiredAt"); } | |
+ public static function authorizedAt() { return new RangeNode("authorizedAt"); } | |
+ public static function billingCompany() { return new TextNode('billing_company'); } | |
+ public static function billingCountryName() { return new TextNode('billing_country_name'); } | |
+ public static function billingExtendedAddress() { return new TextNode('billing_extended_address'); } | |
+ public static function billingFirstName() { return new TextNode('billing_first_name'); } | |
+ public static function billingLastName() { return new TextNode('billing_last_name'); } | |
+ public static function billingLocality() { return new TextNode('billing_locality'); } | |
+ public static function billingPostalCode() { return new TextNode('billing_postal_code'); } | |
+ public static function billingRegion() { return new TextNode('billing_region'); } | |
+ public static function billingStreetAddress() { return new TextNode('billing_street_address'); } | |
+ public static function createdAt() { return new RangeNode("createdAt"); } | |
+ public static function creditCardCardholderName() { return new TextNode('credit_card_cardholderName'); } | |
+ public static function creditCardExpirationDate() { return new EqualityNode('credit_card_expiration_date'); } | |
+ public static function creditCardNumber() { return new PartialMatchNode('credit_card_number'); } | |
+ public static function creditCardUniqueIdentifier() { return new TextNode('credit_card_unique_identifier'); } | |
+ public static function customerCompany() { return new TextNode('customer_company'); } | |
+ public static function customerEmail() { return new TextNode('customer_email'); } | |
+ public static function customerFax() { return new TextNode('customer_fax'); } | |
+ public static function customerFirstName() { return new TextNode('customer_first_name'); } | |
+ public static function customerId() { return new TextNode('customer_id'); } | |
+ public static function customerLastName() { return new TextNode('customer_last_name'); } | |
+ public static function customerPhone() { return new TextNode('customer_phone'); } | |
+ public static function customerWebsite() { return new TextNode('customer_website'); } | |
+ public static function disbursementDate() { return new RangeNode("disbursementDate"); } | |
+ public static function disputeDate() { return new RangeNode("disputeDate"); } | |
+ public static function europeBankAccountIban() { return new TextNode("europeBankAccountIban"); } | |
+ public static function failedAt() { return new RangeNode("failedAt"); } | |
+ public static function gatewayRejectedAt() { return new RangeNode("gatewayRejectedAt"); } | |
+ public static function id() { return new TextNode('id'); } | |
+ public static function ids() { return new MultipleValueNode('ids'); } | |
+ public static function merchantAccountId() { return new MultipleValueNode("merchant_account_id"); } | |
+ public static function orderId() { return new TextNode('order_id'); } | |
+ public static function paymentInstrumentType() { return new MultipleValueNode('paymentInstrumentType'); } | |
+ public static function paymentMethodToken() { return new TextNode('payment_method_token'); } | |
+ public static function paypalAuthorizationId() { return new TextNode('paypal_authorization_id'); } | |
+ public static function paypalPayerEmail() { return new TextNode('paypal_payer_email'); } | |
+ public static function paypalPaymentId() { return new TextNode('paypal_payment_id'); } | |
+ public static function processorAuthorizationCode() { return new TextNode('processor_authorization_code'); } | |
+ public static function processorDeclinedAt() { return new RangeNode("processorDeclinedAt"); } | |
+ public static function refund() { return new KeyValueNode("refund"); } | |
+ public static function settledAt() { return new RangeNode("settledAt"); } | |
+ public static function settlementBatchId() { return new TextNode('settlement_batch_id'); } | |
+ public static function shippingCompany() { return new TextNode('shipping_company'); } | |
+ public static function shippingCountryName() { return new TextNode('shipping_country_name'); } | |
+ public static function shippingExtendedAddress() { return new TextNode('shipping_extended_address'); } | |
+ public static function shippingFirstName() { return new TextNode('shipping_first_name'); } | |
+ public static function shippingLastName() { return new TextNode('shipping_last_name'); } | |
+ public static function shippingLocality() { return new TextNode('shipping_locality'); } | |
+ public static function shippingPostalCode() { return new TextNode('shipping_postal_code'); } | |
+ public static function shippingRegion() { return new TextNode('shipping_region'); } | |
+ public static function shippingStreetAddress() { return new TextNode('shipping_street_address'); } | |
+ public static function submittedForSettlementAt() { return new RangeNode("submittedForSettlementAt"); } | |
+ public static function user() { return new MultipleValueNode('user'); } | |
+ public static function voidedAt() { return new RangeNode("voidedAt"); } | |
- static function createdUsing() | |
+ public static function createdUsing() | |
{ | |
- return new Braintree_MultipleValueNode("created_using", array( | |
- Braintree_Transaction::FULL_INFORMATION, | |
- Braintree_Transaction::TOKEN | |
- )); | |
+ return new MultipleValueNode('created_using', [ | |
+ Transaction::FULL_INFORMATION, | |
+ Transaction::TOKEN | |
+ ]); | |
} | |
- static function creditCardCardType() | |
+ public static function creditCardCardType() | |
{ | |
- return new Braintree_MultipleValueNode("credit_card_card_type", array( | |
- Braintree_CreditCard::AMEX, | |
- Braintree_CreditCard::CARTE_BLANCHE, | |
- Braintree_CreditCard::CHINA_UNION_PAY, | |
- Braintree_CreditCard::DINERS_CLUB_INTERNATIONAL, | |
- Braintree_CreditCard::DISCOVER, | |
- Braintree_CreditCard::JCB, | |
- Braintree_CreditCard::LASER, | |
- Braintree_CreditCard::MAESTRO, | |
- Braintree_CreditCard::MASTER_CARD, | |
- Braintree_CreditCard::SOLO, | |
- Braintree_CreditCard::SWITCH_TYPE, | |
- Braintree_CreditCard::VISA, | |
- Braintree_CreditCard::UNKNOWN | |
- )); | |
+ return new MultipleValueNode('credit_card_card_type', [ | |
+ CreditCard::AMEX, | |
+ CreditCard::CARTE_BLANCHE, | |
+ CreditCard::CHINA_UNION_PAY, | |
+ CreditCard::DINERS_CLUB_INTERNATIONAL, | |
+ CreditCard::DISCOVER, | |
+ CreditCard::JCB, | |
+ CreditCard::LASER, | |
+ CreditCard::MAESTRO, | |
+ CreditCard::MASTER_CARD, | |
+ CreditCard::SOLO, | |
+ CreditCard::SWITCH_TYPE, | |
+ CreditCard::VISA, | |
+ CreditCard::UNKNOWN | |
+ ]); | |
} | |
- static function creditCardCustomerLocation() | |
+ public static function creditCardCustomerLocation() | |
{ | |
- return new Braintree_MultipleValueNode("credit_card_customer_location", array( | |
- Braintree_CreditCard::INTERNATIONAL, | |
- Braintree_CreditCard::US | |
- )); | |
+ return new MultipleValueNode('credit_card_customer_location', [ | |
+ CreditCard::INTERNATIONAL, | |
+ CreditCard::US | |
+ ]); | |
} | |
- static function source() | |
+ public static function source() | |
{ | |
- return new Braintree_MultipleValueNode("source", array( | |
- Braintree_Transaction::API, | |
- Braintree_Transaction::CONTROL_PANEL, | |
- Braintree_Transaction::RECURRING, | |
- )); | |
+ return new MultipleValueNode('source', []); | |
} | |
- static function status() | |
+ public static function status() | |
{ | |
- return new Braintree_MultipleValueNode("status", array( | |
- Braintree_Transaction::AUTHORIZATION_EXPIRED, | |
- Braintree_Transaction::AUTHORIZING, | |
- Braintree_Transaction::AUTHORIZED, | |
- Braintree_Transaction::GATEWAY_REJECTED, | |
- Braintree_Transaction::FAILED, | |
- Braintree_Transaction::PROCESSOR_DECLINED, | |
- Braintree_Transaction::SETTLED, | |
- Braintree_Transaction::SETTLING, | |
- Braintree_Transaction::SUBMITTED_FOR_SETTLEMENT, | |
- Braintree_Transaction::VOIDED, | |
- Braintree_Transaction::SETTLEMENT_DECLINED, | |
- Braintree_Transaction::SETTLEMENT_PENDING | |
- )); | |
+ return new MultipleValueNode('status', [ | |
+ Transaction::AUTHORIZATION_EXPIRED, | |
+ Transaction::AUTHORIZING, | |
+ Transaction::AUTHORIZED, | |
+ Transaction::GATEWAY_REJECTED, | |
+ Transaction::FAILED, | |
+ Transaction::PROCESSOR_DECLINED, | |
+ Transaction::SETTLED, | |
+ Transaction::SETTLING, | |
+ Transaction::SUBMITTED_FOR_SETTLEMENT, | |
+ Transaction::VOIDED, | |
+ Transaction::SETTLEMENT_DECLINED, | |
+ Transaction::SETTLEMENT_PENDING | |
+ ]); | |
} | |
- static function type() | |
+ public static function type() | |
{ | |
- return new Braintree_MultipleValueNode("type", array( | |
- Braintree_Transaction::SALE, | |
- Braintree_Transaction::CREDIT | |
- )); | |
+ return new MultipleValueNode('type', [ | |
+ Transaction::SALE, | |
+ Transaction::CREDIT | |
+ ]); | |
} | |
} | |
+class_alias('Braintree\TransactionSearch', 'Braintree_TransactionSearch'); | |
Index: braintree_sdk/lib/Braintree/TransparentRedirect.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/TransparentRedirect.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/TransparentRedirect.php (working copy) | |
@@ -1,9 +1,9 @@ | |
<?php | |
+namespace Braintree; | |
- | |
/** | |
* Braintree Transparent Redirect module | |
- * Static class providing methods to build Transparent Redirect urls | |
+ * Static class providing methods to build Transparent Redirect urls. | |
* | |
* The TransparentRedirect module provides methods to build the tr_data param | |
* that must be submitted when using the transparent redirect API. | |
@@ -14,7 +14,7 @@ | |
* user the action is complete. | |
* | |
* <code> | |
- * $trData = Braintree_TransparentRedirect::createCustomerData(array( | |
+ * $trData = TransparentRedirect::createCustomerData(array( | |
* 'redirectUrl => 'http://example.com/redirect_back_to_merchant_site', | |
* )); | |
* </code> | |
@@ -25,7 +25,7 @@ | |
* amount, include the amount in the trData. | |
* | |
* <code> | |
- * $trData = Braintree_TransparentRedirect::transactionData(array( | |
+ * $trData = TransparentRedirect::transactionData(array( | |
* 'redirectUrl' => 'http://example.com/complete_transaction', | |
* 'transaction' => array('amount' => '100.00'), | |
* )); | |
@@ -34,9 +34,9 @@ | |
* | |
* @package Braintree | |
* @category Resources | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_TransparentRedirect | |
+class TransparentRedirect | |
{ | |
// Request Kinds | |
const CREATE_TRANSACTION = 'create_transaction'; | |
@@ -48,7 +48,7 @@ | |
/** | |
* @ignore | |
* don't permit an explicit call of the constructor! | |
- * (like $t = new Braintree_TransparentRedirect()) | |
+ * (like $t = new TransparentRedirect()) | |
*/ | |
protected function __construct() | |
{ | |
@@ -60,41 +60,42 @@ | |
public static function confirm($queryString) | |
{ | |
- return Braintree_Configuration::gateway()->transparentRedirect()->confirm($queryString); | |
+ return Configuration::gateway()->transparentRedirect()->confirm($queryString); | |
} | |
public static function createCreditCardData($params) | |
{ | |
- return Braintree_Configuration::gateway()->transparentRedirect()->createCreditCardData($params); | |
+ return Configuration::gateway()->transparentRedirect()->createCreditCardData($params); | |
} | |
public static function createCustomerData($params) | |
{ | |
- return Braintree_Configuration::gateway()->transparentRedirect()->createCustomerData($params); | |
+ return Configuration::gateway()->transparentRedirect()->createCustomerData($params); | |
} | |
public static function url() | |
{ | |
- return Braintree_Configuration::gateway()->transparentRedirect()->url(); | |
+ return Configuration::gateway()->transparentRedirect()->url(); | |
} | |
public static function transactionData($params) | |
{ | |
- return Braintree_Configuration::gateway()->transparentRedirect()->transactionData($params); | |
+ return Configuration::gateway()->transparentRedirect()->transactionData($params); | |
} | |
public static function updateCreditCardData($params) | |
{ | |
- return Braintree_Configuration::gateway()->transparentRedirect()->updateCreditCardData($params); | |
+ return Configuration::gateway()->transparentRedirect()->updateCreditCardData($params); | |
} | |
public static function updateCustomerData($params) | |
{ | |
- return Braintree_Configuration::gateway()->transparentRedirect()->updateCustomerData($params); | |
+ return Configuration::gateway()->transparentRedirect()->updateCustomerData($params); | |
} | |
public static function parseAndValidateQueryString($queryString) | |
{ | |
- return Braintree_Configuration::gateway()->transparentRedirect()->parseAndValidateQueryString($queryString); | |
+ return Configuration::gateway()->transparentRedirect()->parseAndValidateQueryString($queryString); | |
} | |
} | |
+class_alias('Braintree\TransparentRedirect', 'Braintree_TransparentRedirect'); | |
Index: braintree_sdk/lib/Braintree/TransparentRedirectGateway.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/TransparentRedirectGateway.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/TransparentRedirectGateway.php (working copy) | |
@@ -1,13 +1,19 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
+use InvalidArgumentException; | |
+use DateTime; | |
+use DateTimeZone; | |
+ | |
/** | |
* Braintree Transparent Redirect Gateway module | |
* Static class providing methods to build Transparent Redirect urls | |
* | |
* @package Braintree | |
* @category Resources | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_TransparentRedirectGateway | |
+class TransparentRedirectGateway | |
{ | |
private $_gateway; | |
private $_config; | |
@@ -37,44 +43,44 @@ | |
public static function init() | |
{ | |
- self::$_createCustomerSignature = array( | |
+ self::$_createCustomerSignature = [ | |
self::$_transparentRedirectKeys, | |
- array('customer' => Braintree_CustomerGateway::createSignature()), | |
- ); | |
- self::$_updateCustomerSignature = array( | |
+ ['customer' => CustomerGateway::createSignature()], | |
+ ]; | |
+ self::$_updateCustomerSignature = [ | |
self::$_transparentRedirectKeys, | |
'customerId', | |
- array('customer' => Braintree_CustomerGateway::updateSignature()), | |
- ); | |
- self::$_transactionSignature = array( | |
+ ['customer' => CustomerGateway::updateSignature()], | |
+ ]; | |
+ self::$_transactionSignature = [ | |
self::$_transparentRedirectKeys, | |
- array('transaction' => Braintree_TransactionGateway::createSignature()), | |
- ); | |
- self::$_createCreditCardSignature = array( | |
+ ['transaction' => TransactionGateway::createSignature()], | |
+ ]; | |
+ self::$_createCreditCardSignature = [ | |
self::$_transparentRedirectKeys, | |
- array('creditCard' => Braintree_CreditCardGateway::createSignature()), | |
- ); | |
- self::$_updateCreditCardSignature = array( | |
+ ['creditCard' => CreditCardGateway::createSignature()], | |
+ ]; | |
+ self::$_updateCreditCardSignature = [ | |
self::$_transparentRedirectKeys, | |
'paymentMethodToken', | |
- array('creditCard' => Braintree_CreditCardGateway::updateSignature()), | |
- ); | |
+ ['creditCard' => CreditCardGateway::updateSignature()], | |
+ ]; | |
} | |
public function confirm($queryString) | |
{ | |
- $params = Braintree_TransparentRedirect::parseAndValidateQueryString( | |
+ $params = TransparentRedirect::parseAndValidateQueryString( | |
$queryString | |
); | |
- $confirmationKlasses = array( | |
- Braintree_TransparentRedirect::CREATE_TRANSACTION => 'Braintree_TransactionGateway', | |
- Braintree_TransparentRedirect::CREATE_CUSTOMER => 'Braintree_CustomerGateway', | |
- Braintree_TransparentRedirect::UPDATE_CUSTOMER => 'Braintree_CustomerGateway', | |
- Braintree_TransparentRedirect::CREATE_PAYMENT_METHOD => 'Braintree_CreditCardGateway', | |
- Braintree_TransparentRedirect::UPDATE_PAYMENT_METHOD => 'Braintree_CreditCardGateway' | |
- ); | |
+ $confirmationKlasses = [ | |
+ TransparentRedirect::CREATE_TRANSACTION => 'Braintree\TransactionGateway', | |
+ TransparentRedirect::CREATE_CUSTOMER => 'Braintree\CustomerGateway', | |
+ TransparentRedirect::UPDATE_CUSTOMER => 'Braintree\CustomerGateway', | |
+ TransparentRedirect::CREATE_PAYMENT_METHOD => 'Braintree\CreditCardGateway', | |
+ TransparentRedirect::UPDATE_PAYMENT_METHOD => 'Braintree\CreditCardGateway', | |
+ ]; | |
$confirmationGateway = new $confirmationKlasses[$params["kind"]]($this->_gateway); | |
- return $confirmationGateway->_doCreate('/transparent_redirect_requests/' . $params['id'] . '/confirm', array()); | |
+ return $confirmationGateway->_doCreate('/transparent_redirect_requests/' . $params['id'] . '/confirm', []); | |
} | |
/** | |
@@ -84,11 +90,11 @@ | |
*/ | |
public function createCreditCardData($params) | |
{ | |
- Braintree_Util::verifyKeys( | |
+ Util::verifyKeys( | |
self::$_createCreditCardSignature, | |
$params | |
); | |
- $params["kind"] = Braintree_TransparentRedirect::CREATE_PAYMENT_METHOD; | |
+ $params["kind"] = TransparentRedirect::CREATE_PAYMENT_METHOD; | |
return $this->_data($params); | |
} | |
@@ -99,18 +105,18 @@ | |
*/ | |
public function createCustomerData($params) | |
{ | |
- Braintree_Util::verifyKeys( | |
+ Util::verifyKeys( | |
self::$_createCustomerSignature, | |
$params | |
); | |
- $params["kind"] = Braintree_TransparentRedirect::CREATE_CUSTOMER; | |
+ $params["kind"] = TransparentRedirect::CREATE_CUSTOMER; | |
return $this->_data($params); | |
} | |
public function url() | |
{ | |
- return $this->_config->baseUrl() . $this->_config->merchantPath() . "/transparent_redirect_requests"; | |
+ return $this->_config->baseUrl() . $this->_config->merchantPath() . '/transparent_redirect_requests'; | |
} | |
/** | |
@@ -120,15 +126,15 @@ | |
*/ | |
public function transactionData($params) | |
{ | |
- Braintree_Util::verifyKeys( | |
+ Util::verifyKeys( | |
self::$_transactionSignature, | |
$params | |
); | |
- $params["kind"] = Braintree_TransparentRedirect::CREATE_TRANSACTION; | |
+ $params["kind"] = TransparentRedirect::CREATE_TRANSACTION; | |
$transactionType = isset($params['transaction']['type']) ? | |
$params['transaction']['type'] : | |
null; | |
- if ($transactionType != Braintree_Transaction::SALE && $transactionType != Braintree_Transaction::CREDIT) { | |
+ if ($transactionType != Transaction::SALE && $transactionType != Transaction::CREDIT) { | |
throw new InvalidArgumentException( | |
'expected transaction[type] of sale or credit, was: ' . | |
$transactionType | |
@@ -144,7 +150,7 @@ | |
* The paymentMethodToken of the credit card to update is required. | |
* | |
* <code> | |
- * $trData = Braintree_TransparentRedirect::updateCreditCardData(array( | |
+ * $trData = TransparentRedirect::updateCreditCardData(array( | |
* 'redirectUrl' => 'http://example.com/redirect_here', | |
* 'paymentMethodToken' => 'token123', | |
* )); | |
@@ -155,7 +161,7 @@ | |
*/ | |
public function updateCreditCardData($params) | |
{ | |
- Braintree_Util::verifyKeys( | |
+ Util::verifyKeys( | |
self::$_updateCreditCardSignature, | |
$params | |
); | |
@@ -164,7 +170,7 @@ | |
'expected params to contain paymentMethodToken.' | |
); | |
} | |
- $params["kind"] = Braintree_TransparentRedirect::UPDATE_PAYMENT_METHOD; | |
+ $params["kind"] = TransparentRedirect::UPDATE_PAYMENT_METHOD; | |
return $this->_data($params); | |
} | |
@@ -174,7 +180,7 @@ | |
* The customerId of the customer to update is required. | |
* | |
* <code> | |
- * $trData = Braintree_TransparentRedirect::updateCustomerData(array( | |
+ * $trData = TransparentRedirect::updateCustomerData(array( | |
* 'redirectUrl' => 'http://example.com/redirect_here', | |
* 'customerId' => 'customer123', | |
* )); | |
@@ -185,7 +191,7 @@ | |
*/ | |
public function updateCustomerData($params) | |
{ | |
- Braintree_Util::verifyKeys( | |
+ Util::verifyKeys( | |
self::$_updateCustomerSignature, | |
$params | |
); | |
@@ -194,7 +200,7 @@ | |
'expected params to contain customerId of customer to update' | |
); | |
} | |
- $params["kind"] = Braintree_TransparentRedirect::UPDATE_CUSTOMER; | |
+ $params["kind"] = TransparentRedirect::UPDATE_CUSTOMER; | |
return $this->_data($params); | |
} | |
@@ -204,7 +210,7 @@ | |
parse_str($queryString, $params); | |
// remove the hash | |
$queryStringWithoutHash = null; | |
- if(preg_match('/^(.*)&hash=[a-f0-9]+$/', $queryString, $match)) { | |
+ if (preg_match('/^(.*)&hash=[a-f0-9]+$/', $queryString, $match)) { | |
$queryStringWithoutHash = $match[1]; | |
} | |
@@ -213,14 +219,14 @@ | |
if(array_key_exists('bt_message', $params)) { | |
$message = $params['bt_message']; | |
} | |
- Braintree_Util::throwStatusCodeException($params['http_status'], $message); | |
+ Util::throwStatusCodeException(isset($params['http_status']) ? $params['http_status'] : null, $message); | |
} | |
// recreate the hash and compare it | |
- if($this->_hash($queryStringWithoutHash) == $params['hash']) { | |
+ if ($this->_hash($queryStringWithoutHash) == $params['hash']) { | |
return $params; | |
} else { | |
- throw new Braintree_Exception_ForgedQueryString(); | |
+ throw new Exception\ForgedQueryString(); | |
} | |
} | |
@@ -239,17 +245,17 @@ | |
$params = $this->_underscoreKeys($params); | |
$now = new DateTime('now', new DateTimeZone('UTC')); | |
$trDataParams = array_merge($params, | |
- array( | |
- 'api_version' => Braintree_Configuration::API_VERSION, | |
+ [ | |
+ 'api_version' => Configuration::API_VERSION, | |
'public_key' => $this->_config->publicKey(), | |
'time' => $now->format('YmdHis'), | |
- ) | |
+ ] | |
); | |
ksort($trDataParams); | |
$urlEncodedData = http_build_query($trDataParams, null, "&"); | |
- $signatureService = new Braintree_SignatureService( | |
+ $signatureService = new SignatureService( | |
$this->_config->privateKey(), | |
- "Braintree_Digest::hexDigestSha1" | |
+ "Braintree\Digest::hexDigestSha1" | |
); | |
return $signatureService->sign($urlEncodedData); | |
} | |
@@ -258,7 +264,7 @@ | |
{ | |
foreach($array as $key=>$value) | |
{ | |
- $newKey = Braintree_Util::camelCaseToDelimiter($key, '_'); | |
+ $newKey = Util::camelCaseToDelimiter($key, '_'); | |
unset($array[$key]); | |
if (is_array($value)) | |
{ | |
@@ -277,7 +283,8 @@ | |
*/ | |
private function _hash($string) | |
{ | |
- return Braintree_Digest::hexDigestSha1($this->_config->privateKey(), $string); | |
+ return Digest::hexDigestSha1($this->_config->privateKey(), $string); | |
} | |
} | |
-Braintree_TransparentRedirectGateway::init(); | |
+TransparentRedirectGateway::init(); | |
+class_alias('Braintree\TransparentRedirectGateway', 'Braintree_TransparentRedirectGateway'); | |
Index: braintree_sdk/lib/Braintree/UnknownPaymentMethod.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/UnknownPaymentMethod.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/UnknownPaymentMethod.php (working copy) | |
@@ -1,10 +1,12 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
/** | |
* Braintree UnknownPaymentMethod module | |
* | |
* @package Braintree | |
* @category Resources | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
/** | |
@@ -15,21 +17,21 @@ | |
* | |
* @package Braintree | |
* @category Resources | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
* | |
* @property-read string $token | |
* @property-read string $imageUrl | |
*/ | |
-class Braintree_UnknownPaymentMethod extends Braintree_Base | |
+class UnknownPaymentMethod extends Base | |
{ | |
/** | |
- * factory method: returns an instance of Braintree_UnknownPaymentMethod | |
+ * factory method: returns an instance of UnknownPaymentMethod | |
* to the requesting method, with populated properties | |
* | |
* @ignore | |
- * @return object instance of Braintree_UnknownPaymentMethod | |
+ * @return UnknownPaymentMethod | |
*/ | |
public static function factory($attributes) | |
{ | |
@@ -56,7 +58,7 @@ | |
* | |
* @access protected | |
* @param array $unknownPaymentMethodAttribs array of unknownPaymentMethod data | |
- * @return none | |
+ * @return void | |
*/ | |
protected function _initialize($unknownPaymentMethodAttribs) | |
{ | |
@@ -66,3 +68,4 @@ | |
} | |
} | |
+class_alias('Braintree\UnknownPaymentMethod', 'Braintree_UnknownPaymentMethod'); | |
Index: braintree_sdk/lib/Braintree/Util.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Util.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Util.php (working copy) | |
@@ -1,28 +1,33 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
+use DateTime; | |
+use InvalidArgumentException; | |
+ | |
/** | |
* Braintree Utility methods | |
* PHP version 5 | |
* | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_Util | |
+class Util | |
{ | |
/** | |
* extracts an attribute and returns an array of objects | |
* | |
* extracts the requested element from an array, and converts the contents | |
- * of its child arrays to objects of type Braintree_$attributeName, or returns | |
+ * of its child arrays to objects of type $attributeName, or returns | |
* an array with a single element containing the value of that array element | |
* | |
- * @param array $attribArray attributes from a search response | |
+ * @param array $attribArray attributes from a search response | |
* @param string $attributeName indicates which element of the passed array to extract | |
- * @return array array of Braintree_$attributeName objects, or a single element array | |
+ * @return array array of $attributeName objects, or a single element array | |
*/ | |
- public static function extractAttributeAsArray(& $attribArray, $attributeName) | |
+ public static function extractAttributeAsArray(&$attribArray, $attributeName) | |
{ | |
if(!isset($attribArray[$attributeName])): | |
- return array(); | |
+ return []; | |
endif; | |
// get what should be an array from the passed array | |
@@ -33,7 +38,7 @@ | |
// create an object from the data in each element | |
$objectArray = array_map($classFactory, $data); | |
else: | |
- return array($data); | |
+ return [$data]; | |
endif; | |
unset($attribArray[$attributeName]); | |
@@ -42,32 +47,33 @@ | |
/** | |
* throws an exception based on the type of error | |
* @param string $statusCode HTTP status code to throw exception from | |
- * @throws Braintree_Exception multiple types depending on the error | |
- * | |
+ * @param null|string $message | |
+ * @throws Exception multiple types depending on the error | |
+ * @return void | |
*/ | |
public static function throwStatusCodeException($statusCode, $message=null) | |
{ | |
switch($statusCode) { | |
case 401: | |
- throw new Braintree_Exception_Authentication(); | |
+ throw new Exception\Authentication(); | |
break; | |
case 403: | |
- throw new Braintree_Exception_Authorization($message); | |
+ throw new Exception\Authorization($message); | |
break; | |
case 404: | |
- throw new Braintree_Exception_NotFound(); | |
+ throw new Exception\NotFound(); | |
break; | |
case 426: | |
- throw new Braintree_Exception_UpgradeRequired(); | |
+ throw new Exception\UpgradeRequired(); | |
break; | |
case 500: | |
- throw new Braintree_Exception_ServerError(); | |
+ throw new Exception\ServerError(); | |
break; | |
case 503: | |
- throw new Braintree_Exception_DownForMaintenance(); | |
+ throw new Exception\DownForMaintenance(); | |
break; | |
default: | |
- throw new Braintree_Exception_Unexpected('Unexpected HTTP_RESPONSE #'.$statusCode); | |
+ throw new Exception\Unexpected('Unexpected HTTP_RESPONSE #' . $statusCode); | |
break; | |
} | |
} | |
@@ -77,82 +83,108 @@ | |
* @param string $className | |
* @param object $resultObj | |
* @return object returns the passed object if successful | |
- * @throws Braintree_Exception_ValidationsFailed | |
+ * @throws Exception\ValidationsFailed | |
*/ | |
public static function returnObjectOrThrowException($className, $resultObj) | |
{ | |
- $resultObjName = Braintree_Util::cleanClassName($className); | |
+ $resultObjName = self::cleanClassName($className); | |
if ($resultObj->success) { | |
return $resultObj->$resultObjName; | |
} else { | |
- throw new Braintree_Exception_ValidationsFailed(); | |
+ throw new Exception\ValidationsFailed(); | |
} | |
} | |
/** | |
- * removes the Braintree_ header from a classname | |
+ * removes the header from a classname | |
* | |
- * @param string $name Braintree_ClassName | |
- * @return camelCased classname minus Braintree_ header | |
+ * @param string $name ClassName | |
+ * @return camelCased classname minus header | |
*/ | |
public static function cleanClassName($name) | |
{ | |
- $classNamesToResponseKeys = array( | |
- 'CreditCard' => 'creditCard', | |
- 'CreditCardGateway' => 'creditCard', | |
- 'Customer' => 'customer', | |
- 'CustomerGateway' => 'customer', | |
- 'Subscription' => 'subscription', | |
- 'SubscriptionGateway' => 'subscription', | |
- 'Transaction' => 'transaction', | |
- 'TransactionGateway' => 'transaction', | |
- 'CreditCardVerification' => 'verification', | |
- 'CreditCardVerificationGateway' => 'verification', | |
- 'AddOn' => 'addOn', | |
- 'AddOnGateway' => 'addOn', | |
- 'Discount' => 'discount', | |
- 'DiscountGateway' => 'discount', | |
- 'Plan' => 'plan', | |
- 'PlanGateway' => 'plan', | |
- 'Address' => 'address', | |
- 'AddressGateway' => 'address', | |
- 'SettlementBatchSummary' => 'settlementBatchSummary', | |
- 'SettlementBatchSummaryGateway' => 'settlementBatchSummary', | |
- 'Merchant' => 'merchant', | |
- 'MerchantGateway' => 'merchant', | |
- 'MerchantAccount' => 'merchantAccount', | |
- 'MerchantAccountGateway' => 'merchantAccount', | |
- 'OAuthCredentials' => 'credentials', | |
- 'PayPalAccount' => 'paypalAccount', | |
- 'PayPalAccountGateway' => 'paypalAccount' | |
- ); | |
+ $classNamesToResponseKeys = [ | |
+ 'Braintree\CreditCard' => 'creditCard', | |
+ 'Braintree_CreditCard' => 'creditCard', | |
+ 'Braintree\CreditCardGateway' => 'creditCard', | |
+ 'Braintree_CreditCardGateway' => 'creditCard', | |
+ 'Braintree\Customer' => 'customer', | |
+ 'Braintree_Customer' => 'customer', | |
+ 'Braintree\CustomerGateway' => 'customer', | |
+ 'Braintree_CustomerGateway' => 'customer', | |
+ 'Braintree\Subscription' => 'subscription', | |
+ 'Braintree_Subscription' => 'subscription', | |
+ 'Braintree\SubscriptionGateway' => 'subscription', | |
+ 'Braintree_SubscriptionGateway' => 'subscription', | |
+ 'Braintree\Transaction' => 'transaction', | |
+ 'Braintree_Transaction' => 'transaction', | |
+ 'Braintree\TransactionGateway' => 'transaction', | |
+ 'Braintree_TransactionGateway' => 'transaction', | |
+ 'Braintree\CreditCardVerification' => 'verification', | |
+ 'Braintree_CreditCardVerification' => 'verification', | |
+ 'Braintree\CreditCardVerificationGateway' => 'verification', | |
+ 'Braintree_CreditCardVerificationGateway' => 'verification', | |
+ 'Braintree\AddOn' => 'addOn', | |
+ 'Braintree_AddOn' => 'addOn', | |
+ 'Braintree\AddOnGateway' => 'addOn', | |
+ 'Braintree_AddOnGateway' => 'addOn', | |
+ 'Braintree\Discount' => 'discount', | |
+ 'Braintree_Discount' => 'discount', | |
+ 'Braintree\DiscountGateway' => 'discount', | |
+ 'Braintree_DiscountGateway' => 'discount', | |
+ 'Braintree\Plan' => 'plan', | |
+ 'Braintree_Plan' => 'plan', | |
+ 'Braintree\PlanGateway' => 'plan', | |
+ 'Braintree_PlanGateway' => 'plan', | |
+ 'Braintree\Address' => 'address', | |
+ 'Braintree_Address' => 'address', | |
+ 'Braintree\AddressGateway' => 'address', | |
+ 'Braintree_AddressGateway' => 'address', | |
+ 'Braintree\SettlementBatchSummary' => 'settlementBatchSummary', | |
+ 'Braintree_SettlementBatchSummary' => 'settlementBatchSummary', | |
+ 'Braintree\SettlementBatchSummaryGateway' => 'settlementBatchSummary', | |
+ 'Braintree_SettlementBatchSummaryGateway' => 'settlementBatchSummary', | |
+ 'Braintree\Merchant' => 'merchant', | |
+ 'Braintree_Merchant' => 'merchant', | |
+ 'Braintree\MerchantGateway' => 'merchant', | |
+ 'Braintree_MerchantGateway' => 'merchant', | |
+ 'Braintree\MerchantAccount' => 'merchantAccount', | |
+ 'Braintree_MerchantAccount' => 'merchantAccount', | |
+ 'Braintree\MerchantAccountGateway' => 'merchantAccount', | |
+ 'Braintree_MerchantAccountGateway' => 'merchantAccount', | |
+ 'Braintree\OAuthCredentials' => 'credentials', | |
+ 'Braintree_OAuthCredentials' => 'credentials', | |
+ 'Braintree\PayPalAccount' => 'paypalAccount', | |
+ 'Braintree_PayPalAccount' => 'paypalAccount', | |
+ 'Braintree\PayPalAccountGateway' => 'paypalAccount', | |
+ 'Braintree_PayPalAccountGateway' => 'paypalAccount', | |
+ ]; | |
- $name = str_replace('Braintree_', '', $name); | |
return $classNamesToResponseKeys[$name]; | |
} | |
/** | |
* | |
* @param string $name className | |
- * @return string Braintree_ClassName | |
+ * @return string ClassName | |
*/ | |
public static function buildClassName($name) | |
{ | |
- $responseKeysToClassNames = array( | |
- 'creditCard' => 'CreditCard', | |
- 'customer' => 'Customer', | |
- 'subscription' => 'Subscription', | |
- 'transaction' => 'Transaction', | |
- 'verification' => 'CreditCardVerification', | |
- 'addOn' => 'AddOn', | |
- 'discount' => 'Discount', | |
- 'plan' => 'Plan', | |
- 'address' => 'Address', | |
- 'settlementBatchSummary' => 'SettlementBatchSummary', | |
- 'merchantAccount' => 'MerchantAccount' | |
- ); | |
+ $responseKeysToClassNames = [ | |
+ 'creditCard' => 'Braintree\CreditCard', | |
+ 'customer' => 'Braintree\Customer', | |
+ 'subscription' => 'Braintree\Subscription', | |
+ 'transaction' => 'Braintree\Transaction', | |
+ 'verification' => 'Braintree\CreditCardVerification', | |
+ 'addOn' => 'Braintree\AddOn', | |
+ 'discount' => 'Braintree\Discount', | |
+ 'plan' => 'Braintree\Plan', | |
+ 'address' => 'Braintree\Address', | |
+ 'settlementBatchSummary' => 'Braintree\SettlementBatchSummary', | |
+ 'merchantAccount' => 'Braintree\MerchantAccount', | |
+ ]; | |
- return 'Braintree_' . $responseKeysToClassNames[$name]; | |
+ return (string) $responseKeysToClassNames[$name]; | |
} | |
/** | |
@@ -160,6 +192,7 @@ | |
* | |
* @access public | |
* @param string $string | |
+ * @param null|string $delimiter | |
* @return string modified string | |
*/ | |
public static function delimiterToCamelCase($string, $delimiter = '[\-\_]') | |
@@ -192,25 +225,18 @@ | |
* find capitals and convert to delimiter + lowercase | |
* | |
* @access public | |
- * @param var $string | |
- * @return var modified string | |
+ * @param string $string | |
+ * @param null|string $delimiter | |
+ * @return string modified string | |
*/ | |
public static function camelCaseToDelimiter($string, $delimiter = '-') | |
{ | |
- // php doesn't garbage collect functions created by create_function() | |
- // so use a static variable to avoid adding a new function to memory | |
- // every time this function is called. | |
- static $callbacks = array(); | |
- if (!isset($callbacks[$delimiter])) { | |
- $callbacks[$delimiter] = create_function('$matches', "return '$delimiter' . strtolower(\$matches[1]);"); | |
- } | |
- | |
- return preg_replace_callback('/([A-Z])/', $callbacks[$delimiter], $string); | |
+ return strtolower(preg_replace('/([A-Z])/', "$delimiter\\1", $string)); | |
} | |
public static function delimiterToCamelCaseArray($array, $delimiter = '[\-\_]') | |
{ | |
- $converted = array(); | |
+ $converted = []; | |
foreach ($array as $key => $value) { | |
if (is_string($key)) { | |
$key = self::delimiterToCamelCase($key, $delimiter); | |
@@ -232,7 +258,7 @@ | |
public static function camelCaseToDelimiterArray($array, $delimiter = '-') | |
{ | |
- $converted = array(); | |
+ $converted = []; | |
foreach ($array as $key => $value) { | |
if (is_string($key)) { | |
$key = self::camelCaseToDelimiter($key, $delimiter); | |
@@ -247,7 +273,7 @@ | |
public static function delimiterToUnderscoreArray($array) | |
{ | |
- $converted = array(); | |
+ $converted = []; | |
foreach ($array as $key => $value) { | |
$key = self::delimiterToUnderscore($key); | |
$converted[$key] = $value; | |
@@ -260,6 +286,7 @@ | |
* @param array $array associative array to implode | |
* @param string $separator (optional, defaults to =) | |
* @param string $glue (optional, defaults to ', ') | |
+ * @return bool | |
*/ | |
public static function implodeAssociativeArray($array, $separator = '=', $glue = ', ') | |
{ | |
@@ -276,10 +303,10 @@ | |
} | |
public static function attributesToString($attributes) { | |
- $printableAttribs = array(); | |
+ $printableAttribs = []; | |
foreach ($attributes AS $key => $value) { | |
if (is_array($value)) { | |
- $pAttrib = Braintree_Util::attributesToString($value); | |
+ $pAttrib = self::attributesToString($value); | |
} else if ($value instanceof DateTime) { | |
$pAttrib = $value->format(DateTime::RFC850); | |
} else { | |
@@ -287,7 +314,7 @@ | |
} | |
$printableAttribs[$key] = sprintf('%s', $pAttrib); | |
} | |
- return Braintree_Util::implodeAssociativeArray($printableAttribs); | |
+ return self::implodeAssociativeArray($printableAttribs); | |
} | |
/** | |
@@ -309,7 +336,7 @@ | |
if(!empty($invalidKeys)) { | |
asort($invalidKeys); | |
$sortedList = join(', ', $invalidKeys); | |
- throw new InvalidArgumentException('invalid keys: '. $sortedList); | |
+ throw new InvalidArgumentException('invalid keys: ' . $sortedList); | |
} | |
} | |
/** | |
@@ -320,7 +347,7 @@ | |
*/ | |
private static function _flattenArray($keys, $namespace = null) | |
{ | |
- $flattenedArray = array(); | |
+ $flattenedArray = []; | |
foreach($keys AS $key) { | |
if(is_array($key)) { | |
$theKeys = array_keys($key); | |
@@ -339,7 +366,7 @@ | |
private static function _flattenUserKeys($keys, $namespace = null) | |
{ | |
- $flattenedArray = array(); | |
+ $flattenedArray = []; | |
foreach($keys AS $key => $value) { | |
$fullKey = empty($namespace) ? $key : $namespace; | |
@@ -381,3 +408,4 @@ | |
return $invalidKeys; | |
} | |
} | |
+class_alias('Braintree\Util', 'Braintree_Util'); | |
Index: braintree_sdk/lib/Braintree/VenmoAccount.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/VenmoAccount.php (revision 0) | |
+++ braintree_sdk/lib/Braintree/VenmoAccount.php (working copy) | |
@@ -0,0 +1,75 @@ | |
+<?php | |
+namespace Braintree; | |
+ | |
+/** | |
+ * Braintree VenmoAccount module | |
+ * Creates and manages Braintree Venmo accounts | |
+ * | |
+ * <b>== More information ==</b> | |
+ * | |
+ * See {@link https://developers.braintreepayments.com/javascript+php}<br /> | |
+ * | |
+ * @package Braintree | |
+ * @category Resources | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
+ * | |
+ * @property-read string $createdAt | |
+ * @property-read string $default | |
+ * @property-read string $updatedAt | |
+ * @property-read string $customerId | |
+ * @property-read string $sourceDescription | |
+ * @property-read string $token | |
+ * @property-read string $imageUrl | |
+ * @property-read string $username | |
+ * @property-read string $venmoUserId | |
+ */ | |
+class VenmoAccount extends Base | |
+{ | |
+ /* instance methods */ | |
+ /** | |
+ * returns false if default is null or false | |
+ * | |
+ * @return boolean | |
+ */ | |
+ public function isDefault() | |
+ { | |
+ return $this->default; | |
+ } | |
+ | |
+ /** | |
+ * factory method: returns an instance of VenmoAccount | |
+ * to the requesting method, with populated properties | |
+ * | |
+ * @ignore | |
+ * @return VenmoAccount | |
+ */ | |
+ public static function factory($attributes) | |
+ { | |
+ | |
+ $instance = new self(); | |
+ $instance->_initialize($attributes); | |
+ return $instance; | |
+ } | |
+ | |
+ /** | |
+ * sets instance properties from an array of values | |
+ * | |
+ * @access protected | |
+ * @param array $venmoAccountAttribs array of Venmo account properties | |
+ * @return void | |
+ */ | |
+ protected function _initialize($venmoAccountAttribs) | |
+ { | |
+ $this->_attributes = $venmoAccountAttribs; | |
+ | |
+ $subscriptionArray = array(); | |
+ if (isset($venmoAccountAttribs['subscriptions'])) { | |
+ foreach ($venmoAccountAttribs['subscriptions'] AS $subscription) { | |
+ $subscriptionArray[] = Subscription::factory($subscription); | |
+ } | |
+ } | |
+ | |
+ $this->_set('subscriptions', $subscriptionArray); | |
+ } | |
+} | |
+class_alias('Braintree\VenmoAccount', 'Braintree_VenmoAccount'); | |
Index: braintree_sdk/lib/Braintree/Version.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Version.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Version.php (working copy) | |
@@ -1,17 +1,19 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
/** | |
* Braintree Library Version | |
* stores version information about the Braintree library | |
* | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-final class Braintree_Version | |
+final class Version | |
{ | |
/** | |
* class constants | |
*/ | |
const MAJOR = 3; | |
- const MINOR = 5; | |
+ const MINOR = 8; | |
const TINY = 0; | |
/** | |
@@ -28,6 +30,7 @@ | |
*/ | |
public static function get() | |
{ | |
- return self::MAJOR.'.'.self::MINOR.'.'.self::TINY; | |
+ return self::MAJOR . '.' . self::MINOR . '.' . self::TINY; | |
} | |
} | |
+class_alias('Braintree\Version', 'Braintree_Version'); | |
Index: braintree_sdk/lib/Braintree/WebhookNotification.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/WebhookNotification.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/WebhookNotification.php (working copy) | |
@@ -1,5 +1,7 @@ | |
<?php | |
-class Braintree_WebhookNotification extends Braintree_Base | |
+namespace Braintree; | |
+ | |
+class WebhookNotification extends Base | |
{ | |
const SUBSCRIPTION_CANCELED = 'subscription_canceled'; | |
const SUBSCRIPTION_CHARGED_SUCCESSFULLY = 'subscription_charged_successfully'; | |
@@ -19,29 +21,30 @@ | |
const PARTNER_MERCHANT_CONNECTED = 'partner_merchant_connected'; | |
const PARTNER_MERCHANT_DISCONNECTED = 'partner_merchant_disconnected'; | |
const PARTNER_MERCHANT_DECLINED = 'partner_merchant_declined'; | |
+ const CHECK = 'check'; | |
public static function parse($signature, $payload) | |
{ | |
if (preg_match("/[^A-Za-z0-9+=\/\n]/", $payload) === 1) { | |
- throw new Braintree_Exception_InvalidSignature("payload contains illegal characters"); | |
+ throw new Exception\InvalidSignature("payload contains illegal characters"); | |
} | |
- Braintree_Configuration::assertGlobalHasAccessTokenOrKeys(); | |
+ Configuration::assertGlobalHasAccessTokenOrKeys(); | |
self::_validateSignature($signature, $payload); | |
$xml = base64_decode($payload); | |
- $attributes = Braintree_Xml::buildArrayFromXml($xml); | |
+ $attributes = Xml::buildArrayFromXml($xml); | |
return self::factory($attributes['notification']); | |
} | |
public static function verify($challenge) | |
{ | |
if (!preg_match('/^[a-f0-9]{20,32}$/', $challenge)) { | |
- throw new Braintree_Exception_InvalidChallenge("challenge contains non-hex characters"); | |
+ throw new Exception\InvalidChallenge("challenge contains non-hex characters"); | |
} | |
- Braintree_Configuration::assertGlobalHasAccessTokenOrKeys(); | |
- $publicKey = Braintree_Configuration::publicKey(); | |
- $digest = Braintree_Digest::hexDigestSha1(Braintree_Configuration::privateKey(), $challenge); | |
+ Configuration::assertGlobalHasAccessTokenOrKeys(); | |
+ $publicKey = Configuration::publicKey(); | |
+ $digest = Digest::hexDigestSha1(Configuration::privateKey(), $challenge); | |
return "{$publicKey}|{$digest}"; | |
} | |
@@ -57,7 +60,7 @@ | |
foreach ($signaturePairs as $pair) | |
{ | |
$components = preg_split("/\|/", $pair); | |
- if ($components[0] == Braintree_Configuration::publicKey()) { | |
+ if ($components[0] == Configuration::publicKey()) { | |
return $components[1]; | |
} | |
} | |
@@ -67,8 +70,8 @@ | |
private static function _payloadMatches($signature, $payload) | |
{ | |
- $payloadSignature = Braintree_Digest::hexDigestSha1(Braintree_Configuration::privateKey(), $payload); | |
- return Braintree_Digest::secureCompare($signature, $payloadSignature); | |
+ $payloadSignature = Digest::hexDigestSha1(Configuration::privateKey(), $payload); | |
+ return Digest::secureCompare($signature, $payloadSignature); | |
} | |
private static function _validateSignature($signatureString, $payload) | |
@@ -76,11 +79,11 @@ | |
$signaturePairs = preg_split("/&/", $signatureString); | |
$signature = self::_matchingSignature($signaturePairs); | |
if (!$signature) { | |
- throw new Braintree_Exception_InvalidSignature("no matching public key"); | |
+ throw new Exception\InvalidSignature("no matching public key"); | |
} | |
if (!(self::_payloadMatches($signature, $payload) || self::_payloadMatches($signature, $payload . "\n"))) { | |
- throw new Braintree_Exception_InvalidSignature("signature does not match payload - one has been modified"); | |
+ throw new Exception\InvalidSignature("signature does not match payload - one has been modified"); | |
} | |
} | |
@@ -95,32 +98,33 @@ | |
} | |
if (isset($wrapperNode['subscription'])) { | |
- $this->_set('subscription', Braintree_Subscription::factory($attributes['subject']['subscription'])); | |
+ $this->_set('subscription', Subscription::factory($attributes['subject']['subscription'])); | |
} | |
if (isset($wrapperNode['merchantAccount'])) { | |
- $this->_set('merchantAccount', Braintree_MerchantAccount::factory($wrapperNode['merchantAccount'])); | |
+ $this->_set('merchantAccount', MerchantAccount::factory($wrapperNode['merchantAccount'])); | |
} | |
if (isset($wrapperNode['transaction'])) { | |
- $this->_set('transaction', Braintree_Transaction::factory($wrapperNode['transaction'])); | |
+ $this->_set('transaction', Transaction::factory($wrapperNode['transaction'])); | |
} | |
if (isset($wrapperNode['disbursement'])) { | |
- $this->_set('disbursement', Braintree_Disbursement::factory($wrapperNode['disbursement'])); | |
+ $this->_set('disbursement', Disbursement::factory($wrapperNode['disbursement'])); | |
} | |
if (isset($wrapperNode['partnerMerchant'])) { | |
- $this->_set('partnerMerchant', Braintree_PartnerMerchant::factory($wrapperNode['partnerMerchant'])); | |
+ $this->_set('partnerMerchant', PartnerMerchant::factory($wrapperNode['partnerMerchant'])); | |
} | |
if (isset($wrapperNode['dispute'])) { | |
- $this->_set('dispute', Braintree_Dispute::factory($wrapperNode['dispute'])); | |
+ $this->_set('dispute', Dispute::factory($wrapperNode['dispute'])); | |
} | |
if (isset($wrapperNode['errors'])) { | |
- $this->_set('errors', new Braintree_Error_ValidationErrorCollection($wrapperNode['errors'])); | |
+ $this->_set('errors', new Error\ValidationErrorCollection($wrapperNode['errors'])); | |
$this->_set('message', $wrapperNode['message']); | |
} | |
} | |
} | |
+class_alias('Braintree\WebhookNotification', 'Braintree_WebhookNotification'); | |
Index: braintree_sdk/lib/Braintree/WebhookTesting.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/WebhookTesting.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/WebhookTesting.php (working copy) | |
@@ -1,53 +1,61 @@ | |
<?php | |
-class Braintree_WebhookTesting | |
+namespace Braintree; | |
+ | |
+class WebhookTesting | |
{ | |
public static function sampleNotification($kind, $id) | |
{ | |
$payload = base64_encode(self::_sampleXml($kind, $id)) . "\n"; | |
- $signature = Braintree_Configuration::publicKey() . "|" . Braintree_Digest::hexDigestSha1(Braintree_Configuration::privateKey(), $payload); | |
+ $signature = Configuration::publicKey() . "|" . Digest::hexDigestSha1(Configuration::privateKey(), $payload); | |
- return array( | |
+ return [ | |
'bt_signature' => $signature, | |
'bt_payload' => $payload | |
- ); | |
+ ]; | |
} | |
private static function _sampleXml($kind, $id) | |
{ | |
switch ($kind) { | |
- case Braintree_WebhookNotification::SUB_MERCHANT_ACCOUNT_APPROVED: | |
+ case WebhookNotification::SUB_MERCHANT_ACCOUNT_APPROVED: | |
$subjectXml = self::_merchantAccountApprovedSampleXml($id); | |
break; | |
- case Braintree_WebhookNotification::SUB_MERCHANT_ACCOUNT_DECLINED: | |
+ case WebhookNotification::SUB_MERCHANT_ACCOUNT_DECLINED: | |
$subjectXml = self::_merchantAccountDeclinedSampleXml($id); | |
break; | |
- case Braintree_WebhookNotification::TRANSACTION_DISBURSED: | |
+ case WebhookNotification::TRANSACTION_DISBURSED: | |
$subjectXml = self::_transactionDisbursedSampleXml($id); | |
break; | |
- case Braintree_WebhookNotification::DISBURSEMENT_EXCEPTION: | |
+ case WebhookNotification::DISBURSEMENT_EXCEPTION: | |
$subjectXml = self::_disbursementExceptionSampleXml($id); | |
break; | |
- case Braintree_WebhookNotification::DISBURSEMENT: | |
+ case WebhookNotification::DISBURSEMENT: | |
$subjectXml = self::_disbursementSampleXml($id); | |
break; | |
- case Braintree_WebhookNotification::PARTNER_MERCHANT_CONNECTED: | |
+ case WebhookNotification::PARTNER_MERCHANT_CONNECTED: | |
$subjectXml = self::_partnerMerchantConnectedSampleXml($id); | |
break; | |
- case Braintree_WebhookNotification::PARTNER_MERCHANT_DISCONNECTED: | |
+ case WebhookNotification::PARTNER_MERCHANT_DISCONNECTED: | |
$subjectXml = self::_partnerMerchantDisconnectedSampleXml($id); | |
break; | |
- case Braintree_WebhookNotification::PARTNER_MERCHANT_DECLINED: | |
+ case WebhookNotification::PARTNER_MERCHANT_DECLINED: | |
$subjectXml = self::_partnerMerchantDeclinedSampleXml($id); | |
break; | |
- case Braintree_WebhookNotification::DISPUTE_OPENED: | |
+ case WebhookNotification::DISPUTE_OPENED: | |
$subjectXml = self::_disputeOpenedSampleXml($id); | |
break; | |
- case Braintree_WebhookNotification::DISPUTE_LOST: | |
+ case WebhookNotification::DISPUTE_LOST: | |
$subjectXml = self::_disputeLostSampleXml($id); | |
break; | |
- case Braintree_WebhookNotification::DISPUTE_WON: | |
+ case WebhookNotification::DISPUTE_WON: | |
$subjectXml = self::_disputeWonSampleXml($id); | |
break; | |
+ case WebhookNotification::SUBSCRIPTION_CHARGED_SUCCESSFULLY: | |
+ $subjectXml = self::_subscriptionChargedSuccessfullySampleXml($id); | |
+ break; | |
+ case WebhookNotification::CHECK: | |
+ $subjectXml = self::_checkSampleXml(); | |
+ break; | |
default: | |
$subjectXml = self::_subscriptionSampleXml($id); | |
break; | |
@@ -176,6 +184,7 @@ | |
<currency-iso-code>USD</currency-iso-code> | |
<received-date type=\"date\">2014-03-01</received-date> | |
<reply-by-date type=\"date\">2014-03-21</reply-by-date> | |
+ <kind>chargeback</kind> | |
<status>open</status> | |
<reason>fraud</reason> | |
<id>${id}</id> | |
@@ -183,6 +192,7 @@ | |
<id>${id}</id> | |
<amount>250.00</amount> | |
</transaction> | |
+ <date-opened type=\"date\">2014-03-21</date-opened> | |
</dispute> | |
"; | |
} | |
@@ -195,6 +205,7 @@ | |
<currency-iso-code>USD</currency-iso-code> | |
<received-date type=\"date\">2014-03-01</received-date> | |
<reply-by-date type=\"date\">2014-03-21</reply-by-date> | |
+ <kind>chargeback</kind> | |
<status>lost</status> | |
<reason>fraud</reason> | |
<id>${id}</id> | |
@@ -202,6 +213,7 @@ | |
<id>${id}</id> | |
<amount>250.00</amount> | |
</transaction> | |
+ <date-opened type=\"date\">2014-03-21</date-opened> | |
</dispute> | |
"; | |
} | |
@@ -214,6 +226,7 @@ | |
<currency-iso-code>USD</currency-iso-code> | |
<received-date type=\"date\">2014-03-01</received-date> | |
<reply-by-date type=\"date\">2014-03-21</reply-by-date> | |
+ <kind>chargeback</kind> | |
<status>won</status> | |
<reason>fraud</reason> | |
<id>${id}</id> | |
@@ -221,6 +234,8 @@ | |
<id>${id}</id> | |
<amount>250.00</amount> | |
</transaction> | |
+ <date-opened type=\"date\">2014-03-21</date-opened> | |
+ <date-won type=\"date\">2014-03-22</date-won> | |
</dispute> | |
"; | |
} | |
@@ -240,6 +255,32 @@ | |
"; | |
} | |
+ private static function _subscriptionChargedSuccessfullySampleXml($id) | |
+ { | |
+ return " | |
+ <subscription> | |
+ <id>{$id}</id> | |
+ <transactions type=\"array\"> | |
+ <transaction> | |
+ <status>submitted_for_settlement</status> | |
+ <amount>49.99</amount> | |
+ </transaction> | |
+ </transactions> | |
+ <add_ons type=\"array\"> | |
+ </add_ons> | |
+ <discounts type=\"array\"> | |
+ </discounts> | |
+ </subscription> | |
+ "; | |
+ } | |
+ | |
+ private static function _checkSampleXml() | |
+ { | |
+ return " | |
+ <check type=\"boolean\">true</check> | |
+ "; | |
+ } | |
+ | |
private static function _partnerMerchantConnectedSampleXml($id) | |
{ | |
return " | |
@@ -281,3 +322,4 @@ | |
return $timestamp; | |
} | |
} | |
+class_alias('Braintree\WebhookTesting', 'Braintree_WebhookTesting'); | |
Index: braintree_sdk/lib/Braintree/Xml/Generator.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Xml/Generator.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Xml/Generator.php (working copy) | |
@@ -1,27 +1,34 @@ | |
<?php | |
+namespace Braintree\Xml; | |
+ | |
+use DateTime; | |
+use DateTimeZone; | |
+use XMLWriter; | |
+use Braintree\Util; | |
+ | |
/** | |
* PHP version 5 | |
* | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
/** | |
* Generates XML output from arrays using PHP's | |
* built-in XMLWriter | |
* | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_Xml_Generator | |
+class Generator | |
{ | |
/** | |
* arrays passed to this method should have a single root element | |
* with an array as its value | |
* @param array $aData the array of data | |
- * @return var XML string | |
+ * @return string XML string | |
*/ | |
public static function arrayToXml($aData) | |
{ | |
- $aData = Braintree_Util::camelCaseToDelimiterArray($aData, '-'); | |
+ $aData = Util::camelCaseToDelimiterArray($aData, '-'); | |
// set up the XMLWriter | |
$writer = new XMLWriter(); | |
$writer->openMemory(); | |
@@ -53,7 +60,7 @@ | |
* @static | |
* @param object $writer XMLWriter object | |
* @param array $aData contains attributes and values | |
- * @return none | |
+ * @return void | |
*/ | |
private static function _createElementsFromArray(&$writer, $aData) | |
{ | |
@@ -103,23 +110,23 @@ | |
private static function _generateXmlAttribute($value) | |
{ | |
if ($value instanceof DateTime) { | |
- return array('type', 'datetime', self::_dateTimeToXmlTimestamp($value)); | |
+ return ['type', 'datetime', self::_dateTimeToXmlTimestamp($value)]; | |
} | |
if (is_int($value)) { | |
- return array('type', 'integer', $value); | |
+ return ['type', 'integer', $value]; | |
} | |
if (is_bool($value)) { | |
- return array('type', 'boolean', ($value ? 'true' : 'false')); | |
+ return ['type', 'boolean', ($value ? 'true' : 'false')]; | |
} | |
if ($value === NULL) { | |
- return array('nil', 'true', $value); | |
+ return ['nil', 'true', $value]; | |
} | |
} | |
/** | |
* converts datetime back to xml schema format | |
* @access protected | |
* @param object $dateTime | |
- * @return var XML schema formatted timestamp | |
+ * @return string XML schema formatted timestamp | |
*/ | |
private static function _dateTimeToXmlTimestamp($dateTime) | |
{ | |
@@ -141,3 +148,4 @@ | |
} | |
} | |
} | |
+class_alias('Braintree\Xml\Generator', 'Braintree_Xml_Generator'); | |
Index: braintree_sdk/lib/Braintree/Xml/Parser.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Xml/Parser.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Xml/Parser.php (working copy) | |
@@ -1,11 +1,19 @@ | |
<?php | |
+namespace Braintree\Xml; | |
+use DateTime; | |
+use DateTimeZone; | |
+use DOMDocument; | |
+use DOMElement; | |
+use DOMText; | |
+use Braintree\Util; | |
+ | |
/** | |
* Braintree XML Parser | |
* | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-class Braintree_Xml_Parser | |
+class Parser | |
{ | |
/** | |
* Converts an XML string into a multidimensional array | |
@@ -20,9 +28,9 @@ | |
$root = $document->documentElement->nodeName; | |
- return Braintree_Util::delimiterToCamelCaseArray(array( | |
+ return Util::delimiterToCamelCaseArray([ | |
$root => self::_nodeToValue($document->childNodes->item(0)), | |
- )); | |
+ ]); | |
} | |
/** | |
@@ -40,7 +48,7 @@ | |
switch($type) { | |
case 'array': | |
- $array = array(); | |
+ $array = []; | |
foreach ($node->childNodes as $child) { | |
$value = self::_nodeToValue($child); | |
if ($value !== null) { | |
@@ -49,19 +57,19 @@ | |
} | |
return $array; | |
case 'collection': | |
- $collection = array(); | |
+ $collection = []; | |
foreach ($node->childNodes as $child) { | |
$value = self::_nodetoValue($child); | |
if ($value !== null) { | |
if (!isset($collection[$child->nodeName])) { | |
- $collection[$child->nodeName] = array(); | |
+ $collection[$child->nodeName] = []; | |
} | |
$collection[$child->nodeName][] = self::_nodeToValue($child); | |
} | |
} | |
return $collection; | |
default: | |
- $values = array(); | |
+ $values = []; | |
if ($node->childNodes->length === 1 && $node->childNodes->item(0) instanceof DOMText) { | |
return $node->childNodes->item(0)->nodeValue; | |
} else { | |
@@ -131,3 +139,4 @@ | |
return $dateTime; | |
} | |
} | |
+class_alias('Braintree\Xml\Parser', 'Braintree_Xml_Parser'); | |
Index: braintree_sdk/lib/Braintree/Xml.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree/Xml.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree/Xml.php (working copy) | |
@@ -1,12 +1,14 @@ | |
<?php | |
+namespace Braintree; | |
+ | |
/** | |
* Braintree Xml parser and generator | |
* PHP version 5 | |
* superclass for Braintree XML parsing and generation | |
* | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
-final class Braintree_Xml | |
+final class Xml | |
{ | |
/** | |
* @ignore | |
@@ -23,7 +25,7 @@ | |
*/ | |
public static function buildArrayFromXml($xml) | |
{ | |
- return Braintree_Xml_Parser::arrayFromXml($xml); | |
+ return Xml\Parser::arrayFromXml($xml); | |
} | |
/** | |
@@ -33,6 +35,7 @@ | |
*/ | |
public static function buildXmlFromArray($array) | |
{ | |
- return Braintree_Xml_Generator::arrayToXml($array); | |
+ return Xml\Generator::arrayToXml($array); | |
} | |
} | |
+class_alias('Braintree\Xml', 'Braintree_Xml'); | |
Index: braintree_sdk/lib/Braintree.php | |
=================================================================== | |
--- braintree_sdk/lib/Braintree.php (revision 1387260) | |
+++ braintree_sdk/lib/Braintree.php (working copy) | |
@@ -1,151 +1,20 @@ | |
<?php | |
/** | |
* Braintree PHP Library | |
+ * Creates class_aliases for old class names replaced by PSR-4 Namespaces | |
* | |
- * Braintree base class and initialization | |
- * Provides methods to child classes. This class cannot be instantiated. | |
- * | |
- * PHP version 5 | |
- * | |
- * @copyright 2014 Braintree, a division of PayPal, Inc. | |
+ * @copyright 2015 Braintree, a division of PayPal, Inc. | |
*/ | |
+require_once('autoload.php'); | |
-set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__))); | |
- | |
-require_once('Braintree/Base.php'); | |
-require_once('Braintree/Modification.php'); | |
-require_once('Braintree/Instance.php'); | |
- | |
-require_once('Braintree/OAuthCredentials.php'); | |
-require_once('Braintree/Address.php'); | |
-require_once('Braintree/AddressGateway.php'); | |
-require_once('Braintree/AddOn.php'); | |
-require_once('Braintree/AddOnGateway.php'); | |
-require_once('Braintree/AndroidPayCard.php'); | |
-require_once('Braintree/ApplePayCard.php'); | |
-require_once('Braintree/ClientToken.php'); | |
-require_once('Braintree/ClientTokenGateway.php'); | |
-require_once('Braintree/CoinbaseAccount.php'); | |
-require_once('Braintree/Collection.php'); | |
-require_once('Braintree/Configuration.php'); | |
-require_once('Braintree/CredentialsParser.php'); | |
-require_once('Braintree/CreditCard.php'); | |
-require_once('Braintree/CreditCardGateway.php'); | |
-require_once('Braintree/Customer.php'); | |
-require_once('Braintree/CustomerGateway.php'); | |
-require_once('Braintree/CustomerSearch.php'); | |
-require_once('Braintree/DisbursementDetails.php'); | |
-require_once('Braintree/Dispute.php'); | |
-require_once('Braintree/Dispute/TransactionDetails.php'); | |
-require_once('Braintree/Descriptor.php'); | |
-require_once('Braintree/Digest.php'); | |
-require_once('Braintree/Discount.php'); | |
-require_once('Braintree/DiscountGateway.php'); | |
-require_once('Braintree/IsNode.php'); | |
-require_once('Braintree/EuropeBankAccount.php'); | |
-require_once('Braintree/EqualityNode.php'); | |
-require_once('Braintree/Exception.php'); | |
-require_once('Braintree/Gateway.php'); | |
-require_once('Braintree/Http.php'); | |
-require_once('Braintree/KeyValueNode.php'); | |
-require_once('Braintree/Merchant.php'); | |
-require_once('Braintree/MerchantGateway.php'); | |
-require_once('Braintree/MerchantAccount.php'); | |
-require_once('Braintree/MerchantAccountGateway.php'); | |
-require_once('Braintree/MerchantAccount/BusinessDetails.php'); | |
-require_once('Braintree/MerchantAccount/FundingDetails.php'); | |
-require_once('Braintree/MerchantAccount/IndividualDetails.php'); | |
-require_once('Braintree/MerchantAccount/AddressDetails.php'); | |
-require_once('Braintree/MultipleValueNode.php'); | |
-require_once('Braintree/MultipleValueOrTextNode.php'); | |
-require_once('Braintree/OAuthGateway.php'); | |
-require_once('Braintree/PartialMatchNode.php'); | |
-require_once('Braintree/Plan.php'); | |
-require_once('Braintree/PlanGateway.php'); | |
-require_once('Braintree/RangeNode.php'); | |
-require_once('Braintree/ResourceCollection.php'); | |
-require_once('Braintree/RiskData.php'); | |
-require_once('Braintree/ThreeDSecureInfo.php'); | |
-require_once('Braintree/SettlementBatchSummary.php'); | |
-require_once('Braintree/SettlementBatchSummaryGateway.php'); | |
-require_once('Braintree/SignatureService.php'); | |
-require_once('Braintree/Subscription.php'); | |
-require_once('Braintree/SubscriptionGateway.php'); | |
-require_once('Braintree/SubscriptionSearch.php'); | |
-require_once('Braintree/Subscription/StatusDetails.php'); | |
-require_once('Braintree/TextNode.php'); | |
-require_once('Braintree/Transaction.php'); | |
-require_once('Braintree/TransactionGateway.php'); | |
-require_once('Braintree/Disbursement.php'); | |
-require_once('Braintree/TransactionSearch.php'); | |
-require_once('Braintree/TransparentRedirect.php'); | |
-require_once('Braintree/TransparentRedirectGateway.php'); | |
-require_once('Braintree/Util.php'); | |
-require_once('Braintree/Version.php'); | |
-require_once('Braintree/Xml.php'); | |
-require_once('Braintree/Error/Codes.php'); | |
-require_once('Braintree/Error/ErrorCollection.php'); | |
-require_once('Braintree/Error/Validation.php'); | |
-require_once('Braintree/Error/ValidationErrorCollection.php'); | |
-require_once('Braintree/Exception/Authentication.php'); | |
-require_once('Braintree/Exception/Authorization.php'); | |
-require_once('Braintree/Exception/Configuration.php'); | |
-require_once('Braintree/Exception/DownForMaintenance.php'); | |
-require_once('Braintree/Exception/ForgedQueryString.php'); | |
-require_once('Braintree/Exception/InvalidChallenge.php'); | |
-require_once('Braintree/Exception/InvalidSignature.php'); | |
-require_once('Braintree/Exception/NotFound.php'); | |
-require_once('Braintree/Exception/ServerError.php'); | |
-require_once('Braintree/Exception/SSLCertificate.php'); | |
-require_once('Braintree/Exception/SSLCaFileNotFound.php'); | |
-require_once('Braintree/Exception/Unexpected.php'); | |
-require_once('Braintree/Exception/UpgradeRequired.php'); | |
-require_once('Braintree/Exception/ValidationsFailed.php'); | |
-require_once('Braintree/Result/CreditCardVerification.php'); | |
-require_once('Braintree/Result/Error.php'); | |
-require_once('Braintree/Result/Successful.php'); | |
-require_once('Braintree/Test/CreditCardNumbers.php'); | |
-require_once('Braintree/Test/MerchantAccount.php'); | |
-require_once('Braintree/Test/TransactionAmounts.php'); | |
-require_once('Braintree/Test/VenmoSdk.php'); | |
-require_once('Braintree/Test/Nonces.php'); | |
-require_once('Braintree/Transaction/AddressDetails.php'); | |
-require_once('Braintree/Transaction/AndroidPayCardDetails.php'); | |
-require_once('Braintree/Transaction/ApplePayCardDetails.php'); | |
-require_once('Braintree/Transaction/CoinbaseDetails.php'); | |
-require_once('Braintree/Transaction/EuropeBankAccountDetails.php'); | |
-require_once('Braintree/Transaction/CreditCardDetails.php'); | |
-require_once('Braintree/Transaction/PayPalDetails.php'); | |
-require_once('Braintree/Transaction/CustomerDetails.php'); | |
-require_once('Braintree/Transaction/StatusDetails.php'); | |
-require_once('Braintree/Transaction/SubscriptionDetails.php'); | |
-require_once('Braintree/WebhookNotification.php'); | |
-require_once('Braintree/WebhookTesting.php'); | |
-require_once('Braintree/Xml/Generator.php'); | |
-require_once('Braintree/Xml/Parser.php'); | |
-require_once('Braintree/CreditCardVerification.php'); | |
-require_once('Braintree/CreditCardVerificationGateway.php'); | |
-require_once('Braintree/CreditCardVerificationSearch.php'); | |
-require_once('Braintree/PartnerMerchant.php'); | |
-require_once('Braintree/PayPalAccount.php'); | |
-require_once('Braintree/PayPalAccountGateway.php'); | |
-require_once('Braintree/PaymentMethod.php'); | |
-require_once('Braintree/PaymentMethodGateway.php'); | |
-require_once('Braintree/PaymentMethodNonce.php'); | |
-require_once('Braintree/PaymentMethodNonceGateway.php'); | |
-require_once('Braintree/PaymentInstrumentType.php'); | |
-require_once('Braintree/UnknownPaymentMethod.php'); | |
-require_once('Braintree/Exception/TestOperationPerformedInProduction.php'); | |
-require_once('Braintree/Test/Transaction.php'); | |
- | |
if (version_compare(PHP_VERSION, '5.4.0', '<')) { | |
throw new Braintree_Exception('PHP version >= 5.4.0 required'); | |
} | |
function requireDependencies() { | |
- $requiredExtensions = array('xmlwriter', 'openssl', 'dom', 'hash', 'curl'); | |
+ $requiredExtensions = ['xmlwriter', 'openssl', 'dom', 'hash', 'curl']; | |
foreach ($requiredExtensions AS $ext) { | |
if (!extension_loaded($ext)) { | |
throw new Braintree_Exception('The Braintree library requires the ' . $ext . ' extension.'); | |
Index: braintree_sdk/lib/autoload.php | |
=================================================================== | |
--- braintree_sdk/lib/autoload.php (revision 0) | |
+++ braintree_sdk/lib/autoload.php (working copy) | |
@@ -0,0 +1,21 @@ | |
+<?php | |
+ | |
+spl_autoload_register(function ($className) { | |
+ if (strpos($className, 'Braintree') !== 0) { | |
+ return; | |
+ } | |
+ | |
+ $fileName = dirname(__DIR__) . '/lib/'; | |
+ | |
+ if ($lastNsPos = strripos($className, '\\')) { | |
+ $namespace = substr($className, 0, $lastNsPos); | |
+ $className = substr($className, $lastNsPos + 1); | |
+ $fileName .= str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR; | |
+ } | |
+ | |
+ $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; | |
+ | |
+ if (is_file($fileName)) { | |
+ require_once $fileName; | |
+ } | |
+}); | |
Index: braintree_sdk/lib/ssl/api_braintreegateway_com.ca.crt | |
=================================================================== | |
--- braintree_sdk/lib/ssl/api_braintreegateway_com.ca.crt (revision 1387260) | |
+++ braintree_sdk/lib/ssl/api_braintreegateway_com.ca.crt (working copy) | |
@@ -1,68 +1,4 @@ | |
-----BEGIN CERTIFICATE----- | |
-MIIDAjCCAmsCEH3Z/gfPqB63EHln+6eJNMYwDQYJKoZIhvcNAQEFBQAwgcExCzAJ | |
-BgNVBAYTAlVTMRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xh | |
-c3MgMyBQdWJsaWMgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcy | |
-MTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3Jp | |
-emVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMB4X | |
-DTk4MDUxODAwMDAwMFoXDTI4MDgwMTIzNTk1OVowgcExCzAJBgNVBAYTAlVTMRcw | |
-FQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMyBQdWJsaWMg | |
-UHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEo | |
-YykgMTk5OCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5 | |
-MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMIGfMA0GCSqGSIb3DQEB | |
-AQUAA4GNADCBiQKBgQDMXtERXVxp0KvTuWpMmR9ZmDCOFoUgRm1HP9SFIIThbbP4 | |
-pO0M8RcPO/mn+SXXwc+EY/J8Y8+iR/LGWzOOZEAEaMGAuWQcRXfH2G71lSk8UOg0 | |
-13gfqLptQ5GVj0VXXn7F+8qkBOvqlzdUMG+7AUcyM83cV5tkaWH4mx0ciU9cZwID | |
-AQABMA0GCSqGSIb3DQEBBQUAA4GBAFFNzb5cy5gZnBWyATl4Lk0PZ3BwmcYQWpSk | |
-U01UbSuvDV1Ai2TT1+7eVmGSX6bEHRBhNtMsJzzoKQm5EWR0zLVznxxIqbxhAe7i | |
-F6YM40AIOw7n60RzKprxaZLvcRTDOaxxp5EJb+RxBrO6WVcmeQD2+A2iMzAo1KpY | |
-oJ2daZH9 | |
------END CERTIFICATE----- | |
------BEGIN CERTIFICATE----- | |
-MIIEGjCCAwICEQCbfgZJoz5iudXukEhxKe9XMA0GCSqGSIb3DQEBBQUAMIHKMQsw | |
-CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZl | |
-cmlTaWduIFRydXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWdu | |
-LCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlT | |
-aWduIENsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3Jp | |
-dHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQswCQYD | |
-VQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlT | |
-aWduIFRydXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJ | |
-bmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWdu | |
-IENsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkg | |
-LSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMu6nFL8eB8aHm8b | |
-N3O9+MlrlBIwT/A2R/XQkQr1F8ilYcEWQE37imGQ5XYgwREGfassbqb1EUGO+i2t | |
-KmFZpGcmTNDovFJbcCAEWNF6yaRpvIMXZK0Fi7zQWM6NjPXr8EJJC52XJ2cybuGu | |
-kxUccLwgTS8Y3pKI6GyFVxEa6X7jJhFUokWWVYPKMIno3Nij7SqAP395ZVc+FSBm | |
-CC+Vk7+qRy+oRpfwEuL+wgorUeZ25rdGt+INpsyow0xZVYnm6FNcHOqd8GIWC6fJ | |
-Xwzw3sJ2zq/3avL6QaaiMxTJ5Xpj055iN9WFZZ4O5lMkdBteHRJTW8cs54NJOxWu | |
-imi5V5cCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAERSWwauSCPc/L8my/uRan2Te | |
-2yFPhpk0djZX3dAVL8WtfxUfN2JzPtTnX84XA9s1+ivbrmAJXx5fj267Cz3qWhMe | |
-DGBvtcC1IyIuBwvLqXTLR7sdwdela8wv0kL9Sd2nic9TutoAWii/gt/4uhMdUIaC | |
-/Y4wjylGsB49Ndo4YhYYSq3mtlFs3q9i6wHQHiT+eo8SGhJouPtmmRQURVyu565p | |
-F4ErWjfJXir0xuKhXFSbplQAz/DxwceYMBo7Nhbbo27q/a2ywtrvAkcTisDxszGt | |
-TxzhT5yvDwyd93gN2PQ1VoDat20Xj50egWTh/sVFuq1ruQp6Tk9LhO5L8X3dEQ== | |
------END CERTIFICATE----- | |
------BEGIN CERTIFICATE----- | |
-MIIDhDCCAwqgAwIBAgIQL4D+I4wOIg9IZxIokYesszAKBggqhkjOPQQDAzCByjEL | |
-MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZW | |
-ZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2ln | |
-biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJp | |
-U2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9y | |
-aXR5IC0gRzQwHhcNMDcxMTA1MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCByjELMAkG | |
-A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJp | |
-U2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwg | |
-SW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2ln | |
-biBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5 | |
-IC0gRzQwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAASnVnp8Utpkmw4tXNherJI9/gHm | |
-GUo9FANL+mAnINmDiWn6VMaaGF5VKmTeBvaNSjutEDxlPZCIBIngMGGzrl0Bp3ve | |
-fLK+ymVhAIau2o970ImtTR1ZmkGxvEeA3J5iw/mjgbIwga8wDwYDVR0TAQH/BAUw | |
-AwEB/zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJ | |
-aW1hZ2UvZ2lmMCEwHzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYj | |
-aHR0cDovL2xvZ28udmVyaXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFLMW | |
-kf3upm7ktS5Jj4d4gYDs5bG1MAoGCCqGSM49BAMDA2gAMGUCMGYhDBgmYFo4e1ZC | |
-4Kf8NoRRkSAsdk1DPcQdhCPQrNZ8NQbOzWm9kA3bbEhCHQ6qQgIxAJw9SDkjOVga | |
-FRJZap7v1VmyHVIsmXHNxynfGyphe3HR3vPA5Q06Sqotp9iGKt0uEA== | |
------END CERTIFICATE----- | |
------BEGIN CERTIFICATE----- | |
MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCB | |
yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL | |
ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJp | |
@@ -91,20 +27,6 @@ | |
hnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq | |
-----END CERTIFICATE----- | |
-----BEGIN CERTIFICATE----- | |
-MIICPDCCAaUCEDyRMcsf9tAbDpq40ES/Er4wDQYJKoZIhvcNAQEFBQAwXzELMAkG | |
-A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFz | |
-cyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2 | |
-MDEyOTAwMDAwMFoXDTI4MDgwMjIzNTk1OVowXzELMAkGA1UEBhMCVVMxFzAVBgNV | |
-BAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmlt | |
-YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GN | |
-ADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhE | |
-BarsAx94f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/is | |
-I19wKTakyYbnsZogy1Olhec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0G | |
-CSqGSIb3DQEBBQUAA4GBABByUqkFFBkyCEHwxWsKzH4PIRnN5GfcX6kb5sroc50i | |
-2JhucwNhkcV8sEVAbkSdjbCxlnRhLQ2pRdKkkirWmnWXbj9T/UWZYB2oK0z5XqcJ | |
-2HUw19JlYD1n1khVdWk/kfVIC0dpImmClr7JyDiGSnoscxlIaU5rfGW/D/xwzoiQ | |
------END CERTIFICATE----- | |
------BEGIN CERTIFICATE----- | |
MIIDuDCCAqCgAwIBAgIQDPCOXAgWpa1Cf/DrJxhZ0DANBgkqhkiG9w0BAQUFADBI | |
MQswCQYDVQQGEwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24x | |
FzAVBgNVBAMTDlNlY3VyZVRydXN0IENBMB4XDTA2MTEwNzE5MzExOFoXDTI5MTIz | |
@@ -150,37 +72,73 @@ | |
4uJEvlz36hz1 | |
-----END CERTIFICATE----- | |
-----BEGIN CERTIFICATE----- | |
-MIIFbDCCA1SgAwIBAgIBATANBgkqhkiG9w0BAQUFADBHMQswCQYDVQQGEwJVUzEW | |
-MBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEgMB4GA1UEAxMXR2VvVHJ1c3QgVW5pdmVy | |
-c2FsIENBIDIwHhcNMDQwMzA0MDUwMDAwWhcNMjkwMzA0MDUwMDAwWjBHMQswCQYD | |
-VQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEgMB4GA1UEAxMXR2VvVHJ1 | |
-c3QgVW5pdmVyc2FsIENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC | |
-AQCzVFLByT7y2dyxUxpZKeexw0Uo5dfR7cXFS6GqdHtXr0om/Nj1XqduGdt0DE81 | |
-WzILAePb63p3NeqqWuDW6KFXlPCQo3RWlEQwAx5cTiuFJnSCegx2oG9NzkEtoBUG | |
-FF+3Qs17j1hhNNwqCPkuwwGmIkQcTAeC5lvO0Ep8BNMZcyfwqph/Lq9O64ceJHdq | |
-XbboW0W63MOhBW9Wjo8QJqVJwy7XQYci4E+GymC16qFjwAGXEHm9ADwSbSsVsaxL | |
-se4YuU6W3Nx2/zu+z18DwPw76L5GG//aQMJS9/7jOvdqdzXQ2o3rXhhqMcceujwb | |
-KNZrVMaqW9eiLBsZzKIC9ptZvTdrhrVtgrrY6slWvKk2WP0+GfPtDCapkzj4T8Fd | |
-IgbQl+rhrcZV4IErKIM6+vR7IVEAvlI4zs1meaj0gVbi0IMJR1FbUGrP20gaXT73 | |
-y/Zl92zxlfgCOzJWgjl6W70viRu/obTo/3+NjN8D8WBOWBFM66M/ECuDmgFz2ZRt | |
-hAAnZqzwcEAJQpKtT5MNYQlRJNiS1QuUYbKHsu3/mjX/hVTK7URDrBs8FmtISgoc | |
-QIgfksILAAX/8sgCSqSqqcyZlpwvWOB94b67B9xfBHJcMTTD7F8t4D1kkCLm0ey4 | |
-Lt1ZrtmhN79UNdxzMk+MBB4zsslG8dhcyFVQyWi9qLo2CQIDAQABo2MwYTAPBgNV | |
-HRMBAf8EBTADAQH/MB0GA1UdDgQWBBR281Xh+qQ2+/CfXGJx7Tz0RzgQKzAfBgNV | |
-HSMEGDAWgBR281Xh+qQ2+/CfXGJx7Tz0RzgQKzAOBgNVHQ8BAf8EBAMCAYYwDQYJ | |
-KoZIhvcNAQEFBQADggIBAGbBxiPz2eAubl/oz66wsCVNK/g7WJtAJDday6sWSf+z | |
-dXkzoS9tcBc0kf5nfo/sm+VegqlVHy/c1FEHEv6sFj4sNcZj/NwQ6w2jqtB8zNHQ | |
-L1EuxBRa3ugZ4T7GzKQp5y6EqgYweHZUcyiYWTjgAA1i00J9IZ+uPTqM1fp3DRgr | |
-Fg5fNuH8KrUwJM/gYwx7WBr+mbpCErGR9Hxo4sjoryzqyX6uuyo9DRXcNJW2GHSo | |
-ag/HtPQTxORb7QrSpJdMKu0vbBKJPfEncKpqA1Ihn0CoZ1Dy81of398j9tx4TuaY | |
-T1U6U+Pv8vSfx3zYWK8pIpe44L2RLrB27FcRz+8pRPPphXpgY+RdM4kX2TGq2tbz | |
-GDVyz4crL2MjhF2EjD9XoIj8mZEoJmmZ1I+XRL6O1UixpCgp8RW04eWe3fiPpm8m | |
-1wk8OhwRDqZsN/etRIcsKMfYdIKz0G9KV7s1KSegi+ghp4dkNl3M2Basx7InQJJV | |
-OCiNUW7dFGdTbHFcJoRNdVq2fmBWqU2t+5sel/MN2dKXVHfaPRK34B7vCAas+YWH | |
-6aLcr34YEoP9VhdBLtUpgn2Z9DH2canPLAEnpQW5qrJITirvn5NSUZU8UnOOVkwX | |
-QMAJKOSLakhT2+zNVVXxxvjpoixMptEmX36vWkzaH6byHCx+rgIW0lbQL1dTR+iS | |
+MIIDtzCCAp+gAwIBAgIQDOfg5RfYRv6P5WD8G/AwOTANBgkqhkiG9w0BAQUFADBl | |
+MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 | |
+d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJv | |
+b3QgQ0EwHhcNMDYxMTEwMDAwMDAwWhcNMzExMTEwMDAwMDAwWjBlMQswCQYDVQQG | |
+EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNl | |
+cnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0EwggEi | |
+MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCtDhXO5EOAXLGH87dg+XESpa7c | |
+JpSIqvTO9SA5KFhgDPiA2qkVlTJhPLWxKISKityfCgyDF3qPkKyK53lTXDGEKvYP | |
+mDI2dsze3Tyoou9q+yHyUmHfnyDXH+Kx2f4YZNISW1/5WBg1vEfNoTb5a3/UsDg+ | |
+wRvDjDPZ2C8Y/igPs6eD1sNuRMBhNZYW/lmci3Zt1/GiSw0r/wty2p5g0I6QNcZ4 | |
+VYcgoc/lbQrISXwxmDNsIumH0DJaoroTghHtORedmTpyoeb6pNnVFzF1roV9Iq4/ | |
+AUaG9ih5yLHa5FcXxH4cDrC0kqZWs72yl+2qp/C3xag/lRbQ/6GW6whfGHdPAgMB | |
+AAGjYzBhMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQW | |
+BBRF66Kv9JLLgjEtUYunpyGd823IDzAfBgNVHSMEGDAWgBRF66Kv9JLLgjEtUYun | |
+pyGd823IDzANBgkqhkiG9w0BAQUFAAOCAQEAog683+Lt8ONyc3pklL/3cmbYMuRC | |
+dWKuh+vy1dneVrOfzM4UKLkNl2BcEkxY5NM9g0lFWJc1aRqoR+pWxnmrEthngYTf | |
+fwk8lOa4JiwgvT2zKIn3X/8i4peEH+ll74fg38FnSbNd67IJKusm7Xi+fT8r87cm | |
+NW1fiQG2SVufAQWbqz0lwcy2f8Lxb4bG+mRo64EtlOtCt/qMHt1i8b5QZ7dsvfPx | |
+H2sMNgcWfzd8qVttevESRmCD1ycEvkvOl77DZypoEd+A5wwzZr8TDRRu838fYxAe | |
++o0bJW1sj6W3YQGx0qMmoRBxna3iw/nDmVG3KwcIzi7mULKn+gpFL6Lw8g== | |
-----END CERTIFICATE----- | |
-----BEGIN CERTIFICATE----- | |
+MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh | |
+MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 | |
+d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD | |
+QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT | |
+MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j | |
+b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG | |
+9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsB | |
+CSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97 | |
+nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt | |
+43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7P | |
+T19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4 | |
+gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAO | |
+BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbR | |
+TLtm8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUw | |
+DQYJKoZIhvcNAQEFBQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/Esr | |
+hMAtudXH/vTBH1jLuG2cenTnmCmrEbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg | |
+06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIttep3Sp+dWOIrWcBAI+0tKIJF | |
+PnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0ls | |
+YSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk | |
+CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4= | |
+-----END CERTIFICATE----- | |
+-----BEGIN CERTIFICATE----- | |
+MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBs | |
+MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 | |
+d3cuZGlnaWNlcnQuY29tMSswKQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5j | |
+ZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAwMFoXDTMxMTExMDAwMDAwMFowbDEL | |
+MAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZMBcGA1UECxMQd3d3 | |
+LmRpZ2ljZXJ0LmNvbTErMCkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFuY2Ug | |
+RVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm | |
++9S75S0tMqbf5YE/yc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTW | |
+PNt0OKRKzE0lgvdKpVMSOO7zSW1xkX5jtqumX8OkhPhPYlG++MXs2ziS4wblCJEM | |
+xChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFB | |
+Ik5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx+mM0aBhakaHPQNAQTXKFx01p8VdteZOE3 | |
+hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUeh10aUAsg | |
+EsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQF | |
+MAMBAf8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaA | |
+FLE+w2kD+L9HAdSYJhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3Nec | |
+nzyIZgYIVyHbIUf4KmeqvxgydkAQV8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6z | |
+eM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFpmyPInngiK3BD41VHMWEZ71jF | |
+hS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkKmNEVX58Svnw2 | |
+Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe | |
+vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep | |
++OkuE6N36B9K | |
+-----END CERTIFICATE----- | |
+-----BEGIN CERTIFICATE----- | |
MIIFaDCCA1CgAwIBAgIBATANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJVUzEW | |
MBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEeMBwGA1UEAxMVR2VvVHJ1c3QgVW5pdmVy | |
c2FsIENBMB4XDTA0MDMwNDA1MDAwMFoXDTI5MDMwNDA1MDAwMFowRTELMAkGA1UE | |
@@ -212,27 +170,6 @@ | |
bJxPgWp6ZKy7PtXny3YuxadIwVyQD8vIP/rmMuGNG2+k5o7Y+SlIis5z/iw= | |
-----END CERTIFICATE----- | |
-----BEGIN CERTIFICATE----- | |
-MIIDZjCCAk6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBEMQswCQYDVQQGEwJVUzEW | |
-MBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEdMBsGA1UEAxMUR2VvVHJ1c3QgR2xvYmFs | |
-IENBIDIwHhcNMDQwMzA0MDUwMDAwWhcNMTkwMzA0MDUwMDAwWjBEMQswCQYDVQQG | |
-EwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEdMBsGA1UEAxMUR2VvVHJ1c3Qg | |
-R2xvYmFsIENBIDIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDvPE1A | |
-PRDfO1MA4Wf+lGAVPoWI8YkNkMgoI5kF6CsgncbzYEbYwbLVjDHZ3CB5JIG/NTL8 | |
-Y2nbsSpr7iFY8gjpeMtvy/wWUsiRxP89c96xPqfCfWbB9X5SJBri1WeR0IIQ13hL | |
-TytCOb1kLUCgsBDTOEhGiKEMuzozKmKY+wCdE1l/bztyqu6mD4b5BWHqZ38MN5aL | |
-5mkWRxHCJ1kDs6ZgwiFAVvqgx306E+PsV8ez1q6diYD3Aecs9pYrEw15LNnA5IZ7 | |
-S4wMcoKK+xfNAGw6EzywhIdLFnopsk/bHdQL82Y3vdj2V7teJHq4PIu5+pIaGoSe | |
-2HSPqht/XvT+RSIhAgMBAAGjYzBhMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE | |
-FHE4NvICMVNHK266ZUapEBVYIAUJMB8GA1UdIwQYMBaAFHE4NvICMVNHK266ZUap | |
-EBVYIAUJMA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQUFAAOCAQEAA/e1K6td | |
-EPx7srJerJsOflN4WT5CBP51o62sgU7XAotexC3IUnbHLB/8gTKY0UvGkpMzNTEv | |
-/NgdRN3ggX+d6YvhZJFiCzkIjKx0nVnZellSlxG5FntvRdOW2TF9AjYPnDtuzywN | |
-A0ZF66D0f0hExghAzN4bcLUprbqLOzRldRtxIR0sFAqwlpW41uryZfspuk/qkZN0 | |
-abby/+Ea0AzRdoXLiiW9l14sbxWZJue2Kf8i7MkCx1YAzUm5s2x7UwQa4qjJqhIF | |
-I8LO57sEAszAR6LkxCkvW0VXiVHuPOtSCP8HNR6fNWpHSlaY0VqFH4z1Ir+rzoPz | |
-4iIprn2DQKi6bA== | |
------END CERTIFICATE----- | |
------BEGIN CERTIFICATE----- | |
MIIDVDCCAjygAwIBAgIDAjRWMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVT | |
MRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9i | |
YWwgQ0EwHhcNMDIwNTIxMDQwMDAwWhcNMjIwNTIxMDQwMDAwWjBCMQswCQYDVQQG | |
@@ -252,100 +189,3 @@ | |
hw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6pXE0zX5IJL4hmXXeXxx12E6nV | |
5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvmMw== | |
-----END CERTIFICATE----- | |
------BEGIN CERTIFICATE----- | |
-MIIDuDCCAqCgAwIBAgIQDPCOXAgWpa1Cf/DrJxhZ0DANBgkqhkiG9w0BAQUFADBI | |
-MQswCQYDVQQGEwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24x | |
-FzAVBgNVBAMTDlNlY3VyZVRydXN0IENBMB4XDTA2MTEwNzE5MzExOFoXDTI5MTIz | |
-MTE5NDA1NVowSDELMAkGA1UEBhMCVVMxIDAeBgNVBAoTF1NlY3VyZVRydXN0IENv | |
-cnBvcmF0aW9uMRcwFQYDVQQDEw5TZWN1cmVUcnVzdCBDQTCCASIwDQYJKoZIhvcN | |
-AQEBBQADggEPADCCAQoCggEBAKukgeWVzfX2FI7CT8rU4niVWJxB4Q2ZQCQXOZEz | |
-Zum+4YOvYlyJ0fwkW2Gz4BERQRwdbvC4u/jep4G6pkjGnx29vo6pQT64lO0pGtSO | |
-0gMdA+9tDWccV9cGrcrI9f4Or2YlSASWC12juhbDCE/RRvgUXPLIXgGZbf2IzIao | |
-wW8xQmxSPmjL8xk037uHGFaAJsTQ3MBv396gwpEWoGQRS0S8Hvbn+mPeZqx2pHGj | |
-7DaUaHp3pLHnDi+BeuK1cobvomuL8A/b01k/unK8RCSc43Oz969XL0Imnal0ugBS | |
-8kvNU3xHCzaFDmapCJcWNFfBZveA4+1wVMeT4C4oFVmHursCAwEAAaOBnTCBmjAT | |
-BgkrBgEEAYI3FAIEBh4EAEMAQTALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB | |
-/zAdBgNVHQ4EFgQUQjK2FvoE/f5dS3rD/fdMQB1aQ68wNAYDVR0fBC0wKzApoCeg | |
-JYYjaHR0cDovL2NybC5zZWN1cmV0cnVzdC5jb20vU1RDQS5jcmwwEAYJKwYBBAGC | |
-NxUBBAMCAQAwDQYJKoZIhvcNAQEFBQADggEBADDtT0rhWDpSclu1pqNlGKa7UTt3 | |
-6Z3q059c4EVlew3KW+JwULKUBRSuSceNQQcSc5R+DCMh/bwQf2AQWnL1mA6s7Ll/ | |
-3XpvXdMc9P+IBWlCqQVxyLesJugutIxq/3HcuLHfmbx8IVQr5Fiiu1cprp6poxkm | |
-D5kuCLDv/WnPmRoJjeOnnyvJNjR7JLN4TJUXpAYmHrZkUjZfYGfZnMUFdAvnZyPS | |
-CPyI6a6Lf+Ew9Dd+/cYy2i2eRDAwbO4H3tI0/NL/QPZL9GZGBlSm8jIKYyYwa5vR | |
-3ItHuuG51WLQoqD0ZwV4KWMabwTW+MZMo5qxN7SN5ShLHZ4swrhovO0C7jE= | |
------END CERTIFICATE----- | |
------BEGIN CERTIFICATE----- | |
-MIICiDCCAg2gAwIBAgIQNfwmXNmET8k9Jj1Xm67XVjAKBggqhkjOPQQDAzCBhDEL | |
-MAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjE4MDYGA1UECxMvKGMp | |
-IDIwMDcgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxJDAi | |
-BgNVBAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EgLSBHMjAeFw0wNzExMDUwMDAw | |
-MDBaFw0zODAxMTgyMzU5NTlaMIGEMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMdGhh | |
-d3RlLCBJbmMuMTgwNgYDVQQLEy8oYykgMjAwNyB0aGF3dGUsIEluYy4gLSBGb3Ig | |
-YXV0aG9yaXplZCB1c2Ugb25seTEkMCIGA1UEAxMbdGhhd3RlIFByaW1hcnkgUm9v | |
-dCBDQSAtIEcyMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEotWcgnuVnfFSeIf+iha/ | |
-BebfowJPDQfGAFG6DAJSLSKkQjnE/o/qycG+1E3/n3qe4rF8mq2nhglzh9HnmuN6 | |
-papu+7qzcMBniKI11KOasf2twu8x+qi58/sIxpHR+ymVo0IwQDAPBgNVHRMBAf8E | |
-BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUmtgAMADna3+FGO6Lts6K | |
-DPgR4bswCgYIKoZIzj0EAwMDaQAwZgIxAN344FdHW6fmCsO99YCKlzUNG4k8VIZ3 | |
-KMqh9HneteY4sPBlcIx/AlTCv//YoT7ZzwIxAMSNlPzcU9LcnXgWHxUzI1NS41ox | |
-XZ3Krr0TKUQNJ1uo52icEvdYPy5yAlejj6EULg== | |
------END CERTIFICATE----- | |
------BEGIN CERTIFICATE----- | |
-MIIEIDCCAwigAwIBAgIQNE7VVyDV7exJ9C/ON9srbTANBgkqhkiG9w0BAQUFADCB | |
-qTELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMf | |
-Q2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIw | |
-MDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxHzAdBgNV | |
-BAMTFnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwHhcNMDYxMTE3MDAwMDAwWhcNMzYw | |
-NzE2MjM1OTU5WjCBqTELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5j | |
-LjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYG | |
-A1UECxMvKGMpIDIwMDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl | |
-IG9ubHkxHzAdBgNVBAMTFnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwggEiMA0GCSqG | |
-SIb3DQEBAQUAA4IBDwAwggEKAoIBAQCsoPD7gFnUnMekz52hWXMJEEUMDSxuaPFs | |
-W0hoSVk3/AszGcJ3f8wQLZU0HObrTQmnHNK4yZc2AreJ1CRfBsDMRJSUjQJib+ta | |
-3RGNKJpchJAQeg29dGYvajig4tVUROsdB58Hum/u6f1OCyn1PoSgAfGcq/gcfomk | |
-6KHYcWUNo1F77rzSImANuVud37r8UVsLr5iy6S7pBOhih94ryNdOwUxkHt3Ph1i6 | |
-Sk/KaAcdHJ1KxtUvkcx8cXIcxcBn6zL9yZJclNqFwJu/U30rCfSMnZEfl2pSy94J | |
-NqR32HuHUETVPm4pafs5SSYeCaWAe0At6+gnhcn+Yf1+5nyXHdWdAgMBAAGjQjBA | |
-MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBR7W0XP | |
-r87Lev0xkhpqtvNG61dIUDANBgkqhkiG9w0BAQUFAAOCAQEAeRHAS7ORtvzw6WfU | |
-DW5FvlXok9LOAz/t2iWwHVfLHjp2oEzsUHboZHIMpKnxuIvW1oeEuzLlQRHAd9mz | |
-YJ3rG9XRbkREqaYB7FViHXe4XI5ISXycO1cRrK1zN44veFyQaEfZYGDm/Ac9IiAX | |
-xPcW6cTYcvnIc3zfFi8VqT79aie2oetaupgf1eNNZAqdE8hhuvU5HIe6uL17In/2 | |
-/qxAeeWsEG89jxt5dovEN7MhGITlNgDrYyCZuen+MwS7QcjBAvlEYyCegc5C09Y/ | |
-LHbTY5xZ3Y+m4Q6gLkH3LpVHz7z9M/P2C2F+fpErgUfCJzDupxBdN49cOSvkBPB7 | |
-jVaMaA== | |
------END CERTIFICATE----- | |
------BEGIN CERTIFICATE----- | |
-MIICiDCCAg2gAwIBAgIQNfwmXNmET8k9Jj1Xm67XVjAKBggqhkjOPQQDAzCBhDEL | |
-MAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjE4MDYGA1UECxMvKGMp | |
-IDIwMDcgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxJDAi | |
-BgNVBAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EgLSBHMjAeFw0wNzExMDUwMDAw | |
-MDBaFw0zODAxMTgyMzU5NTlaMIGEMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMdGhh | |
-d3RlLCBJbmMuMTgwNgYDVQQLEy8oYykgMjAwNyB0aGF3dGUsIEluYy4gLSBGb3Ig | |
-YXV0aG9yaXplZCB1c2Ugb25seTEkMCIGA1UEAxMbdGhhd3RlIFByaW1hcnkgUm9v | |
-dCBDQSAtIEcyMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEotWcgnuVnfFSeIf+iha/ | |
-BebfowJPDQfGAFG6DAJSLSKkQjnE/o/qycG+1E3/n3qe4rF8mq2nhglzh9HnmuN6 | |
-papu+7qzcMBniKI11KOasf2twu8x+qi58/sIxpHR+ymVo0IwQDAPBgNVHRMBAf8E | |
-BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUmtgAMADna3+FGO6Lts6K | |
-DPgR4bswCgYIKoZIzj0EAwMDaQAwZgIxAN344FdHW6fmCsO99YCKlzUNG4k8VIZ3 | |
-KMqh9HneteY4sPBlcIx/AlTCv//YoT7ZzwIxAMSNlPzcU9LcnXgWHxUzI1NS41ox | |
-XZ3Krr0TKUQNJ1uo52icEvdYPy5yAlejj6EULg== | |
------END CERTIFICATE----- | |
------BEGIN CERTIFICATE----- | |
-MIIC5zCCAlACAQEwDQYJKoZIhvcNAQEFBQAwgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0 | |
-IFZhbGlkYXRpb24gTmV0d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAz | |
-BgNVBAsTLFZhbGlDZXJ0IENsYXNzIDIgUG9saWN5IFZhbGlkYXRpb24gQXV0aG9y | |
-aXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZhbGljZXJ0LmNvbS8xIDAeBgkqhkiG | |
-9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMB4XDTk5MDYyNjAwMTk1NFoXDTE5MDYy | |
-NjAwMTk1NFowgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0IFZhbGlkYXRpb24gTmV0d29y | |
-azEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAzBgNVBAsTLFZhbGlDZXJ0IENs | |
-YXNzIDIgUG9saWN5IFZhbGlkYXRpb24gQXV0aG9yaXR5MSEwHwYDVQQDExhodHRw | |
-Oi8vd3d3LnZhbGljZXJ0LmNvbS8xIDAeBgkqhkiG9w0BCQEWEWluZm9AdmFsaWNl | |
-cnQuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDOOnHK5avIWZJV16vY | |
-dA757tn2VUdZZUcOBVXc65g2PFxTXdMwzzjsvUGJ7SVCCSRrCl6zfN1SLUzm1NZ9 | |
-WlmpZdRJEy0kTRxQb7XBhVQ7/nHk01xC+YDgkRoKWzk2Z/M/VXwbP7RfZHM047QS | |
-v4dk+NoS/zcnwbNDu+97bi5p9wIDAQABMA0GCSqGSIb3DQEBBQUAA4GBADt/UG9v | |
-UJSZSWI4OB9L+KXIPqeCgfYrx+jFzug6EILLGACOTb2oWH+heQC1u+mNr0HZDzTu | |
-IYEZoDJJKPTEjlbVUjP9UNV+mWwD5MlM/Mtsq2azSiGM5bUMMj4QssxsodyamEwC | |
-W/POuZ6lcg5Ktz885hZo+L7tdEy8W9ViH0Pd | |
------END CERTIFICATE----- | |
Index: braintree_sdk/phpunit.xml.dist | |
=================================================================== | |
--- braintree_sdk/phpunit.xml.dist (revision 1387260) | |
+++ braintree_sdk/phpunit.xml.dist (working copy) | |
@@ -1,6 +1,7 @@ | |
<?xml version="1.0" encoding="UTF-8"?> | |
<phpunit backupGlobals="false" | |
backupStaticAttributes="false" | |
+ bootstrap="./vendor/autoload.php" | |
convertErrorsToExceptions="true" | |
convertNoticesToExceptions="true" | |
convertWarningsToExceptions="true" | |
Index: braintree_sdk/tests/Braintree/CreditCardDefaults.php | |
=================================================================== | |
--- braintree_sdk/tests/Braintree/CreditCardDefaults.php (revision 1387260) | |
+++ braintree_sdk/tests/Braintree/CreditCardDefaults.php (working copy) | |
@@ -1,4 +1,5 @@ | |
<?php | |
+namespace Test\Braintree; | |
class CreditCardDefaults | |
{ | |
Index: braintree_sdk/tests/Braintree/CreditCardNumbers/CardTypeIndicators.php | |
=================================================================== | |
--- braintree_sdk/tests/Braintree/CreditCardNumbers/CardTypeIndicators.php (revision 1387260) | |
+++ braintree_sdk/tests/Braintree/CreditCardNumbers/CardTypeIndicators.php (working copy) | |
@@ -1,5 +1,7 @@ | |
<?php | |
-class Braintree_CreditCardNumbers_CardTypeIndicators { | |
+namespace Test\Braintree\CreditCardNumbers; | |
+ | |
+class CardTypeIndicators { | |
const PREPAID = "4111111111111210"; | |
const COMMERCIAL = "4111111111131010"; | |
const PAYROLL = "4111111114101010"; | |
Index: braintree_sdk/tests/Braintree/OAuthTestHelper.php | |
=================================================================== | |
--- braintree_sdk/tests/Braintree/OAuthTestHelper.php (revision 1387260) | |
+++ braintree_sdk/tests/Braintree/OAuthTestHelper.php (working copy) | |
@@ -1,31 +1,34 @@ | |
<?php | |
+namespace Test\Braintree; | |
-class Braintree_OAuthTestHelper | |
+use Braintree; | |
+ | |
+class OAuthTestHelper | |
{ | |
public static function createGrant($gateway, $params) | |
{ | |
- $http = new Braintree_Http($gateway->config); | |
+ $http = new Braintree\Http($gateway->config); | |
$http->useClientCredentials(); | |
- $response = $http->post('/oauth_testing/grants', array('grant' => $params)); | |
+ $response = $http->post('/oauth_testing/grants', ['grant' => $params]); | |
return $response['grant']['code']; | |
} | |
public static function createCredentials($params) | |
{ | |
- $gateway = new Braintree_Gateway(array( | |
+ $gateway = new Braintree\Gateway([ | |
'clientId' => $params['clientId'], | |
'clientSecret' => $params['clientSecret'] | |
- )); | |
+ ]); | |
- $code = Braintree_OAuthTestHelper::createGrant($gateway, array( | |
+ $code = OAuthTestHelper::createGrant($gateway, [ | |
'merchant_public_id' => $params['merchantId'], | |
'scope' => 'read_write' | |
- )); | |
+ ]); | |
- $credentials = $gateway->oauth()->createTokenFromCode(array( | |
+ $credentials = $gateway->oauth()->createTokenFromCode([ | |
'code' => $code, | |
'scope' => 'read_write', | |
- )); | |
+ ]); | |
return $credentials; | |
} | |
Index: braintree_sdk/tests/Helper.php | |
=================================================================== | |
--- braintree_sdk/tests/Helper.php (revision 0) | |
+++ braintree_sdk/tests/Helper.php (working copy) | |
@@ -0,0 +1,136 @@ | |
+<?php | |
+namespace Test; | |
+ | |
+require_once __DIR__ . '/Setup.php'; | |
+ | |
+use DateTime; | |
+use DateTimeZone; | |
+use Braintree; | |
+ | |
+class Helper | |
+{ | |
+ public static function testMerchantConfig() | |
+ { | |
+ Braintree\Configuration::reset(); | |
+ | |
+ Braintree\Configuration::environment('development'); | |
+ Braintree\Configuration::merchantId('test_merchant_id'); | |
+ Braintree\Configuration::publicKey('test_public_key'); | |
+ Braintree\Configuration::privateKey('test_private_key'); | |
+ } | |
+ | |
+ public static function defaultMerchantAccountId() | |
+ { | |
+ return 'sandbox_credit_card'; | |
+ } | |
+ | |
+ public static function nonDefaultMerchantAccountId() | |
+ { | |
+ return 'sandbox_credit_card_non_default'; | |
+ } | |
+ | |
+ public static function nonDefaultSubMerchantAccountId() | |
+ { | |
+ return 'sandbox_sub_merchant_account'; | |
+ } | |
+ | |
+ public static function threeDSecureMerchantAccountId() | |
+ { | |
+ return 'three_d_secure_merchant_account'; | |
+ } | |
+ | |
+ public static function fakeAmexDirectMerchantAccountId() | |
+ { | |
+ return 'fake_amex_direct_usd'; | |
+ } | |
+ | |
+ public static function fakeVenmoAccountMerchantAccountId() | |
+ { | |
+ return 'fake_first_data_venmo_account'; | |
+ } | |
+ | |
+ public static function createViaTr($regularParams, $trParams) | |
+ { | |
+ $trData = Braintree\TransparentRedirect::transactionData( | |
+ array_merge($trParams, ["redirectUrl" => "http://www.example.com"]) | |
+ ); | |
+ return self::submitTrRequest( | |
+ Braintree\TransparentRedirect::url(), | |
+ $regularParams, | |
+ $trData | |
+ ); | |
+ } | |
+ | |
+ public static function submitTrRequest($url, $regularParams, $trData) | |
+ { | |
+ $curl = curl_init(); | |
+ curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false); | |
+ curl_setopt($curl, CURLOPT_URL, $url); | |
+ curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST'); | |
+ curl_setopt($curl, CURLOPT_HEADER, true); | |
+ // curl_setopt($curl, CURLOPT_VERBOSE, true); | |
+ curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query(array_merge($regularParams, ['tr_data' => $trData]))); | |
+ curl_setopt($curl, CURLOPT_HTTPHEADER, [ | |
+ 'Content-Type: application/x-www-form-urlencoded' | |
+ ]); | |
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); | |
+ $response = curl_exec($curl); | |
+ curl_close($curl); | |
+ preg_match('/Location: .*\?(.*)/i', $response, $match); | |
+ return trim($match[1]); | |
+ } | |
+ | |
+ public static function suppressDeprecationWarnings() | |
+ { | |
+ set_error_handler("Test\Helper::_errorHandler", E_USER_NOTICE); | |
+ } | |
+ | |
+ public static function _errorHandler($errno, $errstr, $errfile, $errline) | |
+ { | |
+ if (preg_match('/^DEPRECATED/', $errstr) == 0) { | |
+ trigger_error('Unknown error received: ' . $errstr, E_USER_ERROR); | |
+ } | |
+ } | |
+ | |
+ public static function includes($collection, $targetItem) | |
+ { | |
+ foreach ($collection AS $item) { | |
+ if ($item->id == $targetItem->id) { | |
+ return true; | |
+ } | |
+ } | |
+ return false; | |
+ } | |
+ | |
+ public static function assertPrintable($object) | |
+ { | |
+ " " . $object; | |
+ } | |
+ | |
+ public static function escrow($transactionId) | |
+ { | |
+ $http = new Braintree\Http(Braintree\Configuration::$global); | |
+ $path = Braintree\Configuration::$global->merchantPath() . '/transactions/' . $transactionId . '/escrow'; | |
+ $http->put($path); | |
+ } | |
+ | |
+ public static function create3DSVerification($merchantAccountId, $params) | |
+ { | |
+ $http = new Braintree\Http(Braintree\Configuration::$global); | |
+ $path = Braintree\Configuration::$global->merchantPath() . '/three_d_secure/create_verification/' . $merchantAccountId; | |
+ $response = $http->post($path, ['threeDSecureVerification' => $params]); | |
+ return $response['threeDSecureVerification']['threeDSecureToken']; | |
+ } | |
+ | |
+ public static function nowInEastern() | |
+ { | |
+ $eastern = new DateTimeZone('America/New_York'); | |
+ $now = new DateTime('now', $eastern); | |
+ return $now->format('Y-m-d'); | |
+ } | |
+ | |
+ public static function decodedClientToken($params=[]) { | |
+ $encodedClientToken = Braintree\ClientToken::generate($params); | |
+ return base64_decode($encodedClientToken); | |
+ } | |
+} | |
Index: braintree_sdk/tests/Setup.php | |
=================================================================== | |
--- braintree_sdk/tests/Setup.php (revision 0) | |
+++ braintree_sdk/tests/Setup.php (working copy) | |
@@ -0,0 +1,32 @@ | |
+<?php | |
+namespace Test; | |
+ | |
+require_once __DIR__ . '/Helper.php'; | |
+require_once __DIR__ . '/integration/HttpClientApi.php'; | |
+require_once __DIR__ . '/integration/SubscriptionHelper.php'; | |
+require_once __DIR__ . '/Braintree/CreditCardNumbers/CardTypeIndicators.php'; | |
+require_once __DIR__ . '/Braintree/CreditCardDefaults.php'; | |
+require_once __DIR__ . '/Braintree/OAuthTestHelper.php'; | |
+ | |
+date_default_timezone_set('UTC'); | |
+ | |
+use Braintree\Configuration; | |
+use PHPUnit_Framework_TestCase; | |
+ | |
+class Setup extends PHPUnit_Framework_TestCase | |
+{ | |
+ public function __construct() | |
+ { | |
+ self::integrationMerchantConfig(); | |
+ } | |
+ | |
+ public static function integrationMerchantConfig() | |
+ { | |
+ Configuration::reset(); | |
+ | |
+ Configuration::environment('development'); | |
+ Configuration::merchantId('integration_merchant_id'); | |
+ Configuration::publicKey('integration_public_key'); | |
+ Configuration::privateKey('integration_private_key'); | |
+ } | |
+} | |
Index: braintree_sdk/tests/integration/AddOnsTest.php | |
=================================================================== | |
--- braintree_sdk/tests/integration/AddOnsTest.php (revision 1387260) | |
+++ braintree_sdk/tests/integration/AddOnsTest.php (working copy) | |
@@ -1,13 +1,18 @@ | |
<?php | |
-require_once realpath(dirname(__FILE__)) . '/../TestHelper.php'; | |
+namespace Test\Integration; | |
-class Braintree_AddOnTest extends PHPUnit_Framework_TestCase | |
+require_once dirname(__DIR__) . '/Setup.php'; | |
+ | |
+use Test\Setup; | |
+use Braintree; | |
+ | |
+class AddOnsTest extends Setup | |
{ | |
- function testAll_returnsAllAddOns() | |
+ public function testAll_returnsAllAddOns() | |
{ | |
$newId = strval(rand()); | |
- $addOnParams = array ( | |
+ $addOnParams = [ | |
"amount" => "100.00", | |
"description" => "some description", | |
"id" => $newId, | |
@@ -15,13 +20,13 @@ | |
"name" => "php_add_on", | |
"neverExpires" => "false", | |
"numberOfBillingCycles" => "1" | |
- ); | |
+ ]; | |
- $http = new Braintree_Http(Braintree_Configuration::$global); | |
- $path = Braintree_Configuration::$global->merchantPath() . "/modifications/create_modification_for_tests"; | |
- $http->post($path, array("modification" => $addOnParams)); | |
+ $http = new Braintree\Http(Braintree\Configuration::$global); | |
+ $path = Braintree\Configuration::$global->merchantPath() . "/modifications/create_modification_for_tests"; | |
+ $http->post($path, ["modification" => $addOnParams]); | |
- $addOns = Braintree_AddOn::all(); | |
+ $addOns = Braintree\AddOn::all(); | |
foreach ($addOns as $addOn) | |
{ | |
@@ -41,11 +46,11 @@ | |
$this->assertEquals($addOnParams["numberOfBillingCycles"], $actualAddOn->numberOfBillingCycles); | |
} | |
- function testGatewayAll_returnsAllAddOns() | |
+ public function testGatewayAll_returnsAllAddOns() | |
{ | |
$newId = strval(rand()); | |
- $addOnParams = array ( | |
+ $addOnParams = [ | |
"amount" => "100.00", | |
"description" => "some description", | |
"id" => $newId, | |
@@ -53,18 +58,18 @@ | |
"name" => "php_add_on", | |
"neverExpires" => "false", | |
"numberOfBillingCycles" => "1" | |
- ); | |
+ ]; | |
- $http = new Braintree_Http(Braintree_Configuration::$global); | |
- $path = Braintree_Configuration::$global->merchantPath() . "/modifications/create_modification_for_tests"; | |
- $http->post($path, array("modification" => $addOnParams)); | |
+ $http = new Braintree\Http(Braintree\Configuration::$global); | |
+ $path = Braintree\Configuration::$global->merchantPath() . "/modifications/create_modification_for_tests"; | |
+ $http->post($path, ["modification" => $addOnParams]); | |
- $gateway = new Braintree_Gateway(array( | |
+ $gateway = new Braintree\Gateway([ | |
'environment' => 'development', | |
'merchantId' => 'integration_merchant_id', | |
'publicKey' => 'integration_public_key', | |
'privateKey' => 'integration_private_key' | |
- )); | |
+ ]); | |
$addOns = $gateway->addOn()->all(); | |
foreach ($addOns as $addOn) | |
Index: braintree_sdk/tests/integration/AddressTest.php | |
=================================================================== | |
--- braintree_sdk/tests/integration/AddressTest.php (revision 1387260) | |
+++ braintree_sdk/tests/integration/AddressTest.php (working copy) | |
@@ -1,12 +1,17 @@ | |
<?php | |
-require_once realpath(dirname(__FILE__)) . '/../TestHelper.php'; | |
+namespace Test\Integration; | |
-class Braintree_AddressTest extends PHPUnit_Framework_TestCase | |
+require_once dirname(__DIR__) . '/Setup.php'; | |
+ | |
+use Test\Setup; | |
+use Braintree; | |
+ | |
+class AddressTest extends Setup | |
{ | |
- function testCreate() | |
+ public function testCreate() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_Address::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\Address::create([ | |
'customerId' => $customer->id, | |
'firstName' => 'Dan', | |
'lastName' => 'Smith', | |
@@ -20,7 +25,7 @@ | |
'countryCodeAlpha2' => 'VA', | |
'countryCodeAlpha3' => 'VAT', | |
'countryCodeNumeric' => '336' | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
$address = $result->address; | |
$this->assertEquals('Dan', $address->firstName); | |
@@ -37,23 +42,23 @@ | |
$this->assertEquals('336', $address->countryCodeNumeric); | |
} | |
- function testGatewayCreate() | |
+ public function testGatewayCreate() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
+ $customer = Braintree\Customer::createNoValidate(); | |
- $gateway = new Braintree_Gateway(array( | |
+ $gateway = new Braintree\Gateway([ | |
'environment' => 'development', | |
'merchantId' => 'integration_merchant_id', | |
'publicKey' => 'integration_public_key', | |
'privateKey' => 'integration_private_key' | |
- )); | |
- $result = $gateway->address()->create(array( | |
+ ]); | |
+ $result = $gateway->address()->create([ | |
'customerId' => $customer->id, | |
'streetAddress' => '1 E Main St', | |
'locality' => 'Chicago', | |
'region' => 'IL', | |
'postalCode' => '60622', | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
$address = $result->address; | |
@@ -63,34 +68,34 @@ | |
$this->assertEquals('60622', $address->postalCode); | |
} | |
- function testCreate_withValidationErrors() | |
+ public function testCreate_withValidationErrors() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_Address::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\Address::create([ | |
'customerId' => $customer->id, | |
'countryName' => 'Invalid States of America' | |
- )); | |
+ ]); | |
$this->assertFalse($result->success); | |
$countryErrors = $result->errors->forKey('address')->onAttribute('countryName'); | |
- $this->assertEquals(Braintree_Error_Codes::ADDRESS_COUNTRY_NAME_IS_NOT_ACCEPTED, $countryErrors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::ADDRESS_COUNTRY_NAME_IS_NOT_ACCEPTED, $countryErrors[0]->code); | |
} | |
- function testCreate_withValidationErrors_onCountryCodes() | |
+ public function testCreate_withValidationErrors_onCountryCodes() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_Address::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\Address::create([ | |
'customerId' => $customer->id, | |
'countryCodeAlpha2' => 'ZZ' | |
- )); | |
+ ]); | |
$this->assertFalse($result->success); | |
$countryErrors = $result->errors->forKey('address')->onAttribute('countryCodeAlpha2'); | |
- $this->assertEquals(Braintree_Error_Codes::ADDRESS_COUNTRY_CODE_ALPHA2_IS_NOT_ACCEPTED, $countryErrors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::ADDRESS_COUNTRY_CODE_ALPHA2_IS_NOT_ACCEPTED, $countryErrors[0]->code); | |
} | |
- function testCreateNoValidate() | |
+ public function testCreateNoValidate() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $address = Braintree_Address::createNoValidate(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $address = Braintree\Address::createNoValidate([ | |
'customerId' => $customer->id, | |
'firstName' => 'Dan', | |
'lastName' => 'Smith', | |
@@ -101,7 +106,7 @@ | |
'region' => 'IL', | |
'postalCode' => '60622', | |
'countryName' => 'United States of America' | |
- )); | |
+ ]); | |
$this->assertEquals('Dan', $address->firstName); | |
$this->assertEquals('Smith', $address->lastName); | |
$this->assertEquals('Braintree', $address->company); | |
@@ -113,33 +118,33 @@ | |
$this->assertEquals('United States of America', $address->countryName); | |
} | |
- function testCreateNoValidate_withValidationErrors() | |
+ public function testCreateNoValidate_withValidationErrors() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $this->setExpectedException('Braintree_Exception_ValidationsFailed'); | |
- Braintree_Address::createNoValidate(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $this->setExpectedException('Braintree\Exception\ValidationsFailed'); | |
+ Braintree\Address::createNoValidate([ | |
'customerId' => $customer->id, | |
'countryName' => 'Invalid States of America' | |
- )); | |
+ ]); | |
} | |
- function testDelete() | |
+ public function testDelete() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $address = Braintree_Address::createNoValidate(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $address = Braintree\Address::createNoValidate([ | |
'customerId' => $customer->id, | |
'streetAddress' => '1 E Main St' | |
- )); | |
- Braintree_Address::find($customer->id, $address->id); | |
- Braintree_Address::delete($customer->id, $address->id); | |
- $this->setExpectedException('Braintree_Exception_NotFound'); | |
- Braintree_Address::find($customer->id, $address->id); | |
+ ]); | |
+ Braintree\Address::find($customer->id, $address->id); | |
+ Braintree\Address::delete($customer->id, $address->id); | |
+ $this->setExpectedException('Braintree\Exception\NotFound'); | |
+ Braintree\Address::find($customer->id, $address->id); | |
} | |
- function testFind() | |
+ public function testFind() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_Address::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\Address::create([ | |
'customerId' => $customer->id, | |
'firstName' => 'Dan', | |
'lastName' => 'Smith', | |
@@ -150,9 +155,9 @@ | |
'region' => 'IL', | |
'postalCode' => '60622', | |
'countryName' => 'United States of America' | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
- $address = Braintree_Address::find($customer->id, $result->address->id); | |
+ $address = Braintree\Address::find($customer->id, $result->address->id); | |
$this->assertEquals('Dan', $address->firstName); | |
$this->assertEquals('Smith', $address->lastName); | |
$this->assertEquals('Braintree', $address->company); | |
@@ -164,17 +169,17 @@ | |
$this->assertEquals('United States of America', $address->countryName); | |
} | |
- function testFind_whenNotFound() | |
+ public function testFind_whenNotFound() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $this->setExpectedException('Braintree_Exception_NotFound'); | |
- Braintree_Address::find($customer->id, 'does-not-exist'); | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $this->setExpectedException('Braintree\Exception\NotFound'); | |
+ Braintree\Address::find($customer->id, 'does-not-exist'); | |
} | |
- function testUpdate() | |
+ public function testUpdate() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $address = Braintree_Address::createNoValidate(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $address = Braintree\Address::createNoValidate([ | |
'customerId' => $customer->id, | |
'firstName' => 'Old First', | |
'lastName' => 'Old Last', | |
@@ -188,8 +193,8 @@ | |
'countryCodeAlpha2' => 'US', | |
'countryCodeAlpha3' => 'USA', | |
'countryCodeNumeric' => '840' | |
- )); | |
- $result = Braintree_Address::update($customer->id, $address->id, array( | |
+ ]); | |
+ $result = Braintree\Address::update($customer->id, $address->id, [ | |
'firstName' => 'New First', | |
'lastName' => 'New Last', | |
'company' => 'New Company', | |
@@ -202,7 +207,7 @@ | |
'countryCodeAlpha2' => 'MX', | |
'countryCodeAlpha3' => 'MEX', | |
'countryCodeNumeric' => '484' | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
$address = $result->address; | |
$this->assertEquals('New First', $address->firstName); | |
@@ -219,50 +224,50 @@ | |
$this->assertEquals('484', $address->countryCodeNumeric); | |
} | |
- function testUpdate_withValidationErrors() | |
+ public function testUpdate_withValidationErrors() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $address = Braintree_Address::createNoValidate(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $address = Braintree\Address::createNoValidate([ | |
'customerId' => $customer->id, | |
'streetAddress' => '1 E Main St' | |
- )); | |
- $result = Braintree_Address::update( | |
+ ]); | |
+ $result = Braintree\Address::update( | |
$customer->id, | |
$address->id, | |
- array( | |
+ [ | |
'countryName' => 'Invalid States of America' | |
- ) | |
+ ] | |
); | |
$this->assertFalse($result->success); | |
$countryErrors = $result->errors->forKey('address')->onAttribute('countryName'); | |
- $this->assertEquals(Braintree_Error_Codes::ADDRESS_COUNTRY_NAME_IS_NOT_ACCEPTED, $countryErrors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::ADDRESS_COUNTRY_NAME_IS_NOT_ACCEPTED, $countryErrors[0]->code); | |
} | |
- function testUpdate_withValidationErrors_onCountry() | |
+ public function testUpdate_withValidationErrors_onCountry() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $address = Braintree_Address::createNoValidate(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $address = Braintree\Address::createNoValidate([ | |
'customerId' => $customer->id, | |
'streetAddress' => '1 E Main St' | |
- )); | |
- $result = Braintree_Address::update( | |
+ ]); | |
+ $result = Braintree\Address::update( | |
$customer->id, | |
$address->id, | |
- array( | |
+ [ | |
'countryCodeAlpha2' => 'MU', | |
'countryCodeAlpha3' => 'MYT' | |
- ) | |
+ ] | |
); | |
$this->assertFalse($result->success); | |
$countryErrors = $result->errors->forKey('address')->onAttribute('base'); | |
- $this->assertEquals(Braintree_Error_Codes::ADDRESS_INCONSISTENT_COUNTRY, $countryErrors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::ADDRESS_INCONSISTENT_COUNTRY, $countryErrors[0]->code); | |
} | |
- function testUpdateNoValidate() | |
+ public function testUpdateNoValidate() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $createdAddress = Braintree_Address::createNoValidate(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $createdAddress = Braintree\Address::createNoValidate([ | |
'customerId' => $customer->id, | |
'firstName' => 'Old First', | |
'lastName' => 'Old Last', | |
@@ -273,8 +278,8 @@ | |
'region' => 'Old Region', | |
'postalCode' => 'Old Postal', | |
'countryName' => 'United States of America' | |
- )); | |
- $address = Braintree_Address::updateNoValidate($customer->id, $createdAddress->id, array( | |
+ ]); | |
+ $address = Braintree\Address::updateNoValidate($customer->id, $createdAddress->id, [ | |
'firstName' => 'New First', | |
'lastName' => 'New Last', | |
'company' => 'New Company', | |
@@ -284,7 +289,7 @@ | |
'region' => 'New Region', | |
'postalCode' => 'New Postal', | |
'countryName' => 'Mexico' | |
- )); | |
+ ]); | |
$this->assertEquals('New First', $address->firstName); | |
$this->assertEquals('New Last', $address->lastName); | |
$this->assertEquals('New Company', $address->company); | |
Index: braintree_sdk/tests/integration/ClientTokenTest.php | |
=================================================================== | |
--- braintree_sdk/tests/integration/ClientTokenTest.php (revision 1387260) | |
+++ braintree_sdk/tests/integration/ClientTokenTest.php (working copy) | |
@@ -1,159 +1,164 @@ | |
<?php | |
-require_once realpath(dirname(__FILE__)) . '/../TestHelper.php'; | |
-require_once realpath(dirname(__FILE__)) . '/HttpClientApi.php'; | |
+namespace Test\Integration; | |
-class Braintree_ClientTokenTest extends PHPUnit_Framework_TestCase | |
+require_once dirname(__DIR__) . '/Setup.php'; | |
+ | |
+use Test; | |
+use Test\Setup; | |
+use Braintree; | |
+ | |
+class ClientTokenTest extends Setup | |
{ | |
- function test_ClientTokenAuthorizesRequest() | |
+ public function test_ClientTokenAuthorizesRequest() | |
{ | |
- $clientToken = Braintree_TestHelper::decodedClientToken(); | |
+ $clientToken = Test\Helper::decodedClientToken(); | |
$authorizationFingerprint = json_decode($clientToken)->authorizationFingerprint; | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $response = $http->get_cards(array( | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $response = $http->get_cards([ | |
"authorization_fingerprint" => $authorizationFingerprint, | |
"shared_customer_identifier" => "fake_identifier", | |
- "shared_customer_identifier_type" => "testing" | |
- )); | |
+ "shared_customer_identifier_type" => "testing", | |
+ ]); | |
$this->assertEquals(200, $response["status"]); | |
} | |
- function test_VersionOptionSupported() | |
+ public function test_VersionOptionSupported() | |
{ | |
- $clientToken = Braintree_ClientToken::generate(array("version" => 1)); | |
+ $clientToken = Braintree\ClientToken::generate(["version" => 1]); | |
$version = json_decode($clientToken)->version; | |
$this->assertEquals(1, $version); | |
} | |
- function test_VersionDefaultsToTwo() | |
+ public function test_VersionDefaultsToTwo() | |
{ | |
- $encodedClientToken = Braintree_ClientToken::generate(); | |
+ $encodedClientToken = Braintree\ClientToken::generate(); | |
$clientToken = base64_decode($encodedClientToken); | |
$version = json_decode($clientToken)->version; | |
$this->assertEquals(2, $version); | |
} | |
- function testGateway_VersionDefaultsToTwo() | |
+ public function testGateway_VersionDefaultsToTwo() | |
{ | |
- $gateway = new Braintree_Gateway(array( | |
+ $gateway = new Braintree\Gateway([ | |
'environment' => 'development', | |
'merchantId' => 'integration_merchant_id', | |
'publicKey' => 'integration_public_key', | |
- 'privateKey' => 'integration_private_key' | |
- )); | |
+ 'privateKey' => 'integration_private_key', | |
+ ]); | |
$encodedClientToken = $gateway->clientToken()->generate(); | |
$clientToken = base64_decode($encodedClientToken); | |
$version = json_decode($clientToken)->version; | |
$this->assertEquals(2, $version); | |
} | |
- function test_GatewayRespectsVerifyCard() | |
+ public function test_GatewayRespectsVerifyCard() | |
{ | |
- $result = Braintree_Customer::create(); | |
+ $result = Braintree\Customer::create(); | |
$this->assertTrue($result->success); | |
$customerId = $result->customer->id; | |
- $clientToken = Braintree_TestHelper::decodedClientToken(array( | |
+ $clientToken = Test\Helper::decodedClientToken([ | |
"customerId" => $customerId, | |
- "options" => array( | |
+ "options" => [ | |
"verifyCard" => true | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$authorizationFingerprint = json_decode($clientToken)->authorizationFingerprint; | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $response = $http->post('/client_api/v1/payment_methods/credit_cards.json', json_encode(array( | |
- "credit_card" => array( | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $response = $http->post('/client_api/v1/payment_methods/credit_cards.json', json_encode([ | |
+ "credit_card" => [ | |
"number" => "4000111111111115", | |
"expirationDate" => "11/2099" | |
- ), | |
+ ], | |
"authorization_fingerprint" => $authorizationFingerprint, | |
"shared_customer_identifier" => "fake_identifier", | |
"shared_customer_identifier_type" => "testing" | |
- ))); | |
+ ])); | |
$this->assertEquals(422, $response["status"]); | |
} | |
- function test_GatewayRespectsFailOnDuplicatePaymentMethod() | |
+ public function test_GatewayRespectsFailOnDuplicatePaymentMethod() | |
{ | |
- $result = Braintree_Customer::create(); | |
+ $result = Braintree\Customer::create(); | |
$this->assertTrue($result->success); | |
$customerId = $result->customer->id; | |
- $clientToken = Braintree_TestHelper::decodedClientToken(array( | |
+ $clientToken = Test\Helper::decodedClientToken([ | |
"customerId" => $customerId, | |
- )); | |
+ ]); | |
$authorizationFingerprint = json_decode($clientToken)->authorizationFingerprint; | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $response = $http->post('/client_api/v1/payment_methods/credit_cards.json', json_encode(array( | |
- "credit_card" => array( | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $response = $http->post('/client_api/v1/payment_methods/credit_cards.json', json_encode([ | |
+ "credit_card" => [ | |
"number" => "4242424242424242", | |
"expirationDate" => "11/2099" | |
- ), | |
+ ], | |
"authorization_fingerprint" => $authorizationFingerprint, | |
"shared_customer_identifier" => "fake_identifier", | |
"shared_customer_identifier_type" => "testing" | |
- ))); | |
+ ])); | |
$this->assertEquals(201, $response["status"]); | |
- $clientToken = Braintree_TestHelper::decodedClientToken(array( | |
+ $clientToken = Test\Helper::decodedClientToken([ | |
"customerId" => $customerId, | |
- "options" => array( | |
+ "options" => [ | |
"failOnDuplicatePaymentMethod" => true | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$authorizationFingerprint = json_decode($clientToken)->authorizationFingerprint; | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $response = $http->post('/client_api/v1/payment_methods/credit_cards.json', json_encode(array( | |
- "credit_card" => array( | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $response = $http->post('/client_api/v1/payment_methods/credit_cards.json', json_encode([ | |
+ "credit_card" => [ | |
"number" => "4242424242424242", | |
"expirationDate" => "11/2099" | |
- ), | |
+ ], | |
"authorization_fingerprint" => $authorizationFingerprint, | |
"shared_customer_identifier" => "fake_identifier", | |
"shared_customer_identifier_type" => "testing" | |
- ))); | |
+ ])); | |
$this->assertEquals(422, $response["status"]); | |
} | |
- function test_GatewayRespectsMakeDefault() | |
+ public function test_GatewayRespectsMakeDefault() | |
{ | |
- $result = Braintree_Customer::create(); | |
+ $result = Braintree\Customer::create(); | |
$this->assertTrue($result->success); | |
$customerId = $result->customer->id; | |
- $result = Braintree_CreditCard::create(array( | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customerId, | |
'number' => '4111111111111111', | |
'expirationDate' => '11/2099' | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
- $clientToken = Braintree_TestHelper::decodedClientToken(array( | |
+ $clientToken = Test\Helper::decodedClientToken([ | |
"customerId" => $customerId, | |
- "options" => array( | |
+ "options" => [ | |
"makeDefault" => true | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$authorizationFingerprint = json_decode($clientToken)->authorizationFingerprint; | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $response = $http->post('/client_api/v1/payment_methods/credit_cards.json', json_encode(array( | |
- "credit_card" => array( | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $response = $http->post('/client_api/v1/payment_methods/credit_cards.json', json_encode([ | |
+ "credit_card" => [ | |
"number" => "4242424242424242", | |
"expirationDate" => "11/2099" | |
- ), | |
+ ], | |
"authorization_fingerprint" => $authorizationFingerprint, | |
"shared_customer_identifier" => "fake_identifier", | |
"shared_customer_identifier_type" => "testing" | |
- ))); | |
+ ])); | |
$this->assertEquals(201, $response["status"]); | |
- $customer = Braintree_Customer::find($customerId); | |
+ $customer = Braintree\Customer::find($customerId); | |
$this->assertEquals(2, count($customer->creditCards)); | |
foreach ($customer->creditCards as $creditCard) { | |
if ($creditCard->last4 == "4242") { | |
@@ -162,22 +167,22 @@ | |
} | |
} | |
- function test_ClientTokenAcceptsMerchantAccountId() | |
+ public function test_ClientTokenAcceptsMerchantAccountId() | |
{ | |
- $clientToken = Braintree_TestHelper::decodedClientToken(array( | |
+ $clientToken = Test\Helper::decodedClientToken([ | |
'merchantAccountId' => 'my_merchant_account' | |
- )); | |
+ ]); | |
$merchantAccountId = json_decode($clientToken)->merchantAccountId; | |
$this->assertEquals('my_merchant_account', $merchantAccountId); | |
} | |
- function test_GenerateRaisesExceptionOnGateway422() | |
+ public function test_GenerateRaisesExceptionOnGateway422() | |
{ | |
$this->setExpectedException('InvalidArgumentException', 'customer_id'); | |
- Braintree_ClientToken::generate(array( | |
+ Braintree\ClientToken::generate([ | |
"customerId" => "not_a_customer" | |
- )); | |
+ ]); | |
} | |
} | |
Index: braintree_sdk/tests/integration/CreditCardTest.php | |
=================================================================== | |
--- braintree_sdk/tests/integration/CreditCardTest.php (revision 1387260) | |
+++ braintree_sdk/tests/integration/CreditCardTest.php (working copy) | |
@@ -1,18 +1,24 @@ | |
<?php | |
-require_once realpath(dirname(__FILE__)) . '/../TestHelper.php'; | |
-require_once realpath(dirname(__FILE__)) . '/HttpClientApi.php'; | |
+namespace Test\Integration; | |
-class Braintree_CreditCardTest extends PHPUnit_Framework_TestCase | |
+require_once dirname(__DIR__) . '/Setup.php'; | |
+ | |
+use Test; | |
+use Test\Braintree\CreditCardNumbers\CardTypeIndicators; | |
+use Test\Setup; | |
+use Braintree; | |
+ | |
+class CreditCardTest extends Setup | |
{ | |
- function testCreate() | |
+ public function testCreate() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'cardholderName' => 'Cardholder', | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
$this->assertEquals($customer->id, $result->creditCard->customerId); | |
$this->assertEquals('510510', $result->creditCard->bin); | |
@@ -24,22 +30,22 @@ | |
$this->assertEquals(1, preg_match('/png/', $result->creditCard->imageUrl)); | |
} | |
- function testGatewayCreate() | |
+ public function testGatewayCreate() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
+ $customer = Braintree\Customer::createNoValidate(); | |
- $gateway = new Braintree_Gateway(array( | |
+ $gateway = new Braintree\Gateway([ | |
'environment' => 'development', | |
'merchantId' => 'integration_merchant_id', | |
'publicKey' => 'integration_public_key', | |
'privateKey' => 'integration_private_key' | |
- )); | |
- $result = $gateway->creditCard()->create(array( | |
+ ]); | |
+ $result = $gateway->creditCard()->create([ | |
'customerId' => $customer->id, | |
'cardholderName' => 'Cardholder', | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
$this->assertEquals($customer->id, $result->creditCard->customerId); | |
@@ -49,79 +55,103 @@ | |
$this->assertEquals('05/2012', $result->creditCard->expirationDate); | |
} | |
- function testCreate_withDefault() | |
+ public function testCreate_withDefault() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $card1 = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $card1 = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'cardholderName' => 'Cardholder', | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- ))->creditCard; | |
+ ])->creditCard; | |
$this->assertTrue($card1->isDefault()); | |
- $card2 = Braintree_CreditCard::create(array( | |
+ $card2 = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'cardholderName' => 'Cardholder', | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12', | |
- 'options' => array( | |
+ 'options' => [ | |
'makeDefault' => true | |
- ) | |
- ))->creditCard; | |
+ ] | |
+ ])->creditCard; | |
- $card1 = Braintree_CreditCard::find($card1->token); | |
+ $card1 = Braintree\CreditCard::find($card1->token); | |
$this->assertFalse($card1->isDefault()); | |
$this->assertTrue($card2->isDefault()); | |
} | |
- function testAddCardToExistingCustomerUsingNonce() | |
+ public function testCreateWithVerificationAmount() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonce_for_new_card(array( | |
- "credit_card" => array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
+ 'customerId' => $customer->id, | |
+ 'cardholderName' => 'Cardholder', | |
+ 'number' => '4111111111111111', | |
+ 'expirationDate' => '05/12', | |
+ 'options' => [ | |
+ 'verificationAmount' => '5.00', | |
+ 'verifyCard' => true | |
+ ] | |
+ ]); | |
+ $this->assertTrue($result->success); | |
+ $this->assertEquals($customer->id, $result->creditCard->customerId); | |
+ $this->assertEquals('411111', $result->creditCard->bin); | |
+ $this->assertEquals('1111', $result->creditCard->last4); | |
+ $this->assertEquals('Cardholder', $result->creditCard->cardholderName); | |
+ $this->assertEquals('05/2012', $result->creditCard->expirationDate); | |
+ $this->assertEquals(1, preg_match('/\A\w{32}\z/', $result->creditCard->uniqueNumberIdentifier)); | |
+ $this->assertFalse($result->creditCard->isVenmoSdk()); | |
+ $this->assertEquals(1, preg_match('/png/', $result->creditCard->imageUrl)); | |
+ } | |
+ | |
+ public function testAddCardToExistingCustomerUsingNonce() | |
+ { | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonce_for_new_card([ | |
+ "credit_card" => [ | |
"number" => "4111111111111111", | |
"expirationMonth" => "11", | |
"expirationYear" => "2099" | |
- ), | |
+ ], | |
"share" => true | |
- )); | |
+ ]); | |
- $result = Braintree_CreditCard::create(array( | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'paymentMethodNonce' => $nonce | |
- )); | |
+ ]); | |
$this->assertSame("411111", $result->creditCard->bin); | |
$this->assertSame("1111", $result->creditCard->last4); | |
} | |
- function testCreate_withSecurityParams() | |
+ public function testCreate_withSecurityParams() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'deviceSessionId' => 'abc_123', | |
'fraudMerchantId' => '456', | |
'cardholderName' => 'Cardholder', | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
} | |
- function testCreate_withExpirationMonthAndYear() | |
+ public function testCreate_withExpirationMonthAndYear() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'cardholderName' => 'Cardholder', | |
'number' => '5105105105105100', | |
'expirationMonth' => '05', | |
'expirationYear' => '2011' | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
$this->assertEquals($customer->id, $result->creditCard->customerId); | |
$this->assertEquals('510510', $result->creditCard->bin); | |
@@ -130,105 +160,105 @@ | |
$this->assertEquals('05/2011', $result->creditCard->expirationDate); | |
} | |
- function testCreate_withSpecifyingToken() | |
+ public function testCreate_withSpecifyingToken() | |
{ | |
$token = strval(rand()); | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'number' => '5105105105105100', | |
'expirationDate' => '05/2011', | |
'token' => $token | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
$this->assertEquals($token, $result->creditCard->token); | |
- $this->assertEquals($token, Braintree_CreditCard::find($token)->token); | |
+ $this->assertEquals($token, Braintree\CreditCard::find($token)->token); | |
} | |
- function testCreate_withDuplicateCardCheck() | |
+ public function testCreate_withDuplicateCardCheck() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
+ $customer = Braintree\Customer::createNoValidate(); | |
- $attributes = array( | |
+ $attributes = [ | |
'customerId' => $customer->id, | |
'number' => '5105105105105100', | |
'expirationDate' => '05/2011', | |
- 'options' => array('failOnDuplicatePaymentMethod' => true) | |
- ); | |
- Braintree_CreditCard::create($attributes); | |
+ 'options' => ['failOnDuplicatePaymentMethod' => true] | |
+ ]; | |
+ Braintree\CreditCard::create($attributes); | |
- $result = Braintree_CreditCard::create($attributes); | |
+ $result = Braintree\CreditCard::create($attributes); | |
$this->assertFalse($result->success); | |
$errors = $result->errors->forKey('creditCard')->onAttribute('number'); | |
- $this->assertEquals(Braintree_Error_Codes::CREDIT_CARD_DUPLICATE_CARD_EXISTS, $errors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::CREDIT_CARD_DUPLICATE_CARD_EXISTS, $errors[0]->code); | |
$this->assertEquals(1, preg_match('/Duplicate card exists in the vault\./', $result->message)); | |
} | |
- function testCreate_withCardVerification() | |
+ public function testCreate_withCardVerification() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'number' => '5105105105105100', | |
'expirationDate' => '05/2011', | |
- 'options' => array('verifyCard' => true) | |
- )); | |
+ 'options' => ['verifyCard' => true] | |
+ ]); | |
$this->assertFalse($result->success); | |
- $this->assertEquals(Braintree_Result_CreditCardVerification::PROCESSOR_DECLINED, $result->creditCardVerification->status); | |
+ $this->assertEquals(Braintree\Result\CreditCardVerification::PROCESSOR_DECLINED, $result->creditCardVerification->status); | |
$this->assertEquals('2000', $result->creditCardVerification->processorResponseCode); | |
$this->assertEquals('Do Not Honor', $result->creditCardVerification->processorResponseText); | |
$this->assertEquals('I', $result->creditCardVerification->cvvResponseCode); | |
$this->assertEquals(null, $result->creditCardVerification->avsErrorResponseCode); | |
$this->assertEquals('I', $result->creditCardVerification->avsPostalCodeResponseCode); | |
$this->assertEquals('I', $result->creditCardVerification->avsStreetAddressResponseCode); | |
- $this->assertEquals(Braintree_CreditCard::PREPAID_UNKNOWN, $result->creditCardVerification->creditCard["prepaid"]); | |
+ $this->assertEquals(Braintree\CreditCard::PREPAID_UNKNOWN, $result->creditCardVerification->creditCard['prepaid']); | |
} | |
- function testCreate_withCardVerificationReturnsVerificationWithRiskData() | |
+ public function testCreate_withCardVerificationReturnsVerificationWithRiskData() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'number' => '4111111111111111', | |
'expirationDate' => '05/2011', | |
- 'options' => array('verifyCard' => true) | |
- )); | |
+ 'options' => ['verifyCard' => true] | |
+ ]); | |
$this->assertTrue($result->success); | |
$this->assertNotNull($result->creditCard->verification->riskData); | |
$this->assertNotNull($result->creditCard->verification->riskData->decision); | |
} | |
- function testCreate_withCardVerificationAndOverriddenAmount() | |
+ public function testCreate_withCardVerificationAndOverriddenAmount() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'number' => '5105105105105100', | |
'expirationDate' => '05/2011', | |
- 'options' => array('verifyCard' => true, 'verificationAmount' => '1.02') | |
- )); | |
+ 'options' => ['verifyCard' => true, 'verificationAmount' => '1.02'] | |
+ ]); | |
$this->assertFalse($result->success); | |
- $this->assertEquals(Braintree_Result_CreditCardVerification::PROCESSOR_DECLINED, $result->creditCardVerification->status); | |
+ $this->assertEquals(Braintree\Result\CreditCardVerification::PROCESSOR_DECLINED, $result->creditCardVerification->status); | |
$this->assertEquals('2000', $result->creditCardVerification->processorResponseCode); | |
$this->assertEquals('Do Not Honor', $result->creditCardVerification->processorResponseText); | |
$this->assertEquals('I', $result->creditCardVerification->cvvResponseCode); | |
$this->assertEquals(null, $result->creditCardVerification->avsErrorResponseCode); | |
$this->assertEquals('I', $result->creditCardVerification->avsPostalCodeResponseCode); | |
$this->assertEquals('I', $result->creditCardVerification->avsStreetAddressResponseCode); | |
- $this->assertEquals(Braintree_CreditCard::PREPAID_UNKNOWN, $result->creditCardVerification->creditCard["prepaid"]); | |
+ $this->assertEquals(Braintree\CreditCard::PREPAID_UNKNOWN, $result->creditCardVerification->creditCard['prepaid']); | |
} | |
- function testCreate_withCardVerificationAndSpecificMerchantAccount() | |
+ public function testCreate_withCardVerificationAndSpecificMerchantAccount() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'number' => '5105105105105100', | |
'expirationDate' => '05/2011', | |
- 'options' => array('verificationMerchantAccountId' => Braintree_TestHelper::nonDefaultMerchantAccountId(), 'verifyCard' => true) | |
- )); | |
+ 'options' => ['verificationMerchantAccountId' => Test\Helper::nonDefaultMerchantAccountId(), 'verifyCard' => true], | |
+ ]); | |
$this->assertFalse($result->success); | |
- $this->assertEquals(Braintree_Result_CreditCardVerification::PROCESSOR_DECLINED, $result->creditCardVerification->status); | |
+ $this->assertEquals(Braintree\Result\CreditCardVerification::PROCESSOR_DECLINED, $result->creditCardVerification->status); | |
$this->assertEquals('2000', $result->creditCardVerification->processorResponseCode); | |
$this->assertEquals('Do Not Honor', $result->creditCardVerification->processorResponseText); | |
$this->assertEquals('I', $result->creditCardVerification->cvvResponseCode); | |
@@ -237,15 +267,15 @@ | |
$this->assertEquals('I', $result->creditCardVerification->avsStreetAddressResponseCode); | |
} | |
- function testCreate_withBillingAddress() | |
+ public function testCreate_withBillingAddress() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'cardholderName' => 'Peter Tomlin', | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12', | |
- 'billingAddress' => array( | |
+ 'billingAddress' => [ | |
'firstName' => 'Drew', | |
'lastName' => 'Smith', | |
'company' => 'Smith Co.', | |
@@ -258,8 +288,8 @@ | |
'countryCodeAlpha2' => 'FM', | |
'countryCodeAlpha3' => 'FSM', | |
'countryCodeNumeric' => '583' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$this->assertTrue($result->success); | |
$this->assertEquals($customer->id, $result->creditCard->customerId); | |
$this->assertEquals('510510', $result->creditCard->bin); | |
@@ -281,119 +311,119 @@ | |
$this->assertEquals('583', $address->countryCodeNumeric); | |
} | |
- function testCreate_withExistingBillingAddress() | |
+ public function testCreate_withExistingBillingAddress() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $existingAddress = Braintree_Address::createNoValidate(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $existingAddress = Braintree\Address::createNoValidate([ | |
'customerId' => $customer->id, | |
'firstName' => 'John' | |
- )); | |
- $result = Braintree_CreditCard::create(array( | |
+ ]); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12', | |
'billingAddressId' => $existingAddress->id | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
$address = $result->creditCard->billingAddress; | |
$this->assertEquals($existingAddress->id, $address->id); | |
$this->assertEquals('John', $address->firstName); | |
} | |
- function testCreate_withValidationErrors() | |
+ public function testCreate_withValidationErrors() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'expirationDate' => 'invalid', | |
- 'billingAddress' => array( | |
+ 'billingAddress' => [ | |
'countryName' => 'Tuvalu', | |
'countryCodeAlpha2' => 'US' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$this->assertFalse($result->success); | |
$errors = $result->errors->forKey('creditCard')->onAttribute('expirationDate'); | |
- $this->assertEquals(Braintree_Error_Codes::CREDIT_CARD_EXPIRATION_DATE_IS_INVALID, $errors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::CREDIT_CARD_EXPIRATION_DATE_IS_INVALID, $errors[0]->code); | |
$this->assertEquals(1, preg_match('/Credit card number is required\./', $result->message)); | |
$this->assertEquals(1, preg_match('/Customer ID is required\./', $result->message)); | |
$this->assertEquals(1, preg_match('/Expiration date is invalid\./', $result->message)); | |
$errors = $result->errors->forKey('creditCard')->forKey('billingAddress')->onAttribute('base'); | |
- $this->assertEquals(Braintree_Error_Codes::ADDRESS_INCONSISTENT_COUNTRY, $errors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::ADDRESS_INCONSISTENT_COUNTRY, $errors[0]->code); | |
} | |
- function testCreate_withVenmoSdkPaymentMethodCode() | |
+ public function testCreate_withVenmoSdkPaymentMethodCode() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
- 'venmoSdkPaymentMethodCode' => Braintree_Test_VenmoSdk::generateTestPaymentMethodCode("378734493671000") | |
- )); | |
+ 'venmoSdkPaymentMethodCode' => Braintree\Test\VenmoSdk::generateTestPaymentMethodCode('378734493671000') | |
+ ]); | |
$this->assertTrue($result->success); | |
$this->assertEquals("378734", $result->creditCard->bin); | |
} | |
- function testCreate_with_invalid_venmoSdkPaymentMethodCode() | |
+ public function testCreate_with_invalid_venmoSdkPaymentMethodCode() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
- 'venmoSdkPaymentMethodCode' => Braintree_Test_VenmoSdk::getInvalidPaymentMethodCode() | |
- )); | |
+ 'venmoSdkPaymentMethodCode' => Braintree\Test\VenmoSdk::getInvalidPaymentMethodCode(), | |
+ ]); | |
$this->assertFalse($result->success); | |
$errors = $result->errors->forKey('creditCard')->onAttribute('venmoSdkPaymentMethodCode'); | |
- $this->assertEquals($errors[0]->code, Braintree_Error_Codes::CREDIT_CARD_INVALID_VENMO_SDK_PAYMENT_METHOD_CODE); | |
+ $this->assertEquals($errors[0]->code, Braintree\Error\Codes::CREDIT_CARD_INVALID_VENMO_SDK_PAYMENT_METHOD_CODE); | |
} | |
- function testCreate_with_venmoSdkSession() | |
+ public function testCreate_with_venmoSdkSession() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12', | |
- 'options' => array( | |
- 'venmoSdkSession' => Braintree_Test_VenmoSdk::getTestSession() | |
- ) | |
- )); | |
+ 'options' => [ | |
+ 'venmoSdkSession' => Braintree\Test\VenmoSdk::getTestSession() | |
+ ] | |
+ ]); | |
$this->assertTrue($result->success); | |
$this->assertTrue($result->creditCard->isVenmoSdk()); | |
} | |
- function testCreate_with_invalidVenmoSdkSession() | |
+ public function testCreate_with_invalidVenmoSdkSession() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12', | |
- 'options' => array( | |
- 'venmoSdkSession' => Braintree_Test_VenmoSdk::getInvalidTestSession() | |
- ) | |
- )); | |
+ 'options' => [ | |
+ 'venmoSdkSession' => Braintree\Test\VenmoSdk::getInvalidTestSession(), | |
+ ] | |
+ ]); | |
$this->assertTrue($result->success); | |
$this->assertFalse($result->creditCard->isVenmoSdk()); | |
} | |
- function testCreateNoValidate_throwsIfValidationsFail() | |
+ public function testCreateNoValidate_throwsIfValidationsFail() | |
{ | |
- $this->setExpectedException('Braintree_Exception_ValidationsFailed'); | |
- $customer = Braintree_Customer::createNoValidate(); | |
- Braintree_CreditCard::createNoValidate(array( | |
+ $this->setExpectedException('Braintree\Exception\ValidationsFailed'); | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ Braintree\CreditCard::createNoValidate([ | |
'expirationDate' => 'invalid', | |
- )); | |
+ ]); | |
} | |
- function testCreateNoValidate_returnsCreditCardIfValid() | |
+ public function testCreateNoValidate_returnsCreditCardIfValid() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $creditCard = Braintree_CreditCard::createNoValidate(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $creditCard = Braintree\CreditCard::createNoValidate([ | |
'customerId' => $customer->id, | |
'cardholderName' => 'Cardholder', | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- )); | |
+ ]); | |
$this->assertEquals($customer->id, $creditCard->customerId); | |
$this->assertEquals('510510', $creditCard->bin); | |
$this->assertEquals('5100', $creditCard->last4); | |
@@ -401,114 +431,114 @@ | |
$this->assertEquals('05/2012', $creditCard->expirationDate); | |
} | |
- function testCreateFromTransparentRedirect() | |
+ public function testCreateFromTransparentRedirect() | |
{ | |
- Braintree_TestHelper::suppressDeprecationWarnings(); | |
- $customer = Braintree_Customer::createNoValidate(); | |
+ Test\Helper::suppressDeprecationWarnings(); | |
+ $customer = Braintree\Customer::createNoValidate(); | |
$queryString = $this->createCreditCardViaTr( | |
- array( | |
- 'credit_card' => array( | |
+ [ | |
+ 'credit_card' => [ | |
'number' => '5105105105105100', | |
'expiration_date' => '05/12' | |
- ) | |
- ), | |
- array( | |
- 'creditCard' => array( | |
+ ] | |
+ ], | |
+ [ | |
+ 'creditCard' => [ | |
'customerId' => $customer->id | |
- ) | |
- ) | |
+ ] | |
+ ] | |
); | |
- $result = Braintree_CreditCard::createFromTransparentRedirect($queryString); | |
+ $result = Braintree\CreditCard::createFromTransparentRedirect($queryString); | |
$this->assertTrue($result->success); | |
$this->assertEquals('510510', $result->creditCard->bin); | |
$this->assertEquals('5100', $result->creditCard->last4); | |
$this->assertEquals('05/2012', $result->creditCard->expirationDate); | |
} | |
- function testCreateFromTransparentRedirect_withDefault() | |
+ public function testCreateFromTransparentRedirect_withDefault() | |
{ | |
- Braintree_TestHelper::suppressDeprecationWarnings(); | |
- $customer = Braintree_Customer::createNoValidate(); | |
+ Test\Helper::suppressDeprecationWarnings(); | |
+ $customer = Braintree\Customer::createNoValidate(); | |
$queryString = $this->createCreditCardViaTr( | |
- array( | |
- 'credit_card' => array( | |
+ [ | |
+ 'credit_card' => [ | |
'number' => '5105105105105100', | |
'expiration_date' => '05/12', | |
- 'options' => array('make_default' => true) | |
- ) | |
- ), | |
- array( | |
- 'creditCard' => array( | |
+ 'options' => ['make_default' => true] | |
+ ] | |
+ ], | |
+ [ | |
+ 'creditCard' => [ | |
'customerId' => $customer->id | |
- ) | |
- ) | |
+ ] | |
+ ] | |
); | |
- $result = Braintree_CreditCard::createFromTransparentRedirect($queryString); | |
+ $result = Braintree\CreditCard::createFromTransparentRedirect($queryString); | |
$this->assertTrue($result->creditCard->isDefault()); | |
} | |
- function testUpdateFromTransparentRedirect() | |
+ public function testUpdateFromTransparentRedirect() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $creditCard = Braintree_CreditCard::createNoValidate(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $creditCard = Braintree\CreditCard::createNoValidate([ | |
'customerId' => $customer->id, | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- )); | |
+ ]); | |
$queryString = $this->updateCreditCardViaTr( | |
- array( | |
- 'credit_card' => array( | |
+ [ | |
+ 'credit_card' => [ | |
'number' => '4111111111111111', | |
'expiration_date' => '01/11' | |
- ) | |
- ), | |
- array('paymentMethodToken' => $creditCard->token) | |
+ ] | |
+ ], | |
+ ['paymentMethodToken' => $creditCard->token] | |
); | |
- $result = Braintree_CreditCard::updateFromTransparentRedirect($queryString); | |
+ $result = Braintree\CreditCard::updateFromTransparentRedirect($queryString); | |
$this->assertTrue($result->success); | |
$this->assertEquals('411111', $result->creditCard->bin); | |
$this->assertEquals('1111', $result->creditCard->last4); | |
$this->assertEquals('01/2011', $result->creditCard->expirationDate); | |
} | |
- function testUpdateFromTransparentRedirect_withDefault() | |
+ public function testUpdateFromTransparentRedirect_withDefault() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $card1 = Braintree_CreditCard::createNoValidate(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $card1 = Braintree\CreditCard::createNoValidate([ | |
'customerId' => $customer->id, | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- )); | |
- $card2 = Braintree_CreditCard::createNoValidate(array( | |
+ ]); | |
+ $card2 = Braintree\CreditCard::createNoValidate([ | |
'customerId' => $customer->id, | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- )); | |
+ ]); | |
$this->assertFalse($card2->isDefault()); | |
$queryString = $this->updateCreditCardViaTr( | |
- array( | |
- 'credit_card' => array( | |
- 'options' => array( | |
+ [ | |
+ 'credit_card' => [ | |
+ 'options' => [ | |
'make_default' => true | |
- ) | |
- ) | |
- ), | |
- array('paymentMethodToken' => $card2->token) | |
+ ] | |
+ ] | |
+ ], | |
+ ['paymentMethodToken' => $card2->token] | |
); | |
- $result = Braintree_CreditCard::updateFromTransparentRedirect($queryString); | |
- $this->assertFalse(Braintree_CreditCard::find($card1->token)->isDefault()); | |
- $this->assertTrue(Braintree_CreditCard::find($card2->token)->isDefault()); | |
+ $result = Braintree\CreditCard::updateFromTransparentRedirect($queryString); | |
+ $this->assertFalse(Braintree\CreditCard::find($card1->token)->isDefault()); | |
+ $this->assertTrue(Braintree\CreditCard::find($card2->token)->isDefault()); | |
} | |
- function testUpdateFromTransparentRedirect_andUpdateExistingBillingAddress() | |
+ public function testUpdateFromTransparentRedirect_andUpdateExistingBillingAddress() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $card = Braintree_CreditCard::createNoValidate(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $card = Braintree\CreditCard::createNoValidate([ | |
'customerId' => $customer->id, | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12', | |
- 'billingAddress' => array( | |
+ 'billingAddress' => [ | |
'firstName' => 'Drew', | |
'lastName' => 'Smith', | |
'company' => 'Smith Co.', | |
@@ -518,165 +548,165 @@ | |
'region' => 'IL', | |
'postalCode' => '60622', | |
'countryName' => 'United States of America' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$queryString = $this->updateCreditCardViaTr( | |
- array(), | |
- array( | |
+ [], | |
+ [ | |
'paymentMethodToken' => $card->token, | |
- 'creditCard' => array( | |
- 'billingAddress' => array( | |
+ 'creditCard' => [ | |
+ 'billingAddress' => [ | |
'streetAddress' => '123 New St', | |
'locality' => 'St. Louis', | |
'region' => 'MO', | |
'postalCode' => '63119', | |
- 'options' => array( | |
+ 'options' => [ | |
'updateExisting' => True | |
- ) | |
- ) | |
- ) | |
- ) | |
+ ] | |
+ ] | |
+ ] | |
+ ] | |
); | |
- $result = Braintree_CreditCard::updateFromTransparentRedirect($queryString); | |
+ $result = Braintree\CreditCard::updateFromTransparentRedirect($queryString); | |
$this->assertTrue($result->success); | |
$card = $result->creditCard; | |
- $this->assertEquals(1, sizeof(Braintree_Customer::find($customer->id)->addresses)); | |
+ $this->assertEquals(1, sizeof(Braintree\Customer::find($customer->id)->addresses)); | |
$this->assertEquals('123 New St', $card->billingAddress->streetAddress); | |
$this->assertEquals('St. Louis', $card->billingAddress->locality); | |
$this->assertEquals('MO', $card->billingAddress->region); | |
$this->assertEquals('63119', $card->billingAddress->postalCode); | |
} | |
- function testSale_createsASaleUsingGivenToken() | |
+ public function testSale_createsASaleUsingGivenToken() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(array( | |
- 'creditCard' => array( | |
+ $customer = Braintree\Customer::createNoValidate([ | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$creditCard = $customer->creditCards[0]; | |
- $result = Braintree_CreditCard::sale($creditCard->token, array( | |
+ $result = Braintree\CreditCard::sale($creditCard->token, [ | |
'amount' => '100.00' | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
$this->assertEquals('100.00', $result->transaction->amount); | |
$this->assertEquals($customer->id, $result->transaction->customerDetails->id); | |
$this->assertEquals($creditCard->token, $result->transaction->creditCardDetails->token); | |
} | |
- function testSaleNoValidate_createsASaleUsingGivenToken() | |
+ public function testSaleNoValidate_createsASaleUsingGivenToken() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(array( | |
- 'creditCard' => array( | |
+ $customer = Braintree\Customer::createNoValidate([ | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$creditCard = $customer->creditCards[0]; | |
- $transaction = Braintree_CreditCard::saleNoValidate($creditCard->token, array( | |
+ $transaction = Braintree\CreditCard::saleNoValidate($creditCard->token, [ | |
'amount' => '100.00' | |
- )); | |
+ ]); | |
$this->assertEquals('100.00', $transaction->amount); | |
$this->assertEquals($customer->id, $transaction->customerDetails->id); | |
$this->assertEquals($creditCard->token, $transaction->creditCardDetails->token); | |
} | |
- function testSaleNoValidate_createsASaleUsingGivenTokenAndCvv() | |
+ public function testSaleNoValidate_createsASaleUsingGivenTokenAndCvv() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(array( | |
- 'creditCard' => array( | |
+ $customer = Braintree\Customer::createNoValidate([ | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$creditCard = $customer->creditCards[0]; | |
- $transaction = Braintree_CreditCard::saleNoValidate($creditCard->token, array( | |
+ $transaction = Braintree\CreditCard::saleNoValidate($creditCard->token, [ | |
'amount' => '100.00', | |
- 'creditCard' => array( | |
+ 'creditCard' => [ | |
'cvv' => '301' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$this->assertEquals('100.00', $transaction->amount); | |
$this->assertEquals($customer->id, $transaction->customerDetails->id); | |
$this->assertEquals($creditCard->token, $transaction->creditCardDetails->token); | |
$this->assertEquals('S', $transaction->cvvResponseCode); | |
} | |
- function testSaleNoValidate_throwsIfInvalid() | |
+ public function testSaleNoValidate_throwsIfInvalid() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(array( | |
- 'creditCard' => array( | |
+ $customer = Braintree\Customer::createNoValidate([ | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$creditCard = $customer->creditCards[0]; | |
- $this->setExpectedException('Braintree_Exception_ValidationsFailed'); | |
- Braintree_CreditCard::saleNoValidate($creditCard->token, array( | |
+ $this->setExpectedException('Braintree\Exception\ValidationsFailed'); | |
+ Braintree\CreditCard::saleNoValidate($creditCard->token, [ | |
'amount' => 'invalid' | |
- )); | |
+ ]); | |
} | |
- function testCredit_createsACreditUsingGivenToken() | |
+ public function testCredit_createsACreditUsingGivenToken() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(array( | |
- 'creditCard' => array( | |
+ $customer = Braintree\Customer::createNoValidate([ | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$creditCard = $customer->creditCards[0]; | |
- $result = Braintree_CreditCard::credit($creditCard->token, array( | |
+ $result = Braintree\CreditCard::credit($creditCard->token, [ | |
'amount' => '100.00' | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
$this->assertEquals('100.00', $result->transaction->amount); | |
- $this->assertEquals(Braintree_Transaction::CREDIT, $result->transaction->type); | |
+ $this->assertEquals(Braintree\Transaction::CREDIT, $result->transaction->type); | |
$this->assertEquals($customer->id, $result->transaction->customerDetails->id); | |
$this->assertEquals($creditCard->token, $result->transaction->creditCardDetails->token); | |
} | |
- function testCreditNoValidate_createsACreditUsingGivenToken() | |
+ public function testCreditNoValidate_createsACreditUsingGivenToken() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(array( | |
- 'creditCard' => array( | |
+ $customer = Braintree\Customer::createNoValidate([ | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$creditCard = $customer->creditCards[0]; | |
- $transaction = Braintree_CreditCard::creditNoValidate($creditCard->token, array( | |
+ $transaction = Braintree\CreditCard::creditNoValidate($creditCard->token, [ | |
'amount' => '100.00' | |
- )); | |
+ ]); | |
$this->assertEquals('100.00', $transaction->amount); | |
- $this->assertEquals(Braintree_Transaction::CREDIT, $transaction->type); | |
+ $this->assertEquals(Braintree\Transaction::CREDIT, $transaction->type); | |
$this->assertEquals($customer->id, $transaction->customerDetails->id); | |
$this->assertEquals($creditCard->token, $transaction->creditCardDetails->token); | |
} | |
- function testCreditNoValidate_throwsIfInvalid() | |
+ public function testCreditNoValidate_throwsIfInvalid() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(array( | |
- 'creditCard' => array( | |
+ $customer = Braintree\Customer::createNoValidate([ | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$creditCard = $customer->creditCards[0]; | |
- $this->setExpectedException('Braintree_Exception_ValidationsFailed'); | |
- Braintree_CreditCard::creditNoValidate($creditCard->token, array( | |
+ $this->setExpectedException('Braintree\Exception\ValidationsFailed'); | |
+ Braintree\CreditCard::creditNoValidate($creditCard->token, [ | |
'amount' => 'invalid' | |
- )); | |
+ ]); | |
} | |
- function testExpired() | |
+ public function testExpired() | |
{ | |
- $collection = Braintree_CreditCard::expired(); | |
+ $collection = Braintree\CreditCard::expired(); | |
$this->assertTrue($collection->maximumCount() > 1); | |
- $arr = array(); | |
+ $arr = []; | |
foreach($collection as $creditCard) { | |
$this->assertTrue($creditCard->isExpired()); | |
array_push($arr, $creditCard->token); | |
@@ -686,15 +716,15 @@ | |
} | |
- function testExpiringBetween() | |
+ public function testExpiringBetween() | |
{ | |
- $collection = Braintree_CreditCard::expiringBetween( | |
+ $collection = Braintree\CreditCard::expiringBetween( | |
mktime(0, 0, 0, 1, 1, 2010), | |
mktime(23, 59, 59, 12, 31, 2010) | |
); | |
$this->assertTrue($collection->maximumCount() > 1); | |
- $arr = array(); | |
+ $arr = []; | |
foreach($collection as $creditCard) { | |
$this->assertEquals('2010', $creditCard->expirationYear); | |
array_push($arr, $creditCard->token); | |
@@ -703,9 +733,9 @@ | |
$this->assertEquals($collection->maximumCount(), count($uniqueCreditCardTokens)); | |
} | |
- function testExpiringBetween_parsesCreditCardDetailsUnderTransactionsCorrectly() | |
+ public function testExpiringBetween_parsesCreditCardDetailsUnderTransactionsCorrectly() | |
{ | |
- $collection = Braintree_CreditCard::expiringBetween( | |
+ $collection = Braintree\CreditCard::expiringBetween( | |
mktime(0, 0, 0, 1, 1, 2010), | |
mktime(23, 59, 59, 12, 31, 2010) | |
); | |
@@ -720,34 +750,34 @@ | |
} | |
} | |
- function testFind() | |
+ public function testFind() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'cardholderName' => 'Cardholder', | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
- $creditCard = Braintree_CreditCard::find($result->creditCard->token); | |
+ $creditCard = Braintree\CreditCard::find($result->creditCard->token); | |
$this->assertEquals($customer->id, $creditCard->customerId); | |
$this->assertEquals('510510', $creditCard->bin); | |
$this->assertEquals('5100', $creditCard->last4); | |
$this->assertEquals('Cardholder', $creditCard->cardholderName); | |
$this->assertEquals('05/2012', $creditCard->expirationDate); | |
- $this->assertEquals(array(), $creditCard->subscriptions); | |
+ $this->assertEquals([], $creditCard->subscriptions); | |
} | |
- function testFindReturnsAssociatedSubscriptions() | |
+ public function testFindReturnsAssociatedSubscriptions() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'cardholderName' => 'Cardholder', | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12', | |
- 'billingAddress' => array( | |
+ 'billingAddress' => [ | |
'firstName' => 'Drew', | |
'lastName' => 'Smith', | |
'company' => 'Smith Co.', | |
@@ -757,107 +787,107 @@ | |
'region' => 'IL', | |
'postalCode' => '60622', | |
'countryName' => 'United States of America' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$id = strval(rand()); | |
- Braintree_Subscription::create(array( | |
+ Braintree\Subscription::create([ | |
'id' => $id, | |
'paymentMethodToken' => $result->creditCard->token, | |
'planId' => 'integration_trialless_plan', | |
'price' => '1.00' | |
- )); | |
- $creditCard = Braintree_CreditCard::find($result->creditCard->token); | |
+ ]); | |
+ $creditCard = Braintree\CreditCard::find($result->creditCard->token); | |
$this->assertEquals($id, $creditCard->subscriptions[0]->id); | |
$this->assertEquals('integration_trialless_plan', $creditCard->subscriptions[0]->planId); | |
$this->assertEquals('1.00', $creditCard->subscriptions[0]->price); | |
} | |
- function testFind_throwsIfCannotBeFound() | |
+ public function testFind_throwsIfCannotBeFound() | |
{ | |
- $this->setExpectedException('Braintree_Exception_NotFound'); | |
- Braintree_CreditCard::find('invalid-token'); | |
+ $this->setExpectedException('Braintree\Exception\NotFound'); | |
+ Braintree\CreditCard::find('invalid-token'); | |
} | |
- function testFind_throwsUsefulErrorMessagesWhenEmpty() | |
+ public function testFind_throwsUsefulErrorMessagesWhenEmpty() | |
{ | |
$this->setExpectedException('InvalidArgumentException', 'expected credit card id to be set'); | |
- Braintree_CreditCard::find(''); | |
+ Braintree\CreditCard::find(''); | |
} | |
- function testFind_throwsUsefulErrorMessagesWhenInvalid() | |
+ public function testFind_throwsUsefulErrorMessagesWhenInvalid() | |
{ | |
$this->setExpectedException('InvalidArgumentException', '@ is an invalid credit card token'); | |
- Braintree_CreditCard::find('@'); | |
+ Braintree\CreditCard::find('@'); | |
} | |
- function testFromNonce() | |
+ public function testFromNonce() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonce_for_new_card(array( | |
- "credit_card" => array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonce_for_new_card([ | |
+ "credit_card" => [ | |
"number" => "4009348888881881", | |
"expirationMonth" => "11", | |
"expirationYear" => "2099" | |
- ), | |
+ ], | |
"customerId" => $customer->id | |
- )); | |
+ ]); | |
- $creditCard = Braintree_CreditCard::fromNonce($nonce); | |
+ $creditCard = Braintree\CreditCard::fromNonce($nonce); | |
- $customer = Braintree_Customer::find($customer->id); | |
+ $customer = Braintree\Customer::find($customer->id); | |
$this->assertEquals($customer->creditCards[0], $creditCard); | |
} | |
- function testFromNonce_ReturnsErrorWhenNoncePointsToSharedCard() | |
+ public function testFromNonce_ReturnsErrorWhenNoncePointsToSharedCard() | |
{ | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonce_for_new_card(array( | |
- "credit_card" => array( | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonce_for_new_card([ | |
+ "credit_card" => [ | |
"number" => "4009348888881881", | |
"expirationMonth" => "11", | |
"expirationYear" => "2099" | |
- ), | |
+ ], | |
"share" => true | |
- )); | |
+ ]); | |
- $this->setExpectedException('Braintree_Exception_NotFound', "not found"); | |
- Braintree_CreditCard::fromNonce($nonce); | |
+ $this->setExpectedException('Braintree\Exception\NotFound', "not found"); | |
+ Braintree\CreditCard::fromNonce($nonce); | |
} | |
- function testFromNonce_ReturnsErrorWhenNonceIsConsumed() | |
+ public function testFromNonce_ReturnsErrorWhenNonceIsConsumed() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonce_for_new_card(array( | |
- "credit_card" => array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonce_for_new_card([ | |
+ "credit_card" => [ | |
"number" => "4009348888881881", | |
"expirationMonth" => "11", | |
"expirationYear" => "2099" | |
- ), | |
+ ], | |
"customerId" => $customer->id | |
- )); | |
+ ]); | |
- Braintree_CreditCard::fromNonce($nonce); | |
- $this->setExpectedException('Braintree_Exception_NotFound', "consumed"); | |
- Braintree_CreditCard::fromNonce($nonce); | |
+ Braintree\CreditCard::fromNonce($nonce); | |
+ $this->setExpectedException('Braintree\Exception\NotFound', "consumed"); | |
+ Braintree\CreditCard::fromNonce($nonce); | |
} | |
- function testUpdate() | |
+ public function testUpdate() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $createResult = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $createResult = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'cardholderName' => 'Old Cardholder', | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- )); | |
+ ]); | |
$this->assertTrue($createResult->success); | |
- $updateResult = Braintree_CreditCard::update($createResult->creditCard->token, array( | |
+ $updateResult = Braintree\CreditCard::update($createResult->creditCard->token, [ | |
'cardholderName' => 'New Cardholder', | |
'number' => '4111111111111111', | |
'expirationDate' => '07/14' | |
- )); | |
+ ]); | |
$this->assertEquals($customer->id, $updateResult->creditCard->customerId); | |
$this->assertEquals('411111', $updateResult->creditCard->bin); | |
$this->assertEquals('1111', $updateResult->creditCard->last4); | |
@@ -865,103 +895,103 @@ | |
$this->assertEquals('07/2014', $updateResult->creditCard->expirationDate); | |
} | |
- function testUpdate_withCardVerification() | |
+ public function testUpdate_withCardVerification() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $initialCreditCard = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $initialCreditCard = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- ))->creditCard; | |
+ ])->creditCard; | |
- $result = Braintree_CreditCard::update($initialCreditCard->token, array( | |
- 'billingAddress' => array( | |
+ $result = Braintree\CreditCard::update($initialCreditCard->token, [ | |
+ 'billingAddress' => [ | |
'region' => 'IL' | |
- ), | |
- 'options' => array('verifyCard' => true) | |
- )); | |
+ ], | |
+ 'options' => ['verifyCard' => true] | |
+ ]); | |
$this->assertFalse($result->success); | |
- $this->assertEquals(Braintree_Result_CreditCardVerification::PROCESSOR_DECLINED, $result->creditCardVerification->status); | |
+ $this->assertEquals(Braintree\Result\CreditCardVerification::PROCESSOR_DECLINED, $result->creditCardVerification->status); | |
$this->assertEquals('2000', $result->creditCardVerification->processorResponseCode); | |
$this->assertEquals('Do Not Honor', $result->creditCardVerification->processorResponseText); | |
$this->assertEquals('I', $result->creditCardVerification->cvvResponseCode); | |
$this->assertEquals(null, $result->creditCardVerification->avsErrorResponseCode); | |
$this->assertEquals('I', $result->creditCardVerification->avsPostalCodeResponseCode); | |
$this->assertEquals('I', $result->creditCardVerification->avsStreetAddressResponseCode); | |
- $this->assertEquals(Braintree_TestHelper::defaultMerchantAccountId(), $result->creditCardVerification->merchantAccountId); | |
+ $this->assertEquals(Test\Helper::defaultMerchantAccountId(), $result->creditCardVerification->merchantAccountId); | |
} | |
- function testUpdate_withCardVerificationAndSpecificMerchantAccount() | |
+ public function testUpdate_withCardVerificationAndSpecificMerchantAccount() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $initialCreditCard = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $initialCreditCard = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- ))->creditCard; | |
+ ])->creditCard; | |
- $result = Braintree_CreditCard::update($initialCreditCard->token, array( | |
- 'billingAddress' => array( | |
+ $result = Braintree\CreditCard::update($initialCreditCard->token, [ | |
+ 'billingAddress' => [ | |
'region' => 'IL' | |
- ), | |
- 'options' => array( | |
- 'verificationMerchantAccountId' => Braintree_TestHelper::nonDefaultMerchantAccountId(), | |
+ ], | |
+ 'options' => [ | |
+ 'verificationMerchantAccountId' => Test\Helper::nonDefaultMerchantAccountId(), | |
'verifyCard' => true | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$this->assertFalse($result->success); | |
- $this->assertEquals(Braintree_Result_CreditCardVerification::PROCESSOR_DECLINED, $result->creditCardVerification->status); | |
- $this->assertEquals(Braintree_TestHelper::nonDefaultMerchantAccountId(), $result->creditCardVerification->merchantAccountId); | |
+ $this->assertEquals(Braintree\Result\CreditCardVerification::PROCESSOR_DECLINED, $result->creditCardVerification->status); | |
+ $this->assertEquals(Test\Helper::nonDefaultMerchantAccountId(), $result->creditCardVerification->merchantAccountId); | |
} | |
- function testUpdate_createsNewBillingAddressByDefault() | |
+ public function testUpdate_createsNewBillingAddressByDefault() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $initialCreditCard = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $initialCreditCard = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12', | |
- 'billingAddress' => array( | |
+ 'billingAddress' => [ | |
'streetAddress' => '123 Nigeria Ave' | |
- ) | |
- ))->creditCard; | |
+ ] | |
+ ])->creditCard; | |
- $updatedCreditCard = Braintree_CreditCard::update($initialCreditCard->token, array( | |
- 'billingAddress' => array( | |
+ $updatedCreditCard = Braintree\CreditCard::update($initialCreditCard->token, [ | |
+ 'billingAddress' => [ | |
'region' => 'IL' | |
- ) | |
- ))->creditCard; | |
+ ] | |
+ ])->creditCard; | |
$this->assertEquals('IL', $updatedCreditCard->billingAddress->region); | |
$this->assertNull($updatedCreditCard->billingAddress->streetAddress); | |
$this->assertNotEquals($initialCreditCard->billingAddress->id, $updatedCreditCard->billingAddress->id); | |
} | |
- function testUpdate_updatesExistingBillingAddressIfUpdateExistingOptionIsTrue() | |
+ public function testUpdate_updatesExistingBillingAddressIfUpdateExistingOptionIsTrue() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $initialCreditCard = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $initialCreditCard = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12', | |
- 'billingAddress' => array( | |
+ 'billingAddress' => [ | |
'countryName' => 'Turkey', | |
'countryCodeAlpha2' => 'TR', | |
'countryCodeAlpha3' => 'TUR', | |
'countryCodeNumeric' => '792', | |
- ) | |
- ))->creditCard; | |
+ ] | |
+ ])->creditCard; | |
- $updatedCreditCard = Braintree_CreditCard::update($initialCreditCard->token, array( | |
- 'billingAddress' => array( | |
+ $updatedCreditCard = Braintree\CreditCard::update($initialCreditCard->token, [ | |
+ 'billingAddress' => [ | |
'countryName' => 'Thailand', | |
'countryCodeAlpha2' => 'TH', | |
'countryCodeAlpha3' => 'THA', | |
'countryCodeNumeric' => '764', | |
- 'options' => array( | |
+ 'options' => [ | |
'updateExisting' => True | |
- ) | |
- ) | |
- ))->creditCard; | |
+ ] | |
+ ] | |
+ ])->creditCard; | |
$this->assertEquals('Thailand', $updatedCreditCard->billingAddress->countryName); | |
$this->assertEquals('TH', $updatedCreditCard->billingAddress->countryCodeAlpha2); | |
$this->assertEquals('THA', $updatedCreditCard->billingAddress->countryCodeAlpha3); | |
@@ -969,41 +999,41 @@ | |
$this->assertEquals($initialCreditCard->billingAddress->id, $updatedCreditCard->billingAddress->id); | |
} | |
- function testUpdate_canChangeToken() | |
+ public function testUpdate_canChangeToken() | |
{ | |
$oldToken = strval(rand()); | |
$newToken = strval(rand()); | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $createResult = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $createResult = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'token' => $oldToken, | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- )); | |
+ ]); | |
$this->assertTrue($createResult->success); | |
- $updateResult = Braintree_CreditCard::update($oldToken, array( | |
+ $updateResult = Braintree\CreditCard::update($oldToken, [ | |
'token' => $newToken | |
- )); | |
+ ]); | |
$this->assertEquals($customer->id, $updateResult->creditCard->customerId); | |
$this->assertEquals($newToken, $updateResult->creditCard->token); | |
- $this->assertEquals($newToken, Braintree_CreditCard::find($newToken)->token); | |
+ $this->assertEquals($newToken, Braintree\CreditCard::find($newToken)->token); | |
} | |
- function testUpdateNoValidate() | |
+ public function testUpdateNoValidate() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $creditCard = Braintree_CreditCard::createNoValidate(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $creditCard = Braintree\CreditCard::createNoValidate([ | |
'customerId' => $customer->id, | |
'cardholderName' => 'Old Cardholder', | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- )); | |
- $updatedCard = Braintree_CreditCard::updateNoValidate($creditCard->token, array( | |
+ ]); | |
+ $updatedCard = Braintree\CreditCard::updateNoValidate($creditCard->token, [ | |
'cardholderName' => 'New Cardholder', | |
'number' => '4111111111111111', | |
'expirationDate' => '07/14' | |
- )); | |
+ ]); | |
$this->assertEquals($customer->id, $updatedCard->customerId); | |
$this->assertEquals('411111', $updatedCard->bin); | |
$this->assertEquals('1111', $updatedCard->last4); | |
@@ -1011,279 +1041,279 @@ | |
$this->assertEquals('07/2014', $updatedCard->expirationDate); | |
} | |
- function testUpdateNoValidate_throwsIfInvalid() | |
+ public function testUpdateNoValidate_throwsIfInvalid() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $creditCard = Braintree_CreditCard::createNoValidate(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $creditCard = Braintree\CreditCard::createNoValidate([ | |
'customerId' => $customer->id, | |
'cardholderName' => 'Old Cardholder', | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- )); | |
- $this->setExpectedException('Braintree_Exception_ValidationsFailed'); | |
- Braintree_CreditCard::updateNoValidate($creditCard->token, array( | |
+ ]); | |
+ $this->setExpectedException('Braintree\Exception\ValidationsFailed'); | |
+ Braintree\CreditCard::updateNoValidate($creditCard->token, [ | |
'number' => 'invalid', | |
- )); | |
+ ]); | |
} | |
- function testUpdate_withDefault() | |
+ public function testUpdate_withDefault() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $card1 = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $card1 = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'cardholderName' => 'Cardholder', | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- ))->creditCard; | |
- $card2 = Braintree_CreditCard::create(array( | |
+ ])->creditCard; | |
+ $card2 = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'cardholderName' => 'Cardholder', | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- ))->creditCard; | |
+ ])->creditCard; | |
$this->assertTrue($card1->isDefault()); | |
$this->assertFalse($card2->isDefault()); | |
- Braintree_CreditCard::update($card2->token, array( | |
- 'options' => array('makeDefault' => true) | |
- ))->creditCard; | |
+ Braintree\CreditCard::update($card2->token, [ | |
+ 'options' => ['makeDefault' => true] | |
+ ])->creditCard; | |
- $this->assertFalse(Braintree_CreditCard::find($card1->token)->isDefault()); | |
- $this->assertTrue(Braintree_CreditCard::find($card2->token)->isDefault()); | |
+ $this->assertFalse(Braintree\CreditCard::find($card1->token)->isDefault()); | |
+ $this->assertTrue(Braintree\CreditCard::find($card2->token)->isDefault()); | |
} | |
- function testDelete_deletesThePaymentMethod() | |
+ public function testDelete_deletesThePaymentMethod() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(array()); | |
- $creditCard = Braintree_CreditCard::createNoValidate(array( | |
+ $customer = Braintree\Customer::createNoValidate([]); | |
+ $creditCard = Braintree\CreditCard::createNoValidate([ | |
'customerId' => $customer->id, | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- )); | |
- Braintree_CreditCard::find($creditCard->token); | |
- Braintree_CreditCard::delete($creditCard->token); | |
- $this->setExpectedException('Braintree_Exception_NotFound'); | |
- Braintree_CreditCard::find($creditCard->token); | |
+ ]); | |
+ Braintree\CreditCard::find($creditCard->token); | |
+ Braintree\CreditCard::delete($creditCard->token); | |
+ $this->setExpectedException('Braintree\Exception\NotFound'); | |
+ Braintree\CreditCard::find($creditCard->token); | |
} | |
- function testGatewayRejectionOnCVV() | |
+ public function testGatewayRejectionOnCVV() | |
{ | |
- $old_merchant_id = Braintree_Configuration::merchantId(); | |
- $old_public_key = Braintree_Configuration::publicKey(); | |
- $old_private_key = Braintree_Configuration::privateKey(); | |
+ $old_merchant_id = Braintree\Configuration::merchantId(); | |
+ $old_public_key = Braintree\Configuration::publicKey(); | |
+ $old_private_key = Braintree\Configuration::privateKey(); | |
- Braintree_Configuration::merchantId('processing_rules_merchant_id'); | |
- Braintree_Configuration::publicKey('processing_rules_public_key'); | |
- Braintree_Configuration::privateKey('processing_rules_private_key'); | |
+ Braintree\Configuration::merchantId('processing_rules_merchant_id'); | |
+ Braintree\Configuration::publicKey('processing_rules_public_key'); | |
+ Braintree\Configuration::privateKey('processing_rules_private_key'); | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'number' => '4111111111111111', | |
'expirationDate' => '05/2011', | |
'cvv' => '200', | |
- 'options' => array('verifyCard' => true) | |
- )); | |
+ 'options' => ['verifyCard' => true] | |
+ ]); | |
- Braintree_Configuration::merchantId($old_merchant_id); | |
- Braintree_Configuration::publicKey($old_public_key); | |
- Braintree_Configuration::privateKey($old_private_key); | |
+ Braintree\Configuration::merchantId($old_merchant_id); | |
+ Braintree\Configuration::publicKey($old_public_key); | |
+ Braintree\Configuration::privateKey($old_private_key); | |
$this->assertFalse($result->success); | |
- $this->assertEquals(Braintree_Transaction::CVV, $result->creditCardVerification->gatewayRejectionReason); | |
+ $this->assertEquals(Braintree\Transaction::CVV, $result->creditCardVerification->gatewayRejectionReason); | |
} | |
- function testGatewayRejectionIsNullOnProcessorDecline() | |
+ public function testGatewayRejectionIsNullOnProcessorDecline() | |
{ | |
- $old_merchant_id = Braintree_Configuration::merchantId(); | |
- $old_public_key = Braintree_Configuration::publicKey(); | |
- $old_private_key = Braintree_Configuration::privateKey(); | |
+ $old_merchant_id = Braintree\Configuration::merchantId(); | |
+ $old_public_key = Braintree\Configuration::publicKey(); | |
+ $old_private_key = Braintree\Configuration::privateKey(); | |
- Braintree_Configuration::merchantId('processing_rules_merchant_id'); | |
- Braintree_Configuration::publicKey('processing_rules_public_key'); | |
- Braintree_Configuration::privateKey('processing_rules_private_key'); | |
+ Braintree\Configuration::merchantId('processing_rules_merchant_id'); | |
+ Braintree\Configuration::publicKey('processing_rules_public_key'); | |
+ Braintree\Configuration::privateKey('processing_rules_private_key'); | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'number' => '5105105105105100', | |
'expirationDate' => '05/2011', | |
'cvv' => '200', | |
- 'options' => array('verifyCard' => true) | |
- )); | |
+ 'options' => ['verifyCard' => true] | |
+ ]); | |
- Braintree_Configuration::merchantId($old_merchant_id); | |
- Braintree_Configuration::publicKey($old_public_key); | |
- Braintree_Configuration::privateKey($old_private_key); | |
+ Braintree\Configuration::merchantId($old_merchant_id); | |
+ Braintree\Configuration::publicKey($old_public_key); | |
+ Braintree\Configuration::privateKey($old_private_key); | |
$this->assertFalse($result->success); | |
$this->assertNull($result->creditCardVerification->gatewayRejectionReason); | |
} | |
- function createCreditCardViaTr($regularParams, $trParams) | |
+ public function createCreditCardViaTr($regularParams, $trParams) | |
{ | |
- $trData = Braintree_TransparentRedirect::createCreditCardData( | |
- array_merge($trParams, array("redirectUrl" => "http://www.example.com")) | |
+ $trData = Braintree\TransparentRedirect::createCreditCardData( | |
+ array_merge($trParams, ["redirectUrl" => "http://www.example.com"]) | |
); | |
- return Braintree_TestHelper::submitTrRequest( | |
- Braintree_CreditCard::createCreditCardUrl(), | |
+ return Test\Helper::submitTrRequest( | |
+ Braintree\CreditCard::createCreditCardUrl(), | |
$regularParams, | |
$trData | |
); | |
} | |
- function updateCreditCardViaTr($regularParams, $trParams) | |
+ public function updateCreditCardViaTr($regularParams, $trParams) | |
{ | |
- $trData = Braintree_TransparentRedirect::updateCreditCardData( | |
- array_merge($trParams, array("redirectUrl" => "http://www.example.com")) | |
+ $trData = Braintree\TransparentRedirect::updateCreditCardData( | |
+ array_merge($trParams, ["redirectUrl" => "http://www.example.com"]) | |
); | |
- return Braintree_TestHelper::submitTrRequest( | |
- Braintree_CreditCard::updateCreditCardUrl(), | |
+ return Test\Helper::submitTrRequest( | |
+ Braintree\CreditCard::updateCreditCardUrl(), | |
$regularParams, | |
$trData | |
); | |
} | |
- function testPrepaidCard() | |
+ public function testPrepaidCard() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'cardholderName' => 'Cardholder', | |
- 'number' => Braintree_CreditCardNumbers_CardTypeIndicators::PREPAID, | |
+ 'number' => CardTypeIndicators::PREPAID, | |
'expirationDate' => '05/12', | |
- 'options' => array('verifyCard' => true) | |
- )); | |
- $this->assertEquals(Braintree_CreditCard::PREPAID_YES, $result->creditCard->prepaid); | |
+ 'options' => ['verifyCard' => true] | |
+ ]); | |
+ $this->assertEquals(Braintree\CreditCard::PREPAID_YES, $result->creditCard->prepaid); | |
} | |
- function testCommercialCard() | |
+ public function testCommercialCard() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'cardholderName' => 'Cardholder', | |
- 'number' => Braintree_CreditCardNumbers_CardTypeIndicators::COMMERCIAL, | |
+ 'number' => CardTypeIndicators::COMMERCIAL, | |
'expirationDate' => '05/12', | |
- 'options' => array('verifyCard' => true) | |
- )); | |
- $this->assertEquals(Braintree_CreditCard::COMMERCIAL_YES, $result->creditCard->commercial); | |
+ 'options' => ['verifyCard' => true] | |
+ ]); | |
+ $this->assertEquals(Braintree\CreditCard::COMMERCIAL_YES, $result->creditCard->commercial); | |
} | |
- function testDebitCard() | |
+ public function testDebitCard() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'cardholderName' => 'Cardholder', | |
- 'number' => Braintree_CreditCardNumbers_CardTypeIndicators::DEBIT, | |
+ 'number' => CardTypeIndicators::DEBIT, | |
'expirationDate' => '05/12', | |
- 'options' => array('verifyCard' => true) | |
- )); | |
- $this->assertEquals(Braintree_CreditCard::DEBIT_YES, $result->creditCard->debit); | |
+ 'options' => ['verifyCard' => true] | |
+ ]); | |
+ $this->assertEquals(Braintree\CreditCard::DEBIT_YES, $result->creditCard->debit); | |
} | |
- function testPayrollCard() | |
+ public function testPayrollCard() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'cardholderName' => 'Cardholder', | |
- 'number' => Braintree_CreditCardNumbers_CardTypeIndicators::PAYROLL, | |
+ 'number' => CardTypeIndicators::PAYROLL, | |
'expirationDate' => '05/12', | |
- 'options' => array('verifyCard' => true) | |
- )); | |
- $this->assertEquals(Braintree_CreditCard::PAYROLL_YES, $result->creditCard->payroll); | |
+ 'options' => ['verifyCard' => true] | |
+ ]); | |
+ $this->assertEquals(Braintree\CreditCard::PAYROLL_YES, $result->creditCard->payroll); | |
} | |
- function testHealthCareCard() | |
+ public function testHealthCareCard() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'cardholderName' => 'Cardholder', | |
- 'number' => Braintree_CreditCardNumbers_CardTypeIndicators::HEALTHCARE, | |
+ 'number' => CardTypeIndicators::HEALTHCARE, | |
'expirationDate' => '05/12', | |
- 'options' => array('verifyCard' => true) | |
- )); | |
- $this->assertEquals(Braintree_CreditCard::HEALTHCARE_YES, $result->creditCard->healthcare); | |
+ 'options' => ['verifyCard' => true] | |
+ ]); | |
+ $this->assertEquals(Braintree\CreditCard::HEALTHCARE_YES, $result->creditCard->healthcare); | |
} | |
- function testDurbinRegulatedCard() | |
+ public function testDurbinRegulatedCard() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'cardholderName' => 'Cardholder', | |
- 'number' => Braintree_CreditCardNumbers_CardTypeIndicators::DURBIN_REGULATED, | |
+ 'number' => CardTypeIndicators::DURBIN_REGULATED, | |
'expirationDate' => '05/12', | |
- 'options' => array('verifyCard' => true) | |
- )); | |
- $this->assertEquals(Braintree_CreditCard::DURBIN_REGULATED_YES, $result->creditCard->durbinRegulated); | |
+ 'options' => ['verifyCard' => true] | |
+ ]); | |
+ $this->assertEquals(Braintree\CreditCard::DURBIN_REGULATED_YES, $result->creditCard->durbinRegulated); | |
} | |
- function testCountryOfIssuanceCard() | |
+ public function testCountryOfIssuanceCard() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'cardholderName' => 'Cardholder', | |
- 'number' => Braintree_CreditCardNumbers_CardTypeIndicators::COUNTRY_OF_ISSUANCE, | |
+ 'number' => CardTypeIndicators::COUNTRY_OF_ISSUANCE, | |
'expirationDate' => '05/12', | |
- 'options' => array('verifyCard' => true) | |
- )); | |
+ 'options' => ['verifyCard' => true] | |
+ ]); | |
$this->assertEquals("USA", $result->creditCard->countryOfIssuance); | |
} | |
- function testIssuingBankCard() | |
+ public function testIssuingBankCard() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'cardholderName' => 'Cardholder', | |
- 'number' => Braintree_CreditCardNumbers_CardTypeIndicators::ISSUING_BANK, | |
+ 'number' => CardTypeIndicators::ISSUING_BANK, | |
'expirationDate' => '05/12', | |
- 'options' => array('verifyCard' => true) | |
- )); | |
+ 'options' => ['verifyCard' => true] | |
+ ]); | |
$this->assertEquals("NETWORK ONLY", $result->creditCard->issuingBank); | |
} | |
- function testNegativeCardTypeIndicators() | |
+ public function testNegativeCardTypeIndicators() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'cardholderName' => 'Cardholder', | |
- 'number' => Braintree_CreditCardNumbers_CardTypeIndicators::NO, | |
+ 'number' => CardTypeIndicators::NO, | |
'expirationDate' => '05/12', | |
- 'options' => array('verifyCard' => true) | |
- )); | |
- $this->assertEquals(Braintree_CreditCard::PREPAID_NO, $result->creditCard->prepaid); | |
- $this->assertEquals(Braintree_CreditCard::DURBIN_REGULATED_NO, $result->creditCard->durbinRegulated); | |
- $this->assertEquals(Braintree_CreditCard::PAYROLL_NO, $result->creditCard->payroll); | |
- $this->assertEquals(Braintree_CreditCard::DEBIT_NO, $result->creditCard->debit); | |
- $this->assertEquals(Braintree_CreditCard::HEALTHCARE_NO, $result->creditCard->healthcare); | |
- $this->assertEquals(Braintree_CreditCard::COMMERCIAL_NO, $result->creditCard->commercial); | |
+ 'options' => ['verifyCard' => true] | |
+ ]); | |
+ $this->assertEquals(Braintree\CreditCard::PREPAID_NO, $result->creditCard->prepaid); | |
+ $this->assertEquals(Braintree\CreditCard::DURBIN_REGULATED_NO, $result->creditCard->durbinRegulated); | |
+ $this->assertEquals(Braintree\CreditCard::PAYROLL_NO, $result->creditCard->payroll); | |
+ $this->assertEquals(Braintree\CreditCard::DEBIT_NO, $result->creditCard->debit); | |
+ $this->assertEquals(Braintree\CreditCard::HEALTHCARE_NO, $result->creditCard->healthcare); | |
+ $this->assertEquals(Braintree\CreditCard::COMMERCIAL_NO, $result->creditCard->commercial); | |
} | |
- function testUnknownCardTypeIndicators() | |
+ public function testUnknownCardTypeIndicators() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'cardholderName' => 'Cardholder', | |
- 'number' => Braintree_CreditCardNumbers_CardTypeIndicators::UNKNOWN, | |
+ 'number' => CardTypeIndicators::UNKNOWN, | |
'expirationDate' => '05/12', | |
- 'options' => array('verifyCard' => true) | |
- )); | |
- $this->assertEquals(Braintree_CreditCard::PREPAID_UNKNOWN, $result->creditCard->prepaid); | |
- $this->assertEquals(Braintree_CreditCard::DURBIN_REGULATED_UNKNOWN, $result->creditCard->durbinRegulated); | |
- $this->assertEquals(Braintree_CreditCard::PAYROLL_UNKNOWN, $result->creditCard->payroll); | |
- $this->assertEquals(Braintree_CreditCard::DEBIT_UNKNOWN, $result->creditCard->debit); | |
- $this->assertEquals(Braintree_CreditCard::HEALTHCARE_UNKNOWN, $result->creditCard->healthcare); | |
- $this->assertEquals(Braintree_CreditCard::COMMERCIAL_UNKNOWN, $result->creditCard->commercial); | |
- $this->assertEquals(Braintree_CreditCard::COUNTRY_OF_ISSUANCE_UNKNOWN, $result->creditCard->countryOfIssuance); | |
- $this->assertEquals(Braintree_CreditCard::ISSUING_BANK_UNKNOWN, $result->creditCard->issuingBank); | |
+ 'options' => ['verifyCard' => true] | |
+ ]); | |
+ $this->assertEquals(Braintree\CreditCard::PREPAID_UNKNOWN, $result->creditCard->prepaid); | |
+ $this->assertEquals(Braintree\CreditCard::DURBIN_REGULATED_UNKNOWN, $result->creditCard->durbinRegulated); | |
+ $this->assertEquals(Braintree\CreditCard::PAYROLL_UNKNOWN, $result->creditCard->payroll); | |
+ $this->assertEquals(Braintree\CreditCard::DEBIT_UNKNOWN, $result->creditCard->debit); | |
+ $this->assertEquals(Braintree\CreditCard::HEALTHCARE_UNKNOWN, $result->creditCard->healthcare); | |
+ $this->assertEquals(Braintree\CreditCard::COMMERCIAL_UNKNOWN, $result->creditCard->commercial); | |
+ $this->assertEquals(Braintree\CreditCard::COUNTRY_OF_ISSUANCE_UNKNOWN, $result->creditCard->countryOfIssuance); | |
+ $this->assertEquals(Braintree\CreditCard::ISSUING_BANK_UNKNOWN, $result->creditCard->issuingBank); | |
} | |
} | |
Index: braintree_sdk/tests/integration/CreditCardVerificationAdvancedSearchTest.php | |
=================================================================== | |
--- braintree_sdk/tests/integration/CreditCardVerificationAdvancedSearchTest.php (revision 1387260) | |
+++ braintree_sdk/tests/integration/CreditCardVerificationAdvancedSearchTest.php (working copy) | |
@@ -1,121 +1,127 @@ | |
<?php | |
-require_once realpath(dirname(__FILE__)) . '/../TestHelper.php'; | |
+namespace Test\Integration; | |
-class Braintree_CreditCardVerificationAdvancedSearchTest extends PHPUnit_Framework_TestCase | |
+require_once dirname(__DIR__) . '/Setup.php'; | |
+ | |
+use Test; | |
+use Test\Setup; | |
+use Braintree; | |
+ | |
+class CreditCardVerificationAdvancedSearchTest extends Setup | |
{ | |
- function test_searchOnTextFields() | |
+ public function test_searchOnTextFields() | |
{ | |
- $searchCriteria = array( | |
+ $searchCriteria = [ | |
'creditCardCardholderName' => 'Tim Toole', | |
'creditCardExpirationDate' => '05/2010', | |
- 'creditCardNumber' => Braintree_Test_CreditCardNumbers::$failsSandboxVerification['Visa'], | |
+ 'creditCardNumber' => Braintree\Test\CreditCardNumbers::$failsSandboxVerification['Visa'], | |
'billingAddressDetailsPostalCode' => '90210', | |
- ); | |
- $result = Braintree_Customer::create(array( | |
- 'creditCard' => array( | |
+ ]; | |
+ $result = Braintree\Customer::create([ | |
+ 'creditCard' => [ | |
'cardholderName' => $searchCriteria['creditCardCardholderName'], | |
'number' => $searchCriteria['creditCardNumber'], | |
'expirationDate' => $searchCriteria['creditCardExpirationDate'], | |
- 'billingAddress' => array( | |
+ 'billingAddress' => [ | |
'postalCode' => $searchCriteria['billingAddressDetailsPostalCode'] | |
- ), | |
- 'options' => array('verifyCard' => true), | |
- ), | |
- )); | |
+ ], | |
+ 'options' => ['verifyCard' => true], | |
+ ], | |
+ ]); | |
$verification = $result->creditCardVerification; | |
- $query = array(Braintree_CreditCardVerificationSearch::id()->is($verification->id)); | |
+ $query = [Braintree\CreditCardVerificationSearch::id()->is($verification->id)]; | |
foreach ($searchCriteria AS $criterion => $value) { | |
- $query[] = Braintree_CreditCardVerificationSearch::$criterion()->is($value); | |
+ $query[] = Braintree\CreditCardVerificationSearch::$criterion()->is($value); | |
} | |
- $collection = Braintree_CreditCardVerification::search($query); | |
+ $collection = Braintree\CreditCardVerification::search($query); | |
$this->assertEquals(1, $collection->maximumCount()); | |
$this->assertEquals($result->creditCardVerification->id, $collection->firstItem()->id); | |
foreach ($searchCriteria AS $criterion => $value) { | |
- $collection = Braintree_CreditCardVerification::search(array( | |
- Braintree_CreditCardVerificationSearch::$criterion()->is($value), | |
- Braintree_CreditCardVerificationSearch::id()->is($result->creditCardVerification->id) | |
- )); | |
+ $collection = Braintree\CreditCardVerification::search([ | |
+ Braintree\CreditCardVerificationSearch::$criterion()->is($value), | |
+ Braintree\CreditCardVerificationSearch::id()->is($result->creditCardVerification->id) | |
+ ]); | |
$this->assertEquals(1, $collection->maximumCount()); | |
$this->assertEquals($result->creditCardVerification->id, $collection->firstItem()->id); | |
- $collection = Braintree_CreditCardVerification::search(array( | |
- Braintree_CreditCardVerificationSearch::$criterion()->is('invalid_attribute'), | |
- Braintree_CreditCardVerificationSearch::id()->is($result->creditCardVerification->id) | |
- )); | |
+ $collection = Braintree\CreditCardVerification::search([ | |
+ Braintree\CreditCardVerificationSearch::$criterion()->is('invalid_attribute'), | |
+ Braintree\CreditCardVerificationSearch::id()->is($result->creditCardVerification->id) | |
+ ]); | |
$this->assertEquals(0, $collection->maximumCount()); | |
} | |
} | |
- function test_searchOnSuccessfulCustomerAndPaymentFields() | |
+ public function test_searchOnSuccessfulCustomerAndPaymentFields() | |
{ | |
$customerId = uniqid(); | |
- $searchCriteria = array( | |
+ $searchCriteria = [ | |
'customerId' => $customerId, | |
'customerEmail' => $customerId . '[email protected]', | |
'paymentMethodToken' => $customerId . 'token', | |
- ); | |
- $result = Braintree_Customer::create(array( | |
+ ]; | |
+ $result = Braintree\Customer::create([ | |
'id' => $customerId, | |
'email' => $searchCriteria['customerEmail'], | |
- 'creditCard' => array( | |
+ 'creditCard' => [ | |
'token' => $searchCriteria['paymentMethodToken'], | |
- 'number' => Braintree_Test_CreditCardNumbers::$visa, | |
+ 'number' => Braintree\Test\CreditCardNumbers::$visa, | |
'expirationDate' => '05/2017', | |
- 'options' => array('verifyCard' => true) | |
- ) | |
- )); | |
+ 'options' => ['verifyCard' => true] | |
+ ] | |
+ ]); | |
$customer = $result->customer; | |
- $query = array(); | |
+ $query = []; | |
foreach ($searchCriteria AS $criterion => $value) { | |
- $query[] = Braintree_CreditCardVerificationSearch::$criterion()->is($value); | |
+ $query[] = Braintree\CreditCardVerificationSearch::$criterion()->is($value); | |
} | |
- $collection = Braintree_CreditCardVerification::search($query); | |
+ $collection = Braintree\CreditCardVerification::search($query); | |
$this->assertEquals(1, $collection->maximumCount()); | |
foreach ($searchCriteria AS $criterion => $value) { | |
- $collection = Braintree_CreditCardVerification::search(array( | |
- Braintree_CreditCardVerificationSearch::$criterion()->is($value), | |
- )); | |
+ $collection = Braintree\CreditCardVerification::search([ | |
+ Braintree\CreditCardVerificationSearch::$criterion()->is($value), | |
+ ]); | |
$this->assertEquals(1, $collection->maximumCount()); | |
- $collection = Braintree_CreditCardVerification::search(array( | |
- Braintree_CreditCardVerificationSearch::$criterion()->is('invalid_attribute'), | |
- )); | |
+ $collection = Braintree\CreditCardVerification::search([ | |
+ Braintree\CreditCardVerificationSearch::$criterion()->is('invalid_attribute'), | |
+ ]); | |
$this->assertEquals(0, $collection->maximumCount()); | |
} | |
} | |
- function testGateway_searchEmpty() | |
+ public function testGateway_searchEmpty() | |
{ | |
- $query = array(); | |
- $query[] = Braintree_CreditCardVerificationSearch::creditCardCardholderName()->is('Not Found'); | |
+ $query = []; | |
+ $query[] = Braintree\CreditCardVerificationSearch::creditCardCardholderName()->is('Not Found'); | |
- $gateway = new Braintree_Gateway(array( | |
+ $gateway = new Braintree\Gateway([ | |
'environment' => 'development', | |
'merchantId' => 'integration_merchant_id', | |
'publicKey' => 'integration_public_key', | |
'privateKey' => 'integration_private_key' | |
- )); | |
+ ]); | |
$collection = $gateway->creditCardVerification()->search($query); | |
$this->assertEquals(0, $collection->maximumCount()); | |
} | |
- function test_createdAt() | |
+ public function test_createdAt() | |
{ | |
- $result = Braintree_Customer::create(array( | |
- 'creditCard' => array( | |
+ $result = Braintree\Customer::create([ | |
+ 'creditCard' => [ | |
'cardholderName' => 'Joe Smith', | |
'number' => '4000111111111115', | |
'expirationDate' => '12/2016', | |
- 'options' => array('verifyCard' => true), | |
- ), | |
- )); | |
+ 'options' => ['verifyCard' => true], | |
+ ], | |
+ ]); | |
$verification = $result->creditCardVerification; | |
@@ -124,130 +130,130 @@ | |
$future = clone $verification->createdAt; | |
$future->modify('+1 hour'); | |
- $collection = Braintree_CreditCardVerification::search(array( | |
- Braintree_CreditCardVerificationSearch::id()->is($verification->id), | |
- Braintree_CreditCardVerificationSearch::createdAt()->between($past, $future) | |
- )); | |
+ $collection = Braintree\CreditCardVerification::search([ | |
+ Braintree\CreditCardVerificationSearch::id()->is($verification->id), | |
+ Braintree\CreditCardVerificationSearch::createdAt()->between($past, $future) | |
+ ]); | |
$this->assertEquals(1, $collection->maximumCount()); | |
$this->assertEquals($verification->id, $collection->firstItem()->id); | |
- $collection = Braintree_CreditCardVerification::search(array( | |
- Braintree_CreditCardVerificationSearch::id()->is($verification->id), | |
- Braintree_CreditCardVerificationSearch::createdAt()->lessThanOrEqualTo($future) | |
- )); | |
+ $collection = Braintree\CreditCardVerification::search([ | |
+ Braintree\CreditCardVerificationSearch::id()->is($verification->id), | |
+ Braintree\CreditCardVerificationSearch::createdAt()->lessThanOrEqualTo($future) | |
+ ]); | |
$this->assertEquals(1, $collection->maximumCount()); | |
$this->assertEquals($verification->id, $collection->firstItem()->id); | |
- $collection = Braintree_CreditCardVerification::search(array( | |
- Braintree_CreditCardVerificationSearch::id()->is($verification->id), | |
- Braintree_CreditCardVerificationSearch::createdAt()->greaterThanOrEqualTo($past) | |
- )); | |
+ $collection = Braintree\CreditCardVerification::search([ | |
+ Braintree\CreditCardVerificationSearch::id()->is($verification->id), | |
+ Braintree\CreditCardVerificationSearch::createdAt()->greaterThanOrEqualTo($past) | |
+ ]); | |
$this->assertEquals(1, $collection->maximumCount()); | |
$this->assertEquals($verification->id, $collection->firstItem()->id); | |
} | |
- function test_multipleValueNode_ids() | |
+ public function test_multipleValueNode_ids() | |
{ | |
- $result = Braintree_Customer::create(array( | |
- 'creditCard' => array( | |
+ $result = Braintree\Customer::create([ | |
+ 'creditCard' => [ | |
'cardholderName' => 'Joe Smith', | |
'number' => '4000111111111115', | |
'expirationDate' => '12/2016', | |
- 'options' => array('verifyCard' => true), | |
- ), | |
- )); | |
+ 'options' => ['verifyCard' => true], | |
+ ], | |
+ ]); | |
$creditCardVerification = $result->creditCardVerification; | |
- $collection = Braintree_CreditCardVerification::search(array( | |
- Braintree_CreditCardVerificationSearch::ids()->is($creditCardVerification->id) | |
- )); | |
+ $collection = Braintree\CreditCardVerification::search([ | |
+ Braintree\CreditCardVerificationSearch::ids()->is($creditCardVerification->id) | |
+ ]); | |
$this->assertEquals(1, $collection->maximumCount()); | |
$this->assertEquals($creditCardVerification->id, $collection->firstItem()->id); | |
- $collection = Braintree_CreditCardVerification::search(array( | |
- Braintree_CreditCardVerificationSearch::ids()->in( | |
- array($creditCardVerification->id,'1234') | |
+ $collection = Braintree\CreditCardVerification::search([ | |
+ Braintree\CreditCardVerificationSearch::ids()->in( | |
+ [$creditCardVerification->id,'1234'] | |
) | |
- )); | |
+ ]); | |
$this->assertEquals(1, $collection->maximumCount()); | |
$this->assertEquals($creditCardVerification->id, $collection->firstItem()->id); | |
- $collection = Braintree_CreditCardVerification::search(array( | |
- Braintree_CreditCardVerificationSearch::ids()->is('1234') | |
- )); | |
+ $collection = Braintree\CreditCardVerification::search([ | |
+ Braintree\CreditCardVerificationSearch::ids()->is('1234') | |
+ ]); | |
$this->assertEquals(0, $collection->maximumCount()); | |
} | |
- function test_multipleValueNode_creditCardType() | |
+ public function test_multipleValueNode_creditCardType() | |
{ | |
- $result = Braintree_Customer::create(array( | |
- 'creditCard' => array( | |
+ $result = Braintree\Customer::create([ | |
+ 'creditCard' => [ | |
'cardholderName' => 'Joe Smith', | |
'number' => '4000111111111115', | |
'expirationDate' => '12/2016', | |
- 'options' => array('verifyCard' => true), | |
- ), | |
- )); | |
+ 'options' => ['verifyCard' => true], | |
+ ], | |
+ ]); | |
$creditCardVerification = $result->creditCardVerification; | |
- $collection = Braintree_CreditCardVerification::search(array( | |
- Braintree_CreditCardVerificationSearch::id()->is($creditCardVerification->id), | |
- Braintree_CreditCardVerificationSearch::creditCardCardType()->is($creditCardVerification->creditCard['cardType']) | |
- )); | |
+ $collection = Braintree\CreditCardVerification::search([ | |
+ Braintree\CreditCardVerificationSearch::id()->is($creditCardVerification->id), | |
+ Braintree\CreditCardVerificationSearch::creditCardCardType()->is($creditCardVerification->creditCard['cardType']) | |
+ ]); | |
$this->assertEquals(1, $collection->maximumCount()); | |
$this->assertEquals($creditCardVerification->id, $collection->firstItem()->id); | |
- $collection = Braintree_CreditCardVerification::search(array( | |
- Braintree_CreditCardVerificationSearch::id()->is($creditCardVerification->id), | |
- Braintree_CreditCardVerificationSearch::creditCardCardType()->in( | |
- array($creditCardVerification->creditCard['cardType'], Braintree_CreditCard::CHINA_UNION_PAY) | |
+ $collection = Braintree\CreditCardVerification::search([ | |
+ Braintree\CreditCardVerificationSearch::id()->is($creditCardVerification->id), | |
+ Braintree\CreditCardVerificationSearch::creditCardCardType()->in( | |
+ [$creditCardVerification->creditCard['cardType'], Braintree\CreditCard::CHINA_UNION_PAY] | |
) | |
- )); | |
+ ]); | |
$this->assertEquals(1, $collection->maximumCount()); | |
$this->assertEquals($creditCardVerification->id, $collection->firstItem()->id); | |
- $collection = Braintree_CreditCardVerification::search(array( | |
- Braintree_CreditCardVerificationSearch::id()->is($creditCardVerification->id), | |
- Braintree_CreditCardVerificationSearch::creditCardCardType()->is(Braintree_CreditCard::CHINA_UNION_PAY) | |
- )); | |
+ $collection = Braintree\CreditCardVerification::search([ | |
+ Braintree\CreditCardVerificationSearch::id()->is($creditCardVerification->id), | |
+ Braintree\CreditCardVerificationSearch::creditCardCardType()->is(Braintree\CreditCard::CHINA_UNION_PAY) | |
+ ]); | |
$this->assertEquals(0, $collection->maximumCount()); | |
} | |
- function test_multipleValueNode_status() | |
+ public function test_multipleValueNode_status() | |
{ | |
- $result = Braintree_Customer::create(array( | |
- 'creditCard' => array( | |
+ $result = Braintree\Customer::create([ | |
+ 'creditCard' => [ | |
'cardholderName' => 'Joe Smith', | |
'number' => '4000111111111115', | |
'expirationDate' => '12/2016', | |
- 'options' => array('verifyCard' => true), | |
- ), | |
- )); | |
+ 'options' => ['verifyCard' => true], | |
+ ], | |
+ ]); | |
$creditCardVerification = $result->creditCardVerification; | |
- $collection = Braintree_CreditCardVerification::search(array( | |
- Braintree_CreditCardVerificationSearch::id()->is($creditCardVerification->id), | |
- Braintree_CreditCardVerificationSearch::status()->is($creditCardVerification->status) | |
- )); | |
+ $collection = Braintree\CreditCardVerification::search([ | |
+ Braintree\CreditCardVerificationSearch::id()->is($creditCardVerification->id), | |
+ Braintree\CreditCardVerificationSearch::status()->is($creditCardVerification->status) | |
+ ]); | |
$this->assertEquals(1, $collection->maximumCount()); | |
$this->assertEquals($creditCardVerification->id, $collection->firstItem()->id); | |
- $collection = Braintree_CreditCardVerification::search(array( | |
- Braintree_CreditCardVerificationSearch::id()->is($creditCardVerification->id), | |
- Braintree_CreditCardVerificationSearch::status()->in( | |
- array($creditCardVerification->status, Braintree_Result_creditCardVerification::VERIFIED) | |
+ $collection = Braintree\CreditCardVerification::search([ | |
+ Braintree\CreditCardVerificationSearch::id()->is($creditCardVerification->id), | |
+ Braintree\CreditCardVerificationSearch::status()->in( | |
+ [$creditCardVerification->status, Braintree\Result\CreditCardVerification::VERIFIED] | |
) | |
- )); | |
+ ]); | |
$this->assertEquals(1, $collection->maximumCount()); | |
$this->assertEquals($creditCardVerification->id, $collection->firstItem()->id); | |
- $collection = Braintree_CreditCardVerification::search(array( | |
- Braintree_CreditCardVerificationSearch::id()->is($creditCardVerification->id), | |
- Braintree_CreditCardVerificationSearch::status()->is(Braintree_Result_creditCardVerification::VERIFIED) | |
- )); | |
+ $collection = Braintree\CreditCardVerification::search([ | |
+ Braintree\CreditCardVerificationSearch::id()->is($creditCardVerification->id), | |
+ Braintree\CreditCardVerificationSearch::status()->is(Braintree\Result\CreditCardVerification::VERIFIED) | |
+ ]); | |
$this->assertEquals(0, $collection->maximumCount()); | |
} | |
} | |
Index: braintree_sdk/tests/integration/CreditCardVerificationTest.php | |
=================================================================== | |
--- braintree_sdk/tests/integration/CreditCardVerificationTest.php (revision 0) | |
+++ braintree_sdk/tests/integration/CreditCardVerificationTest.php (working copy) | |
@@ -0,0 +1,56 @@ | |
+<?php | |
+namespace Test\Integration; | |
+ | |
+require_once dirname(__DIR__) . '/Setup.php'; | |
+ | |
+use Test; | |
+use Test\Setup; | |
+use Braintree; | |
+ | |
+class CreditCardVerificationTest extends Setup | |
+{ | |
+ public function test_createWithSuccessfulResponse() | |
+ { | |
+ $result = Braintree\CreditCardVerification::create([ | |
+ 'creditCard' => [ | |
+ 'number' => '4111111111111111', | |
+ 'expirationDate' => '05/2011', | |
+ ], | |
+ ]); | |
+ $this->assertTrue($result->success); | |
+ } | |
+ | |
+ public function test_createWithUnsuccessfulResponse() | |
+ { | |
+ $result = Braintree\CreditCardVerification::create([ | |
+ 'creditCard' => [ | |
+ 'number' => Braintree\Test\CreditCardNumbers::$failsSandboxVerification['Visa'], | |
+ 'expirationDate' => '05/2011', | |
+ ], | |
+ ]); | |
+ $this->assertFalse($result->success); | |
+ $this->assertEquals($result->verification->status, Braintree\Result\CreditCardVerification::PROCESSOR_DECLINED); | |
+ | |
+ $verification = $result->verification; | |
+ | |
+ $this->assertEquals($verification->processorResponseCode, '2000'); | |
+ $this->assertEquals($verification->processorResponseText, 'Do Not Honor'); | |
+ } | |
+ | |
+ public function test_createWithInvalidRequest() | |
+ { | |
+ $result = Braintree\CreditCardVerification::create([ | |
+ 'creditCard' => [ | |
+ 'number' => Braintree\Test\CreditCardNumbers::$failsSandboxVerification['Visa'], | |
+ 'expirationDate' => '05/2011', | |
+ ], | |
+ 'options' => [ | |
+ 'amount' => '-5.00' | |
+ ], | |
+ ]); | |
+ $this->assertFalse($result->success); | |
+ | |
+ $amountErrors = $result->errors->forKey('verification')->forKey('options')->onAttribute('amount'); | |
+ $this->assertEquals(Braintree\Error\Codes::VERIFICATION_OPTIONS_AMOUNT_CANNOT_BE_NEGATIVE, $amountErrors[0]->code); | |
+ } | |
+} | |
Index: braintree_sdk/tests/integration/CustomerAdvancedSearchTest.php | |
=================================================================== | |
--- braintree_sdk/tests/integration/CustomerAdvancedSearchTest.php (revision 1387260) | |
+++ braintree_sdk/tests/integration/CustomerAdvancedSearchTest.php (working copy) | |
@@ -1,24 +1,28 @@ | |
<?php | |
-require_once realpath(dirname(__FILE__)) . '/../TestHelper.php'; | |
-require_once realpath(dirname(__FILE__)) . '/HttpClientApi.php'; | |
+namespace Test\Integration; | |
-class Braintree_CustomerAdvancedSearchTest extends PHPUnit_Framework_TestCase | |
+require_once dirname(__DIR__) . '/Setup.php'; | |
+ | |
+use Test\Setup; | |
+use Braintree; | |
+ | |
+class CustomerAdvancedSearchTest extends Setup | |
{ | |
- function test_noMatches() | |
+ public function test_noMatches() | |
{ | |
- $collection = Braintree_Customer::search(array( | |
- Braintree_CustomerSearch::company()->is('badname') | |
- )); | |
+ $collection = Braintree\Customer::search([ | |
+ Braintree\CustomerSearch::company()->is('badname') | |
+ ]); | |
$this->assertEquals(0, $collection->maximumCount()); | |
} | |
- function test_noRequestsWhenIterating() | |
+ public function test_noRequestsWhenIterating() | |
{ | |
$resultsReturned = false; | |
- $collection = Braintree_Customer::search(array( | |
- Braintree_CustomerSearch::firstName()->is('badname') | |
- )); | |
+ $collection = Braintree\Customer::search([ | |
+ Braintree\CustomerSearch::firstName()->is('badname') | |
+ ]); | |
foreach($collection as $customer) { | |
$resultsReturned = true; | |
@@ -29,17 +33,17 @@ | |
$this->assertEquals(false, $resultsReturned); | |
} | |
- function test_findDuplicateCardsGivenPaymentMethodToken() | |
+ public function test_findDuplicateCardsGivenPaymentMethodToken() | |
{ | |
- $creditCardRequest = array('number' => '63049580000009', 'expirationDate' => '05/2012'); | |
+ $creditCardRequest = ['number' => '63049580000009', 'expirationDate' => '05/2012']; | |
- $jim = Braintree_Customer::create(array('firstName' => 'Jim', 'creditCard' => $creditCardRequest))->customer; | |
- $joe = Braintree_Customer::create(array('firstName' => 'Joe', 'creditCard' => $creditCardRequest))->customer; | |
+ $jim = Braintree\Customer::create(['firstName' => 'Jim', 'creditCard' => $creditCardRequest])->customer; | |
+ $joe = Braintree\Customer::create(['firstName' => 'Joe', 'creditCard' => $creditCardRequest])->customer; | |
- $query = array(Braintree_CustomerSearch::paymentMethodTokenWithDuplicates()->is($jim->creditCards[0]->token)); | |
- $collection = Braintree_Customer::search($query); | |
+ $query = [Braintree\CustomerSearch::paymentMethodTokenWithDuplicates()->is($jim->creditCards[0]->token)]; | |
+ $collection = Braintree\Customer::search($query); | |
- $customerIds = array(); | |
+ $customerIds = []; | |
foreach($collection as $customer) | |
{ | |
$customerIds[] = $customer->id; | |
@@ -49,11 +53,11 @@ | |
$this->assertTrue(in_array($joe->id, $customerIds)); | |
} | |
- function test_searchOnTextFields() | |
+ public function test_searchOnTextFields() | |
{ | |
$token = 'cctoken' . rand(); | |
- $search_criteria = array( | |
+ $search_criteria = [ | |
'firstName' => 'Timmy', | |
'lastName' => 'OToole', | |
'company' => 'OToole and Son(s)' . rand(), | |
@@ -73,9 +77,9 @@ | |
'addressRegion' => 'Illinois', | |
'addressPostalCode' => '60622', | |
'addressCountryName' => 'United States of America' | |
- ); | |
+ ]; | |
- $customer = Braintree_Customer::createNoValidate(array( | |
+ $customer = Braintree\Customer::createNoValidate([ | |
'firstName' => $search_criteria['firstName'], | |
'lastName' => $search_criteria['lastName'], | |
'company' => $search_criteria['company'], | |
@@ -83,12 +87,12 @@ | |
'fax' => $search_criteria['fax'], | |
'phone' => $search_criteria['phone'], | |
'website' => $search_criteria['website'], | |
- 'creditCard' => array( | |
+ 'creditCard' => [ | |
'cardholderName' => 'Tim Toole', | |
'number' => '4111111111111111', | |
'expirationDate' => $search_criteria['creditCardExpirationDate'], | |
'token' => $token, | |
- 'billingAddress' => array( | |
+ 'billingAddress' => [ | |
'firstName' => $search_criteria['addressFirstName'], | |
'lastName' => $search_criteria['addressLastName'], | |
'streetAddress' => $search_criteria['addressStreetAddress'], | |
@@ -97,99 +101,99 @@ | |
'region' => $search_criteria['addressRegion'], | |
'postalCode' => $search_criteria['addressPostalCode'], | |
'countryName' => 'United States of America' | |
- ) | |
- ) | |
- )); | |
+ ] | |
+ ] | |
+ ]); | |
- $query = array(Braintree_CustomerSearch::id()->is($customer->id)); | |
+ $query = [Braintree\CustomerSearch::id()->is($customer->id)]; | |
foreach ($search_criteria AS $criterion => $value) { | |
- $query[] = Braintree_CustomerSearch::$criterion()->is($value); | |
+ $query[] = Braintree\CustomerSearch::$criterion()->is($value); | |
} | |
- $collection = Braintree_Customer::search($query); | |
+ $collection = Braintree\Customer::search($query); | |
$this->assertEquals(1, $collection->maximumCount()); | |
$this->assertEquals($customer->id, $collection->firstItem()->id); | |
foreach ($search_criteria AS $criterion => $value) { | |
- $collection = Braintree_Customer::search(array( | |
- Braintree_CustomerSearch::$criterion()->is($value), | |
- Braintree_CustomerSearch::id()->is($customer->id) | |
- )); | |
+ $collection = Braintree\Customer::search([ | |
+ Braintree\CustomerSearch::$criterion()->is($value), | |
+ Braintree\CustomerSearch::id()->is($customer->id), | |
+ ]); | |
$this->assertEquals(1, $collection->maximumCount()); | |
$this->assertEquals($customer->id, $collection->firstItem()->id); | |
- $collection = Braintree_Customer::search(array( | |
- Braintree_CustomerSearch::$criterion()->is('invalid_attribute'), | |
- Braintree_CustomerSearch::id()->is($customer->id) | |
- )); | |
+ $collection = Braintree\Customer::search([ | |
+ Braintree\CustomerSearch::$criterion()->is('invalid_attribute'), | |
+ Braintree\CustomerSearch::id()->is($customer->id), | |
+ ]); | |
$this->assertEquals(0, $collection->maximumCount()); | |
} | |
} | |
- function test_createdAt() | |
+ public function test_createdAt() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
+ $customer = Braintree\Customer::createNoValidate(); | |
$past = clone $customer->createdAt; | |
$past->modify("-1 hour"); | |
$future = clone $customer->createdAt; | |
$future->modify("+1 hour"); | |
- $collection = Braintree_Customer::search(array( | |
- Braintree_CustomerSearch::id()->is($customer->id), | |
- Braintree_CustomerSearch::createdAt()->between($past, $future) | |
- )); | |
+ $collection = Braintree\Customer::search([ | |
+ Braintree\CustomerSearch::id()->is($customer->id), | |
+ Braintree\CustomerSearch::createdAt()->between($past, $future), | |
+ ]); | |
$this->assertEquals(1, $collection->maximumCount()); | |
$this->assertEquals($customer->id, $collection->firstItem()->id); | |
- $collection = Braintree_Customer::search(array( | |
- Braintree_CustomerSearch::id()->is($customer->id), | |
- Braintree_CustomerSearch::createdAt()->lessThanOrEqualTo($future) | |
- )); | |
+ $collection = Braintree\Customer::search([ | |
+ Braintree\CustomerSearch::id()->is($customer->id), | |
+ Braintree\CustomerSearch::createdAt()->lessThanOrEqualTo($future), | |
+ ]); | |
$this->assertEquals(1, $collection->maximumCount()); | |
$this->assertEquals($customer->id, $collection->firstItem()->id); | |
- $collection = Braintree_Customer::search(array( | |
- Braintree_CustomerSearch::id()->is($customer->id), | |
- Braintree_CustomerSearch::createdAt()->greaterThanOrEqualTo($past) | |
- )); | |
+ $collection = Braintree\Customer::search([ | |
+ Braintree\CustomerSearch::id()->is($customer->id), | |
+ Braintree\CustomerSearch::createdAt()->greaterThanOrEqualTo($past), | |
+ ]); | |
$this->assertEquals(1, $collection->maximumCount()); | |
$this->assertEquals($customer->id, $collection->firstItem()->id); | |
} | |
- function test_paypalAccountEmail() | |
+ public function test_paypalAccountEmail() | |
{ | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonceForPayPalAccount(array( | |
- 'paypal_account' => array( | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonceForPayPalAccount([ | |
+ 'paypal_account' => [ | |
'consent_code' => 'PAYPAL_CONSENT_CODE', | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$customerId = 'UNIQUE_CUSTOMER_ID-' . strval(rand()); | |
- $customerResult = Braintree_Customer::create(array( | |
+ $customerResult = Braintree\Customer::create([ | |
'paymentMethodNonce' => $nonce, | |
'id' => $customerId | |
- )); | |
+ ]); | |
$this->assertTrue($customerResult->success); | |
$customer = $customerResult->customer; | |
- $collection = Braintree_Customer::search(array( | |
- Braintree_CustomerSearch::id()->is($customer->id), | |
- Braintree_CustomerSearch::paypalAccountEmail()->is('[email protected]') | |
- )); | |
+ $collection = Braintree\Customer::search([ | |
+ Braintree\CustomerSearch::id()->is($customer->id), | |
+ Braintree\CustomerSearch::paypalAccountEmail()->is('[email protected]') | |
+ ]); | |
$this->assertEquals(1, $collection->maximumCount()); | |
$this->assertEquals($customer->id, $collection->firstItem()->id); | |
} | |
- function test_throwsIfNoOperatorNodeGiven() | |
+ public function test_throwsIfNoOperatorNodeGiven() | |
{ | |
$this->setExpectedException('InvalidArgumentException', 'Operator must be provided'); | |
- Braintree_Customer::search(array( | |
- Braintree_CustomerSearch::creditCardExpirationDate() | |
- )); | |
+ Braintree\Customer::search([ | |
+ Braintree\CustomerSearch::creditCardExpirationDate() | |
+ ]); | |
} | |
} | |
Index: braintree_sdk/tests/integration/CustomerTest.php | |
=================================================================== | |
--- braintree_sdk/tests/integration/CustomerTest.php (revision 1387260) | |
+++ braintree_sdk/tests/integration/CustomerTest.php (working copy) | |
@@ -1,28 +1,33 @@ | |
<?php | |
-require_once realpath(dirname(__FILE__)) . '/../TestHelper.php'; | |
-require_once realpath(dirname(__FILE__)) . '/HttpClientApi.php'; | |
+namespace Test\Integration; | |
-class Braintree_CustomerTest extends PHPUnit_Framework_TestCase | |
+require_once dirname(__DIR__) . '/Setup.php'; | |
+ | |
+use Test; | |
+use Test\Setup; | |
+use Braintree; | |
+ | |
+class CustomerTest extends Setup | |
{ | |
- function testAll_smokeTest() | |
+ public function testAll_smokeTest() | |
{ | |
- $all = Braintree_Customer::all(); | |
+ $all = Braintree\Customer::all(); | |
$this->assertTrue($all->maximumCount() > 0); | |
} | |
- function testAllWithManyResults() | |
+ public function testAllWithManyResults() | |
{ | |
- $collection = Braintree_Customer::all(); | |
+ $collection = Braintree\Customer::all(); | |
$this->assertTrue($collection->maximumCount() > 1); | |
$customer = $collection->firstItem(); | |
$this->assertTrue(strlen($customer->id) > 0); | |
- $this->assertTrue($customer instanceof Braintree_Customer); | |
+ $this->assertTrue($customer instanceof Braintree\Customer); | |
} | |
- function testCreate() | |
+ public function testCreate() | |
{ | |
- $result = Braintree_Customer::create(array( | |
+ $result = Braintree\Customer::create([ | |
'firstName' => 'Mike', | |
'lastName' => 'Jones', | |
'company' => 'Jones Co.', | |
@@ -30,7 +35,7 @@ | |
'phone' => '419.555.1234', | |
'fax' => '419.555.1235', | |
'website' => 'http://example.com' | |
- )); | |
+ ]); | |
$this->assertEquals(true, $result->success); | |
$customer = $result->customer; | |
$this->assertEquals('Mike', $customer->firstName); | |
@@ -43,33 +48,33 @@ | |
$this->assertNotNull($customer->merchantId); | |
} | |
- function testCreateWithIdOfZero() | |
+ public function testCreateWithIdOfZero() | |
{ | |
- $result = Braintree_Customer::create(array( | |
+ $result = Braintree\Customer::create([ | |
'id' => '0' | |
- )); | |
+ ]); | |
$this->assertEquals(true, $result->success); | |
$this->assertEquals($result->customer->id, '0'); | |
- $customer = Braintree_Customer::find('0'); | |
+ $customer = Braintree\Customer::find('0'); | |
$this->assertEquals('0', $customer->id); | |
- Braintree_Customer::delete('0'); | |
+ Braintree\Customer::delete('0'); | |
} | |
- function testGatewayCreate() | |
+ public function testGatewayCreate() | |
{ | |
- $gateway = new Braintree_Gateway(array( | |
+ $gateway = new Braintree\Gateway([ | |
'environment' => 'development', | |
'merchantId' => 'integration_merchant_id', | |
'publicKey' => 'integration_public_key', | |
'privateKey' => 'integration_private_key' | |
- )); | |
- $result = $gateway->customer()->create(array( | |
+ ]); | |
+ $result = $gateway->customer()->create([ | |
'firstName' => 'Mike', | |
'lastName' => 'Jones', | |
- )); | |
+ ]); | |
$this->assertEquals(true, $result->success); | |
$customer = $result->customer; | |
$this->assertEquals('Mike', $customer->firstName); | |
@@ -77,22 +82,22 @@ | |
$this->assertNotNull($customer->merchantId); | |
} | |
- function testCreateWithAccessToken() | |
+ public function testCreateWithAccessToken() | |
{ | |
- $credentials = Braintree_OAuthTestHelper::createCredentials(array( | |
+ $credentials = Test\Braintree\OAuthTestHelper::createCredentials([ | |
'clientId' => 'client_id$development$integration_client_id', | |
'clientSecret' => 'client_secret$development$integration_client_secret', | |
'merchantId' => 'integration_merchant_id', | |
- )); | |
+ ]); | |
- $gateway = new Braintree_Gateway(array( | |
+ $gateway = new Braintree\Gateway([ | |
'accessToken' => $credentials->accessToken, | |
- )); | |
+ ]); | |
- $result = $gateway->customer()->create(array( | |
+ $result = $gateway->customer()->create([ | |
'firstName' => 'Mike', | |
'lastName' => 'Jones', | |
- )); | |
+ ]); | |
$this->assertEquals(true, $result->success); | |
$customer = $result->customer; | |
$this->assertEquals('Mike', $customer->firstName); | |
@@ -100,81 +105,114 @@ | |
$this->assertNotNull($customer->merchantId); | |
} | |
- function testCreateCustomerWithCardUsingNonce() | |
+ public function testCreateCustomerWithCardUsingNonce() | |
{ | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonce_for_new_card(array( | |
- "creditCard" => array( | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonce_for_new_card([ | |
+ "creditCard" => [ | |
"number" => "4111111111111111", | |
"expirationMonth" => "11", | |
"expirationYear" => "2099" | |
- ), | |
+ ], | |
"share" => true | |
- )); | |
+ ]); | |
- $result = Braintree_Customer::create(array( | |
- 'creditCard' => array( | |
+ $result = Braintree\Customer::create([ | |
+ 'creditCard' => [ | |
'paymentMethodNonce' => $nonce | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$this->assertTrue($result->success); | |
$this->assertSame("411111", $result->customer->creditCards[0]->bin); | |
$this->assertSame("1111", $result->customer->creditCards[0]->last4); | |
} | |
- function testCreateCustomerWithApplePayCard() | |
+ public function testCreateCustomerWithApplePayCard() | |
{ | |
- $nonce = Braintree_Test_Nonces::$applePayVisa; | |
- $result = Braintree_Customer::create(array( | |
+ $nonce = Braintree\Test\Nonces::$applePayVisa; | |
+ $result = Braintree\Customer::create([ | |
'paymentMethodNonce' => $nonce | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
$customer = $result->customer; | |
$this->assertNotNull($customer->applePayCards[0]); | |
$this->assertNotNull($customer->paymentMethods[0]); | |
} | |
- function testCreateCustomerWithAndroidPayProxyCard() | |
+ public function testCreateCustomerWithAndroidPayProxyCard() | |
{ | |
- $nonce = Braintree_Test_Nonces::$androidPayDiscover; | |
- $result = Braintree_Customer::create(array( | |
+ $nonce = Braintree\Test\Nonces::$androidPayDiscover; | |
+ $result = Braintree\Customer::create([ | |
'paymentMethodNonce' => $nonce | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
$customer = $result->customer; | |
$this->assertNotNull($customer->androidPayCards[0]); | |
$this->assertNotNull($customer->paymentMethods[0]); | |
$androidPayCard = $customer->androidPayCards[0]; | |
- $this->assertTrue($androidPayCard instanceof Braintree_AndroidPayCard); | |
+ $this->assertTrue($androidPayCard instanceof Braintree\AndroidPayCard); | |
$this->assertNotNull($androidPayCard->token); | |
$this->assertNotNull($androidPayCard->expirationYear); | |
} | |
- function testCreateCustomerWithAndroidPayNetworkToken() | |
+ public function testCreateCustomerWithAndroidPayNetworkToken() | |
{ | |
- $nonce = Braintree_Test_Nonces::$androidPayMasterCard; | |
- $result = Braintree_Customer::create(array( | |
+ $nonce = Braintree\Test\Nonces::$androidPayMasterCard; | |
+ $result = Braintree\Customer::create([ | |
'paymentMethodNonce' => $nonce | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
$customer = $result->customer; | |
$this->assertNotNull($customer->androidPayCards[0]); | |
$this->assertNotNull($customer->paymentMethods[0]); | |
$androidPayCard = $customer->androidPayCards[0]; | |
- $this->assertTrue($androidPayCard instanceof Braintree_AndroidPayCard); | |
+ $this->assertTrue($androidPayCard instanceof Braintree\AndroidPayCard); | |
$this->assertNotNull($androidPayCard->token); | |
$this->assertNotNull($androidPayCard->expirationYear); | |
} | |
- function testCreateCustomerWithCoinbase() | |
+ public function testCreateCustomerWithAmexExpressCheckoutCard() | |
{ | |
- $nonce = Braintree_Test_Nonces::$coinbase; | |
- $result = Braintree_Customer::create(array( | |
+ $nonce = Braintree\Test\Nonces::$amexExpressCheckout; | |
+ $result = Braintree\Customer::create([ | |
'paymentMethodNonce' => $nonce | |
+ ]); | |
+ $this->assertTrue($result->success); | |
+ $customer = $result->customer; | |
+ $this->assertNotNull($customer->amexExpressCheckoutCards[0]); | |
+ $this->assertNotNull($customer->paymentMethods[0]); | |
+ $amexExpressCheckoutCard = $customer->amexExpressCheckoutCards[0]; | |
+ $this->assertTrue($amexExpressCheckoutCard instanceof Braintree\AmexExpressCheckoutCard); | |
+ $this->assertNotNull($amexExpressCheckoutCard->token); | |
+ $this->assertNotNull($amexExpressCheckoutCard->expirationYear); | |
+ } | |
+ | |
+ public function testCreateCustomerWithVenmoAccount() | |
+ { | |
+ $nonce = Braintree\Test\Nonces::$venmoAccount; | |
+ $result = Braintree\Customer::create(array( | |
+ 'paymentMethodNonce' => $nonce | |
)); | |
$this->assertTrue($result->success); | |
$customer = $result->customer; | |
+ $this->assertNotNull($customer->venmoAccounts[0]); | |
+ $this->assertNotNull($customer->paymentMethods[0]); | |
+ $venmoAccount = $customer->venmoAccounts[0]; | |
+ $this->assertTrue($venmoAccount instanceof Braintree\VenmoAccount); | |
+ $this->assertNotNull($venmoAccount->token); | |
+ $this->assertNotNull($venmoAccount->username); | |
+ $this->assertNotNull($venmoAccount->venmoUserId); | |
+ } | |
+ | |
+ public function testCreateCustomerWithCoinbase() | |
+ { | |
+ $nonce = Braintree\Test\Nonces::$coinbase; | |
+ $result = Braintree\Customer::create([ | |
+ 'paymentMethodNonce' => $nonce | |
+ ]); | |
+ $this->assertTrue($result->success); | |
+ $customer = $result->customer; | |
$this->assertNotNull($customer->coinbaseAccounts[0]); | |
$this->assertNotNull($customer->coinbaseAccounts[0]->userId); | |
$this->assertNotNull($customer->coinbaseAccounts[0]->userName); | |
@@ -182,9 +220,9 @@ | |
$this->assertNotNull($customer->paymentMethods[0]); | |
} | |
- function testCreate_withUnicode() | |
+ public function testCreate_withUnicode() | |
{ | |
- $result = Braintree_Customer::create(array( | |
+ $result = Braintree\Customer::create([ | |
'firstName' => "Здравствуйте", | |
'lastName' => 'Jones', | |
'company' => 'Jones Co.', | |
@@ -192,7 +230,7 @@ | |
'phone' => '419.555.1234', | |
'fax' => '419.555.1235', | |
'website' => 'http://example.com' | |
- )); | |
+ ]); | |
$this->assertEquals(true, $result->success); | |
$customer = $result->customer; | |
$this->assertEquals("Здравствуйте", $customer->firstName); | |
@@ -205,22 +243,22 @@ | |
$this->assertNotNull($customer->merchantId); | |
} | |
- function testCreate_withCountry() | |
+ public function testCreate_withCountry() | |
{ | |
- $result = Braintree_Customer::create(array( | |
+ $result = Braintree\Customer::create([ | |
'firstName' => 'Bat', | |
'lastName' => 'Manderson', | |
- 'creditCard' => array( | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12', | |
- 'billingAddress' => array( | |
+ 'billingAddress' => [ | |
'countryName' => 'Gabon', | |
'countryCodeAlpha2' => 'GA', | |
'countryCodeAlpha3' => 'GAB', | |
'countryCodeNumeric' => '266' | |
- ) | |
- ) | |
- )); | |
+ ] | |
+ ] | |
+ ]); | |
$this->assertEquals(true, $result->success); | |
$customer = $result->customer; | |
$this->assertEquals('Gabon', $customer->creditCards[0]->billingAddress->countryName); | |
@@ -230,88 +268,88 @@ | |
$this->assertEquals(1, preg_match('/\A\w{32}\z/', $customer->creditCards[0]->uniqueNumberIdentifier)); | |
} | |
- function testCreate_withVenmoSdkSession() | |
+ public function testCreate_withVenmoSdkSession() | |
{ | |
- $result = Braintree_Customer::create(array( | |
+ $result = Braintree\Customer::create([ | |
'firstName' => 'Bat', | |
'lastName' => 'Manderson', | |
- 'creditCard' => array( | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12', | |
- 'options' => array( | |
- 'venmoSdkSession' => Braintree_Test_VenmoSdk::getTestSession() | |
- ) | |
- ) | |
- )); | |
+ 'options' => [ | |
+ 'venmoSdkSession' => Braintree\Test\VenmoSdk::getTestSession() | |
+ ] | |
+ ] | |
+ ]); | |
$this->assertEquals(true, $result->success); | |
$customer = $result->customer; | |
$this->assertEquals(true, $customer->creditCards[0]->venmoSdk); | |
} | |
- function testCreate_withVenmoSdkPaymentMethodCode() | |
+ public function testCreate_withVenmoSdkPaymentMethodCode() | |
{ | |
- $result = Braintree_Customer::create(array( | |
+ $result = Braintree\Customer::create([ | |
'firstName' => 'Bat', | |
'lastName' => 'Manderson', | |
- 'creditCard' => array( | |
- 'venmoSdkPaymentMethodCode' => Braintree_Test_VenmoSdk::$visaPaymentMethodCode | |
- ) | |
- )); | |
+ 'creditCard' => [ | |
+ 'venmoSdkPaymentMethodCode' => Braintree\Test\VenmoSdk::$visaPaymentMethodCode | |
+ ], | |
+ ]); | |
$this->assertEquals(true, $result->success); | |
$customer = $result->customer; | |
$this->assertEquals("411111", $customer->creditCards[0]->bin); | |
} | |
- function testCreate_blankCustomer() | |
+ public function testCreate_blankCustomer() | |
{ | |
- $result = Braintree_Customer::create(); | |
+ $result = Braintree\Customer::create(); | |
$this->assertEquals(true, $result->success); | |
$this->assertNotNull($result->customer->id); | |
- $result = Braintree_Customer::create(array()); | |
+ $result = Braintree\Customer::create([]); | |
$this->assertEquals(true, $result->success); | |
$this->assertNotNull($result->customer->id); | |
} | |
- function testCreate_withSpecialChars() | |
+ public function testCreate_withSpecialChars() | |
{ | |
- $result = Braintree_Customer::create(array('firstName' => '<>&"\'')); | |
+ $result = Braintree\Customer::create(['firstName' => '<>&"\'']); | |
$this->assertEquals(true, $result->success); | |
$this->assertEquals('<>&"\'', $result->customer->firstName); | |
} | |
- function testCreate_withCustomFields() | |
+ public function testCreate_withCustomFields() | |
{ | |
- $result = Braintree_Customer::create(array( | |
+ $result = Braintree\Customer::create([ | |
'firstName' => 'Mike', | |
- 'customFields' => array( | |
+ 'customFields' => [ | |
'store_me' => 'some custom value' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$this->assertEquals(true, $result->success); | |
$customFields = $result->customer->customFields; | |
$this->assertEquals('some custom value', $customFields['store_me']); | |
} | |
- function testCreate_withFraudParams() | |
+ public function testCreate_withFraudParams() | |
{ | |
- $result = Braintree_Customer::create(array( | |
+ $result = Braintree\Customer::create([ | |
'firstName' => 'Mike', | |
- 'creditCard' => array( | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12', | |
'cvv' => '123', | |
'cardholderName' => 'Mike Jones', | |
'deviceSessionId' => 'abc123', | |
'fraudMerchantId' => '456' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$this->assertEquals(true, $result->success); | |
} | |
- function testCreate_withCreditCard() | |
+ public function testCreate_withCreditCard() | |
{ | |
- $result = Braintree_Customer::create(array( | |
+ $result = Braintree\Customer::create([ | |
'firstName' => 'Mike', | |
'lastName' => 'Jones', | |
'company' => 'Jones Co.', | |
@@ -319,13 +357,13 @@ | |
'phone' => '419.555.1234', | |
'fax' => '419.555.1235', | |
'website' => 'http://example.com', | |
- 'creditCard' => array( | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12', | |
'cvv' => '123', | |
'cardholderName' => 'Mike Jones' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$this->assertEquals(true, $result->success); | |
$customer = $result->customer; | |
$this->assertEquals('Mike', $customer->firstName); | |
@@ -344,11 +382,11 @@ | |
$this->assertEquals('2012', $creditCard->expirationYear); | |
} | |
- function testCreate_withDuplicateCardCheck() | |
+ public function testCreate_withDuplicateCardCheck() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
+ $customer = Braintree\Customer::createNoValidate(); | |
- $attributes = array( | |
+ $attributes = [ | |
'firstName' => 'Mike', | |
'lastName' => 'Jones', | |
'company' => 'Jones Co.', | |
@@ -356,28 +394,28 @@ | |
'phone' => '419.555.1234', | |
'fax' => '419.555.1235', | |
'website' => 'http://example.com', | |
- 'creditCard' => array( | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12', | |
'cvv' => '123', | |
'cardholderName' => 'Mike Jones', | |
- 'options' => array( | |
+ 'options' => [ | |
'failOnDuplicatePaymentMethod' => true | |
- ) | |
- ) | |
- ); | |
- Braintree_Customer::create($attributes); | |
- $result = Braintree_Customer::create($attributes); | |
+ ] | |
+ ] | |
+ ]; | |
+ Braintree\Customer::create($attributes); | |
+ $result = Braintree\Customer::create($attributes); | |
$this->assertFalse($result->success); | |
$errors = $result->errors->forKey('customer')->forKey('creditCard')->onAttribute('number'); | |
- $this->assertEquals(Braintree_Error_Codes::CREDIT_CARD_DUPLICATE_CARD_EXISTS, $errors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::CREDIT_CARD_DUPLICATE_CARD_EXISTS, $errors[0]->code); | |
$this->assertEquals(1, preg_match('/Duplicate card exists in the vault\./', $result->message)); | |
} | |
- function testCreate_withCreditCardAndSpecificVerificationMerchantAccount() | |
+ public function testCreate_withCreditCardAndSpecificVerificationMerchantAccount() | |
{ | |
- $result = Braintree_Customer::create(array( | |
+ $result = Braintree\Customer::create([ | |
'firstName' => 'Mike', | |
'lastName' => 'Jones', | |
'company' => 'Jones Co.', | |
@@ -385,20 +423,20 @@ | |
'phone' => '419.555.1234', | |
'fax' => '419.555.1235', | |
'website' => 'http://example.com', | |
- 'creditCard' => array( | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12', | |
'cvv' => '123', | |
'cardholderName' => 'Mike Jones', | |
- 'options' => array( | |
- 'verificationMerchantAccountId' => Braintree_TestHelper::nonDefaultMerchantAccountId(), | |
+ 'options' => [ | |
+ 'verificationMerchantAccountId' => Test\Helper::nonDefaultMerchantAccountId(), | |
'verifyCard' => true | |
- ) | |
- ) | |
- )); | |
- Braintree_TestHelper::assertPrintable($result); | |
+ ] | |
+ ] | |
+ ]); | |
+ Test\Helper::assertPrintable($result); | |
$this->assertFalse($result->success); | |
- $this->assertEquals(Braintree_Result_CreditCardVerification::PROCESSOR_DECLINED, $result->creditCardVerification->status); | |
+ $this->assertEquals(Braintree\Result\CreditCardVerification::PROCESSOR_DECLINED, $result->creditCardVerification->status); | |
$this->assertEquals('2000', $result->creditCardVerification->processorResponseCode); | |
$this->assertEquals('Do Not Honor', $result->creditCardVerification->processorResponseText); | |
$this->assertEquals('M', $result->creditCardVerification->cvvResponseCode); | |
@@ -407,9 +445,9 @@ | |
$this->assertEquals('I', $result->creditCardVerification->avsStreetAddressResponseCode); | |
} | |
- function testCreate_withCreditCardAndBillingAddress() | |
+ public function testCreate_withCreditCardAndBillingAddress() | |
{ | |
- $result = Braintree_Customer::create(array( | |
+ $result = Braintree\Customer::create([ | |
'firstName' => 'Mike', | |
'lastName' => 'Jones', | |
'company' => 'Jones Co.', | |
@@ -417,12 +455,12 @@ | |
'phone' => '419.555.1234', | |
'fax' => '419.555.1235', | |
'website' => 'http://example.com', | |
- 'creditCard' => array( | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12', | |
'cvv' => '123', | |
'cardholderName' => 'Mike Jones', | |
- 'billingAddress' => array( | |
+ 'billingAddress' => [ | |
'firstName' => 'Drew', | |
'lastName' => 'Smith', | |
'company' => 'Smith Co.', | |
@@ -432,10 +470,10 @@ | |
'region' => 'IL', | |
'postalCode' => '60622', | |
'countryName' => 'United States of America' | |
- ) | |
- ) | |
- )); | |
- Braintree_TestHelper::assertPrintable($result); | |
+ ] | |
+ ] | |
+ ]); | |
+ Test\Helper::assertPrintable($result); | |
$this->assertEquals(true, $result->success); | |
$customer = $result->customer; | |
$this->assertEquals('Mike', $customer->firstName); | |
@@ -465,95 +503,95 @@ | |
$this->assertEquals('United States of America', $address->countryName); | |
} | |
- function testCreate_withValidationErrors() | |
+ public function testCreate_withValidationErrors() | |
{ | |
- $result = Braintree_Customer::create(array( | |
+ $result = Braintree\Customer::create([ | |
'email' => 'invalid', | |
- 'creditCard' => array( | |
+ 'creditCard' => [ | |
'number' => 'invalid', | |
- 'billingAddress' => array( | |
+ 'billingAddress' => [ | |
'streetAddress' => str_repeat('x', 256) | |
- ) | |
- ) | |
- )); | |
- Braintree_TestHelper::assertPrintable($result); | |
+ ] | |
+ ] | |
+ ]); | |
+ Test\Helper::assertPrintable($result); | |
$this->assertEquals(false, $result->success); | |
$errors = $result->errors->forKey('customer')->onAttribute('email'); | |
- $this->assertEquals(Braintree_Error_Codes::CUSTOMER_EMAIL_IS_INVALID, $errors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::CUSTOMER_EMAIL_IS_INVALID, $errors[0]->code); | |
$errors = $result->errors->forKey('customer')->forKey('creditCard')->onAttribute('number'); | |
- $this->assertEquals(Braintree_Error_Codes::CREDIT_CARD_NUMBER_INVALID_LENGTH, $errors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::CREDIT_CARD_NUMBER_INVALID_LENGTH, $errors[0]->code); | |
$errors = $result->errors->forKey('customer')->forKey('creditCard')->forKey('billingAddress')->onAttribute('streetAddress'); | |
- $this->assertEquals(Braintree_Error_Codes::ADDRESS_STREET_ADDRESS_IS_TOO_LONG, $errors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::ADDRESS_STREET_ADDRESS_IS_TOO_LONG, $errors[0]->code); | |
} | |
- function testCreate_countryValidations_inconsistency() | |
+ public function testCreate_countryValidations_inconsistency() | |
{ | |
- $result = Braintree_Customer::create(array( | |
- 'creditCard' => array( | |
- 'billingAddress' => array( | |
+ $result = Braintree\Customer::create([ | |
+ 'creditCard' => [ | |
+ 'billingAddress' => [ | |
'countryName' => 'Georgia', | |
'countryCodeAlpha2' => 'TF' | |
- ) | |
- ) | |
- )); | |
+ ] | |
+ ] | |
+ ]); | |
$this->assertEquals(false, $result->success); | |
$errors = $result->errors->forKey('customer')->forKey('creditCard')->forKey('billingAddress')->onAttribute('base'); | |
- $this->assertEquals(Braintree_Error_Codes::ADDRESS_INCONSISTENT_COUNTRY, $errors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::ADDRESS_INCONSISTENT_COUNTRY, $errors[0]->code); | |
} | |
- function testCreateNoValidate_returnsCustomer() | |
+ public function testCreateNoValidate_returnsCustomer() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(array( | |
+ $customer = Braintree\Customer::createNoValidate([ | |
'firstName' => 'Paul', | |
'lastName' => 'Martin' | |
- )); | |
+ ]); | |
$this->assertEquals('Paul', $customer->firstName); | |
$this->assertEquals('Martin', $customer->lastName); | |
} | |
- function testCreateNoValidate_throwsIfInvalid() | |
+ public function testCreateNoValidate_throwsIfInvalid() | |
{ | |
- $this->setExpectedException('Braintree_Exception_ValidationsFailed'); | |
- $customer = Braintree_Customer::createNoValidate(array('email' => 'invalid')); | |
+ $this->setExpectedException('Braintree\Exception\ValidationsFailed'); | |
+ $customer = Braintree\Customer::createNoValidate(['email' => 'invalid']); | |
} | |
- function testCreate_worksWithFuturePayPalNonce() | |
+ public function testCreate_worksWithFuturePayPalNonce() | |
{ | |
- $nonce = Braintree_Test_Nonces::$paypalFuturePayment; | |
+ $nonce = Braintree\Test\Nonces::$paypalFuturePayment; | |
- $result = Braintree_Customer::create(array( | |
+ $result = Braintree\Customer::create([ | |
'paymentMethodNonce' => $nonce | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
} | |
- function testCreate_doesNotWorkWithOnetimePayPalNonce() | |
+ public function testCreate_doesNotWorkWithOnetimePayPalNonce() | |
{ | |
- $nonce = Braintree_Test_Nonces::$paypalOneTimePayment; | |
+ $nonce = Braintree\Test\Nonces::$paypalOneTimePayment; | |
- $result = Braintree_Customer::create(array( | |
+ $result = Braintree\Customer::create([ | |
'paymentMethodNonce' => $nonce | |
- )); | |
+ ]); | |
$this->assertFalse($result->success); | |
$errors = $result->errors->forKey('customer')->forKey('paypalAccount')->errors; | |
- $this->assertEquals(Braintree_Error_Codes::PAYPAL_ACCOUNT_CANNOT_VAULT_ONE_TIME_USE_PAYPAL_ACCOUNT, $errors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::PAYPAL_ACCOUNT_CANNOT_VAULT_ONE_TIME_USE_PAYPAL_ACCOUNT, $errors[0]->code); | |
} | |
- function testDelete_deletesTheCustomer() | |
+ public function testDelete_deletesTheCustomer() | |
{ | |
- $result = Braintree_Customer::create(array()); | |
+ $result = Braintree\Customer::create([]); | |
$this->assertEquals(true, $result->success); | |
- Braintree_Customer::find($result->customer->id); | |
- Braintree_Customer::delete($result->customer->id); | |
- $this->setExpectedException('Braintree_Exception_NotFound'); | |
- Braintree_Customer::find($result->customer->id); | |
+ Braintree\Customer::find($result->customer->id); | |
+ Braintree\Customer::delete($result->customer->id); | |
+ $this->setExpectedException('Braintree\Exception\NotFound'); | |
+ Braintree\Customer::find($result->customer->id); | |
} | |
- function testFind() | |
+ public function testFind() | |
{ | |
- $result = Braintree_Customer::create(array( | |
+ $result = Braintree\Customer::create([ | |
'firstName' => 'Mike', | |
'lastName' => 'Jones', | |
'company' => 'Jones Co.', | |
@@ -561,9 +599,9 @@ | |
'phone' => '419.555.1234', | |
'fax' => '419.555.1235', | |
'website' => 'http://example.com' | |
- )); | |
+ ]); | |
$this->assertEquals(true, $result->success); | |
- $customer = Braintree_Customer::find($result->customer->id); | |
+ $customer = Braintree\Customer::find($result->customer->id); | |
$this->assertEquals('Mike', $customer->firstName); | |
$this->assertEquals('Jones', $customer->lastName); | |
$this->assertEquals('Jones Co.', $customer->company); | |
@@ -573,15 +611,15 @@ | |
$this->assertEquals('http://example.com', $customer->website); | |
} | |
- function testFind_throwsExceptionIfNotFound() | |
+ public function testFind_throwsExceptionIfNotFound() | |
{ | |
- $this->setExpectedException('Braintree_Exception_NotFound'); | |
- Braintree_Customer::find("does-not-exist"); | |
+ $this->setExpectedException('Braintree\Exception\NotFound'); | |
+ Braintree\Customer::find("does-not-exist"); | |
} | |
- function testUpdate() | |
+ public function testUpdate() | |
{ | |
- $result = Braintree_Customer::create(array( | |
+ $result = Braintree\Customer::create([ | |
'firstName' => 'Old First', | |
'lastName' => 'Old Last', | |
'company' => 'Old Company', | |
@@ -589,10 +627,10 @@ | |
'phone' => 'old phone', | |
'fax' => 'old fax', | |
'website' => 'http://old.example.com' | |
- )); | |
+ ]); | |
$this->assertEquals(true, $result->success); | |
$customer = $result->customer; | |
- $updateResult = Braintree_Customer::update($customer->id, array( | |
+ $updateResult = Braintree\Customer::update($customer->id, [ | |
'firstName' => 'New First', | |
'lastName' => 'New Last', | |
'company' => 'New Company', | |
@@ -600,7 +638,7 @@ | |
'phone' => 'new phone', | |
'fax' => 'new fax', | |
'website' => 'http://new.example.com' | |
- )); | |
+ ]); | |
$this->assertEquals(true, $updateResult->success); | |
$this->assertEquals('New First', $updateResult->customer->firstName); | |
$this->assertEquals('New Last', $updateResult->customer->lastName); | |
@@ -611,41 +649,41 @@ | |
$this->assertEquals('http://new.example.com', $updateResult->customer->website); | |
} | |
- function testUpdate_withCountry() | |
+ public function testUpdate_withCountry() | |
{ | |
- $customer = Braintree_Customer::create(array( | |
+ $customer = Braintree\Customer::create([ | |
'firstName' => 'Bat', | |
'lastName' => 'Manderson', | |
- 'creditCard' => array( | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12', | |
- 'billingAddress' => array( | |
+ 'billingAddress' => [ | |
'countryName' => 'United States of America', | |
'countryCodeAlpha2' => 'US', | |
'countryCodeAlpha3' => 'USA', | |
'countryCodeNumeric' => '840' | |
- ) | |
- ) | |
- ))->customer; | |
+ ] | |
+ ] | |
+ ])->customer; | |
- $result = Braintree_Customer::update($customer->id, array( | |
+ $result = Braintree\Customer::update($customer->id, [ | |
'firstName' => 'Bat', | |
'lastName' => 'Manderson', | |
- 'creditCard' => array( | |
- 'options' => array( | |
+ 'creditCard' => [ | |
+ 'options' => [ | |
'updateExistingToken' => $customer->creditCards[0]->token | |
- ), | |
- 'billingAddress' => array( | |
+ ], | |
+ 'billingAddress' => [ | |
'countryName' => 'Gabon', | |
'countryCodeAlpha2' => 'GA', | |
'countryCodeAlpha3' => 'GAB', | |
'countryCodeNumeric' => '266', | |
- 'options' => array( | |
+ 'options' => [ | |
'updateExisting' => true | |
- ) | |
- ) | |
- ) | |
- )); | |
+ ] | |
+ ] | |
+ ] | |
+ ]); | |
$this->assertEquals(true, $result->success); | |
$updatedCustomer = $result->customer; | |
@@ -655,33 +693,33 @@ | |
$this->assertEquals('266', $updatedCustomer->creditCards[0]->billingAddress->countryCodeNumeric); | |
} | |
- function testUpdate_withUpdatingExistingCreditCard() | |
+ public function testUpdate_withUpdatingExistingCreditCard() | |
{ | |
- $create_result = Braintree_Customer::create(array( | |
+ $create_result = Braintree\Customer::create([ | |
'firstName' => 'Old First', | |
'lastName' => 'Old Last', | |
'website' => 'http://old.example.com', | |
- 'creditCard' => array( | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12', | |
'cardholderName' => 'Old Cardholder' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$this->assertEquals(true, $create_result->success); | |
$customer = $create_result->customer; | |
$creditCard = $customer->creditCards[0]; | |
- $result = Braintree_Customer::update($customer->id, array( | |
+ $result = Braintree\Customer::update($customer->id, [ | |
'firstName' => 'New First', | |
'lastName' => 'New Last', | |
- 'creditCard' => array( | |
+ 'creditCard' => [ | |
'number' => '4111111111111111', | |
'expirationDate' => '11/14', | |
'cardholderName' => 'New Cardholder', | |
- 'options' => array( | |
+ 'options' => [ | |
'updateExistingToken' => $creditCard->token | |
- ) | |
- ) | |
- )); | |
+ ] | |
+ ] | |
+ ]); | |
$this->assertEquals(true, $result->success); | |
$this->assertEquals('New First', $result->customer->firstName); | |
$this->assertEquals('New Last', $result->customer->lastName); | |
@@ -692,43 +730,43 @@ | |
$this->assertEquals('New Cardholder', $creditCard->cardholderName); | |
} | |
- function testUpdate_forBillingAddressAndExistingCreditCardAndCustomerDetailsTogether() | |
+ public function testUpdate_forBillingAddressAndExistingCreditCardAndCustomerDetailsTogether() | |
{ | |
- $create_result = Braintree_Customer::create(array( | |
+ $create_result = Braintree\Customer::create([ | |
'firstName' => 'Old First', | |
'lastName' => 'Old Last', | |
- 'creditCard' => array( | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12', | |
'cvv' => '123', | |
'cardholderName' => 'Old Cardholder', | |
- 'billingAddress' => array( | |
+ 'billingAddress' => [ | |
'firstName' => 'Drew', | |
'lastName' => 'Smith' | |
- ) | |
- ) | |
- )); | |
+ ] | |
+ ] | |
+ ]); | |
$this->assertEquals(true, $create_result->success); | |
$customer = $create_result->customer; | |
$creditCard = $customer->creditCards[0]; | |
- $result = Braintree_Customer::update($customer->id, array( | |
+ $result = Braintree\Customer::update($customer->id, [ | |
'firstName' => 'New Customer First', | |
'lastName' => 'New Customer Last', | |
- 'creditCard' => array( | |
+ 'creditCard' => [ | |
'number' => '4111111111111111', | |
'expirationDate' => '11/14', | |
- 'options' => array( | |
+ 'options' => [ | |
'updateExistingToken' => $creditCard->token | |
- ), | |
- 'billingAddress' => array( | |
+ ], | |
+ 'billingAddress' => [ | |
'firstName' => 'New Billing First', | |
'lastName' => 'New Billing Last', | |
- 'options' => array( | |
+ 'options' => [ | |
'updateExisting' => true | |
- ) | |
- ) | |
- ) | |
- )); | |
+ ] | |
+ ] | |
+ ] | |
+ ]); | |
$this->assertEquals(true, $result->success); | |
$this->assertEquals('New Customer First', $result->customer->firstName); | |
$this->assertEquals('New Customer Last', $result->customer->lastName); | |
@@ -744,95 +782,95 @@ | |
$this->assertEquals('New Billing Last', $billingAddress->lastName); | |
} | |
- function testUpdate_withNewCreditCardAndExistingBillingAddress() | |
+ public function testUpdate_withNewCreditCardAndExistingBillingAddress() | |
{ | |
- $customer = Braintree_Customer::create()->customer; | |
- $address = Braintree_Address::create(array( | |
+ $customer = Braintree\Customer::create()->customer; | |
+ $address = Braintree\Address::create([ | |
'customerId' => $customer->id, | |
'firstName' => 'Dan' | |
- ))->address; | |
+ ])->address; | |
- $result = Braintree_Customer::update($customer->id, array( | |
- 'creditCard' => array( | |
+ $result = Braintree\Customer::update($customer->id, [ | |
+ 'creditCard' => [ | |
'number' => '4111111111111111', | |
'expirationDate' => '11/14', | |
'billingAddressId' => $address->id | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$billingAddress = $result->customer->creditCards[0]->billingAddress; | |
$this->assertEquals($address->id, $billingAddress->id); | |
$this->assertEquals('Dan', $billingAddress->firstName); | |
} | |
- function testUpdate_worksWithFuturePayPalNonce() | |
+ public function testUpdate_worksWithFuturePayPalNonce() | |
{ | |
- $customerResult = Braintree_Customer::create(array( | |
- 'creditCard' => array( | |
+ $customerResult = Braintree\Customer::create([ | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12', | |
- 'options' => array( | |
+ 'options' => [ | |
'makeDefault' => true | |
- ) | |
- ) | |
- )); | |
+ ] | |
+ ] | |
+ ]); | |
$paypalAccountToken = 'PAYPALToken-' . strval(rand()); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonceForPayPalAccount(array( | |
- 'paypal_account' => array( | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonceForPayPalAccount([ | |
+ 'paypal_account' => [ | |
'consent_code' => 'PAYPAL_CONSENT_CODE', | |
'token' => $paypalAccountToken, | |
- 'options' => array( | |
+ 'options' => [ | |
'makeDefault' => true | |
- ) | |
- ) | |
- )); | |
+ ] | |
+ ] | |
+ ]); | |
- $result = Braintree_Customer::update($customerResult->customer->id, array( | |
+ $result = Braintree\Customer::update($customerResult->customer->id, [ | |
'paymentMethodNonce' => $nonce | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
$this->assertEquals($result->customer->defaultPaymentMethod()->token, $paypalAccountToken); | |
} | |
- function testUpdate_doesNotWorkWithOnetimePayPalNonce() | |
+ public function testUpdate_doesNotWorkWithOnetimePayPalNonce() | |
{ | |
- $customerResult = Braintree_Customer::create(array( | |
- 'creditCard' => array( | |
+ $customerResult = Braintree\Customer::create([ | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12', | |
- 'options' => array( | |
+ 'options' => [ | |
'makeDefault' => true | |
- ) | |
- ) | |
- )); | |
+ ] | |
+ ] | |
+ ]); | |
$paypalAccountToken = 'PAYPALToken-' . strval(rand()); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonceForPayPalAccount(array( | |
- 'paypal_account' => array( | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonceForPayPalAccount([ | |
+ 'paypal_account' => [ | |
'access_token' => 'PAYPAL_ACCESS_TOKEN', | |
'token' => $paypalAccountToken, | |
- 'options' => array( | |
+ 'options' => [ | |
'makeDefault' => true | |
- ) | |
- ) | |
- )); | |
+ ] | |
+ ] | |
+ ]); | |
- $result = Braintree_Customer::update($customerResult->customer->id, array( | |
+ $result = Braintree\Customer::update($customerResult->customer->id, [ | |
'paymentMethodNonce' => $nonce | |
- )); | |
+ ]); | |
$this->assertFalse($result->success); | |
$errors = $result->errors->forKey('customer')->forKey('paypalAccount')->errors; | |
- $this->assertEquals(Braintree_Error_Codes::PAYPAL_ACCOUNT_CANNOT_VAULT_ONE_TIME_USE_PAYPAL_ACCOUNT, $errors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::PAYPAL_ACCOUNT_CANNOT_VAULT_ONE_TIME_USE_PAYPAL_ACCOUNT, $errors[0]->code); | |
} | |
- function testUpdateNoValidate() | |
+ public function testUpdateNoValidate() | |
{ | |
- $result = Braintree_Customer::create(array( | |
+ $result = Braintree\Customer::create([ | |
'firstName' => 'Old First', | |
'lastName' => 'Old Last', | |
'company' => 'Old Company', | |
@@ -840,10 +878,10 @@ | |
'phone' => 'old phone', | |
'fax' => 'old fax', | |
'website' => 'http://old.example.com' | |
- )); | |
+ ]); | |
$this->assertEquals(true, $result->success); | |
$customer = $result->customer; | |
- $updated = Braintree_Customer::updateNoValidate($customer->id, array( | |
+ $updated = Braintree\Customer::updateNoValidate($customer->id, [ | |
'firstName' => 'New First', | |
'lastName' => 'New Last', | |
'company' => 'New Company', | |
@@ -851,7 +889,7 @@ | |
'phone' => 'new phone', | |
'fax' => 'new fax', | |
'website' => 'http://new.example.com' | |
- )); | |
+ ]); | |
$this->assertEquals('New First', $updated->firstName); | |
$this->assertEquals('New Last', $updated->lastName); | |
$this->assertEquals('New Company', $updated->company); | |
@@ -861,24 +899,24 @@ | |
$this->assertEquals('http://new.example.com', $updated->website); | |
} | |
- function testCreateFromTransparentRedirect() | |
+ public function testCreateFromTransparentRedirect() | |
{ | |
- Braintree_TestHelper::suppressDeprecationWarnings(); | |
+ Test\Helper::suppressDeprecationWarnings(); | |
$queryString = $this->createCustomerViaTr( | |
- array( | |
- 'customer' => array( | |
+ [ | |
+ 'customer' => [ | |
'first_name' => 'Joe', | |
'last_name' => 'Martin', | |
- 'credit_card' => array( | |
+ 'credit_card' => [ | |
'number' => '5105105105105100', | |
'expiration_date' => '05/12' | |
- ) | |
- ) | |
- ), | |
- array( | |
- ) | |
+ ] | |
+ ] | |
+ ], | |
+ [ | |
+ ] | |
); | |
- $result = Braintree_Customer::createFromTransparentRedirect($queryString); | |
+ $result = Braintree\Customer::createFromTransparentRedirect($queryString); | |
$this->assertTrue($result->success); | |
$this->assertEquals('Joe', $result->customer->firstName); | |
$this->assertEquals('Martin', $result->customer->lastName); | |
@@ -888,24 +926,24 @@ | |
$this->assertEquals('05/2012', $creditCard->expirationDate); | |
} | |
- function testCreateFromTransparentRedirect_withParamsInTrData() | |
+ public function testCreateFromTransparentRedirect_withParamsInTrData() | |
{ | |
- Braintree_TestHelper::suppressDeprecationWarnings(); | |
+ Test\Helper::suppressDeprecationWarnings(); | |
$queryString = $this->createCustomerViaTr( | |
- array( | |
- ), | |
- array( | |
- 'customer' => array( | |
+ [ | |
+ ], | |
+ [ | |
+ 'customer' => [ | |
'firstName' => 'Joe', | |
'lastName' => 'Martin', | |
- 'creditCard' => array( | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- ) | |
- ) | |
- ) | |
+ ] | |
+ ] | |
+ ] | |
); | |
- $result = Braintree_Customer::createFromTransparentRedirect($queryString); | |
+ $result = Braintree\Customer::createFromTransparentRedirect($queryString); | |
$this->assertTrue($result->success); | |
$this->assertEquals('Joe', $result->customer->firstName); | |
$this->assertEquals('Martin', $result->customer->lastName); | |
@@ -915,161 +953,161 @@ | |
$this->assertEquals('05/2012', $creditCard->expirationDate); | |
} | |
- function testCreateFromTransparentRedirect_withValidationErrors() | |
+ public function testCreateFromTransparentRedirect_withValidationErrors() | |
{ | |
- Braintree_TestHelper::suppressDeprecationWarnings(); | |
+ Test\Helper::suppressDeprecationWarnings(); | |
$queryString = $this->createCustomerViaTr( | |
- array( | |
- 'customer' => array( | |
+ [ | |
+ 'customer' => [ | |
'first_name' => str_repeat('x', 256), | |
- 'credit_card' => array( | |
+ 'credit_card' => [ | |
'number' => 'invalid', | |
'expiration_date' => '' | |
- ) | |
- ) | |
- ), | |
- array( | |
- ) | |
+ ] | |
+ ] | |
+ ], | |
+ [ | |
+ ] | |
); | |
- $result = Braintree_Customer::createFromTransparentRedirect($queryString); | |
+ $result = Braintree\Customer::createFromTransparentRedirect($queryString); | |
$this->assertFalse($result->success); | |
$errors = $result->errors->forKey('customer')->onAttribute('firstName'); | |
- $this->assertEquals(Braintree_Error_Codes::CUSTOMER_FIRST_NAME_IS_TOO_LONG, $errors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::CUSTOMER_FIRST_NAME_IS_TOO_LONG, $errors[0]->code); | |
$errors = $result->errors->forKey('customer')->forKey('creditCard')->onAttribute('number'); | |
- $this->assertEquals(Braintree_Error_Codes::CREDIT_CARD_NUMBER_INVALID_LENGTH, $errors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::CREDIT_CARD_NUMBER_INVALID_LENGTH, $errors[0]->code); | |
$errors = $result->errors->forKey('customer')->forKey('creditCard')->onAttribute('expirationDate'); | |
- $this->assertEquals(Braintree_Error_Codes::CREDIT_CARD_EXPIRATION_DATE_IS_REQUIRED, $errors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::CREDIT_CARD_EXPIRATION_DATE_IS_REQUIRED, $errors[0]->code); | |
} | |
- function testCreateWithInvalidUTF8Bytes() | |
+ public function testCreateWithInvalidUTF8Bytes() | |
{ | |
- $result = Braintree_Customer::create(array( | |
- 'firstName' => "Jos\xe8 Maria", | |
- )); | |
+ $result = Braintree\Customer::create([ | |
+ 'firstName' => "Jos\xe8 Maria" | |
+ ]); | |
$this->assertEquals(true, $result->success); | |
$customer = $result->customer; | |
$this->assertEquals("Jos\xc3\xa8 Maria", $customer->firstName); | |
} | |
- function testCreateWithValidUTF8Bytes() | |
+ public function testCreateWithValidUTF8Bytes() | |
{ | |
- $result = Braintree_Customer::create(array( | |
- 'firstName' => "Jos\303\251", | |
- )); | |
+ $result = Braintree\Customer::create([ | |
+ 'firstName' => "Jos\303\251" | |
+ ]); | |
$this->assertEquals(true, $result->success); | |
$customer = $result->customer; | |
$this->assertEquals("Jos\303\251", $customer->firstName); | |
} | |
- function testUpdateFromTransparentRedirect() | |
+ public function testUpdateFromTransparentRedirect() | |
{ | |
- Braintree_TestHelper::suppressDeprecationWarnings(); | |
- $customer = Braintree_Customer::createNoValidate(); | |
+ Test\Helper::suppressDeprecationWarnings(); | |
+ $customer = Braintree\Customer::createNoValidate(); | |
$queryString = $this->updateCustomerViaTr( | |
- array( | |
- 'customer' => array( | |
+ [ | |
+ 'customer' => [ | |
'first_name' => 'Joe', | |
'last_name' => 'Martin', | |
'email' => '[email protected]' | |
- ) | |
- ), | |
- array( | |
+ ] | |
+ ], | |
+ [ | |
'customerId' => $customer->id | |
- ) | |
+ ] | |
); | |
- $result = Braintree_Customer::updateFromTransparentRedirect($queryString); | |
+ $result = Braintree\Customer::updateFromTransparentRedirect($queryString); | |
$this->assertTrue($result->success); | |
$this->assertEquals('Joe', $result->customer->firstName); | |
$this->assertEquals('Martin', $result->customer->lastName); | |
$this->assertEquals('[email protected]', $result->customer->email); | |
} | |
- function testUpdateFromTransparentRedirect_withParamsInTrData() | |
+ public function testUpdateFromTransparentRedirect_withParamsInTrData() | |
{ | |
- Braintree_TestHelper::suppressDeprecationWarnings(); | |
- $customer = Braintree_Customer::createNoValidate(); | |
+ Test\Helper::suppressDeprecationWarnings(); | |
+ $customer = Braintree\Customer::createNoValidate(); | |
$queryString = $this->updateCustomerViaTr( | |
- array( | |
- ), | |
- array( | |
+ [ | |
+ ], | |
+ [ | |
'customerId' => $customer->id, | |
- 'customer' => array( | |
+ 'customer' => [ | |
'firstName' => 'Joe', | |
'lastName' => 'Martin', | |
'email' => '[email protected]' | |
- ) | |
- ) | |
+ ] | |
+ ] | |
); | |
- $result = Braintree_Customer::updateFromTransparentRedirect($queryString); | |
+ $result = Braintree\Customer::updateFromTransparentRedirect($queryString); | |
$this->assertTrue($result->success); | |
$this->assertEquals('Joe', $result->customer->firstName); | |
$this->assertEquals('Martin', $result->customer->lastName); | |
$this->assertEquals('[email protected]', $result->customer->email); | |
} | |
- function testUpdateFromTransparentRedirect_withValidationErrors() | |
+ public function testUpdateFromTransparentRedirect_withValidationErrors() | |
{ | |
- Braintree_TestHelper::suppressDeprecationWarnings(); | |
- $customer = Braintree_Customer::createNoValidate(); | |
+ Test\Helper::suppressDeprecationWarnings(); | |
+ $customer = Braintree\Customer::createNoValidate(); | |
$queryString = $this->updateCustomerViaTr( | |
- array( | |
- 'customer' => array( | |
+ [ | |
+ 'customer' => [ | |
'first_name' => str_repeat('x', 256), | |
- ) | |
- ), | |
- array( | |
+ ] | |
+ ], | |
+ [ | |
'customerId' => $customer->id | |
- ) | |
+ ] | |
); | |
- $result = Braintree_Customer::updateFromTransparentRedirect($queryString); | |
+ $result = Braintree\Customer::updateFromTransparentRedirect($queryString); | |
$this->assertFalse($result->success); | |
$errors = $result->errors->forKey('customer')->onAttribute('firstName'); | |
- $this->assertEquals(Braintree_Error_Codes::CUSTOMER_FIRST_NAME_IS_TOO_LONG, $errors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::CUSTOMER_FIRST_NAME_IS_TOO_LONG, $errors[0]->code); | |
} | |
- function testUpdateFromTransparentRedirect_withUpdateExisting() | |
+ public function testUpdateFromTransparentRedirect_withUpdateExisting() | |
{ | |
- Braintree_TestHelper::suppressDeprecationWarnings(); | |
- $customer = Braintree_Customer::create(array( | |
+ Test\Helper::suppressDeprecationWarnings(); | |
+ $customer = Braintree\Customer::create([ | |
'firstName' => 'Mike', | |
'lastName' => 'Jones', | |
- 'creditCard' => array( | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12', | |
'cardholderName' => 'Mike Jones', | |
- 'billingAddress' => array( | |
+ 'billingAddress' => [ | |
'firstName' => 'Drew', | |
'lastName' => 'Smith' | |
- ) | |
- ) | |
- ))->customer; | |
+ ] | |
+ ] | |
+ ])->customer; | |
$queryString = $this->updateCustomerViaTr( | |
- array(), | |
- array( | |
+ [], | |
+ [ | |
'customerId' => $customer->id, | |
- 'customer' => array( | |
+ 'customer' => [ | |
'firstName' => 'New First', | |
'lastName' => 'New Last', | |
- 'creditCard' => array( | |
+ 'creditCard' => [ | |
'number' => '4111111111111111', | |
'expirationDate' => '05/13', | |
'cardholderName' => 'New Cardholder', | |
- 'options' => array( | |
+ 'options' => [ | |
'updateExistingToken' => $customer->creditCards[0]->token | |
- ), | |
- 'billingAddress' => array( | |
+ ], | |
+ 'billingAddress' => [ | |
'firstName' => 'New First Billing', | |
'lastName' => 'New Last Billing', | |
- 'options' => array( | |
+ 'options' => [ | |
'updateExisting' => true | |
- ) | |
- ) | |
- ) | |
- ) | |
- ) | |
+ ] | |
+ ] | |
+ ] | |
+ ] | |
+ ] | |
); | |
- $result = Braintree_Customer::updateFromTransparentRedirect($queryString); | |
+ $result = Braintree\Customer::updateFromTransparentRedirect($queryString); | |
$this->assertTrue($result->success); | |
$this->assertEquals(true, $result->success); | |
@@ -1091,129 +1129,129 @@ | |
$this->assertEquals('New Last Billing', $address->lastName); | |
} | |
- function testSale_createsASaleUsingGivenToken() | |
+ public function testSale_createsASaleUsingGivenToken() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(array( | |
- 'creditCard' => array( | |
+ $customer = Braintree\Customer::createNoValidate([ | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$creditCard = $customer->creditCards[0]; | |
- $result = Braintree_Customer::sale($customer->id, array( | |
+ $result = Braintree\Customer::sale($customer->id, [ | |
'amount' => '100.00' | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
$this->assertEquals('100.00', $result->transaction->amount); | |
$this->assertEquals($customer->id, $result->transaction->customerDetails->id); | |
$this->assertEquals($creditCard->token, $result->transaction->creditCardDetails->token); | |
} | |
- function testSaleNoValidate_createsASaleUsingGivenToken() | |
+ public function testSaleNoValidate_createsASaleUsingGivenToken() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(array( | |
- 'creditCard' => array( | |
+ $customer = Braintree\Customer::createNoValidate([ | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$creditCard = $customer->creditCards[0]; | |
- $transaction = Braintree_Customer::saleNoValidate($customer->id, array( | |
+ $transaction = Braintree\Customer::saleNoValidate($customer->id, [ | |
'amount' => '100.00' | |
- )); | |
+ ]); | |
$this->assertEquals('100.00', $transaction->amount); | |
$this->assertEquals($customer->id, $transaction->customerDetails->id); | |
$this->assertEquals($creditCard->token, $transaction->creditCardDetails->token); | |
} | |
- function testSaleNoValidate_throwsIfInvalid() | |
+ public function testSaleNoValidate_throwsIfInvalid() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(array( | |
- 'creditCard' => array( | |
+ $customer = Braintree\Customer::createNoValidate([ | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$creditCard = $customer->creditCards[0]; | |
- $this->setExpectedException('Braintree_Exception_ValidationsFailed'); | |
- Braintree_Customer::saleNoValidate($customer->id, array( | |
+ $this->setExpectedException('Braintree\Exception\ValidationsFailed'); | |
+ Braintree\Customer::saleNoValidate($customer->id, [ | |
'amount' => 'invalid' | |
- )); | |
+ ]); | |
} | |
- function testCredit_createsACreditUsingGivenCustomerId() | |
+ public function testCredit_createsACreditUsingGivenCustomerId() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(array( | |
- 'creditCard' => array( | |
+ $customer = Braintree\Customer::createNoValidate([ | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$creditCard = $customer->creditCards[0]; | |
- $result = Braintree_Customer::credit($customer->id, array( | |
+ $result = Braintree\Customer::credit($customer->id, [ | |
'amount' => '100.00' | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
$this->assertEquals('100.00', $result->transaction->amount); | |
- $this->assertEquals(Braintree_Transaction::CREDIT, $result->transaction->type); | |
+ $this->assertEquals(Braintree\Transaction::CREDIT, $result->transaction->type); | |
$this->assertEquals($customer->id, $result->transaction->customerDetails->id); | |
$this->assertEquals($creditCard->token, $result->transaction->creditCardDetails->token); | |
} | |
- function testCreditNoValidate_createsACreditUsingGivenId() | |
+ public function testCreditNoValidate_createsACreditUsingGivenId() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(array( | |
- 'creditCard' => array( | |
+ $customer = Braintree\Customer::createNoValidate([ | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$creditCard = $customer->creditCards[0]; | |
- $transaction = Braintree_Customer::creditNoValidate($customer->id, array( | |
+ $transaction = Braintree\Customer::creditNoValidate($customer->id, [ | |
'amount' => '100.00' | |
- )); | |
+ ]); | |
$this->assertEquals('100.00', $transaction->amount); | |
- $this->assertEquals(Braintree_Transaction::CREDIT, $transaction->type); | |
+ $this->assertEquals(Braintree\Transaction::CREDIT, $transaction->type); | |
$this->assertEquals($customer->id, $transaction->customerDetails->id); | |
$this->assertEquals($creditCard->token, $transaction->creditCardDetails->token); | |
} | |
- function testCreditNoValidate_throwsIfInvalid() | |
+ public function testCreditNoValidate_throwsIfInvalid() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(array( | |
- 'creditCard' => array( | |
+ $customer = Braintree\Customer::createNoValidate([ | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$creditCard = $customer->creditCards[0]; | |
- $this->setExpectedException('Braintree_Exception_ValidationsFailed'); | |
- Braintree_Customer::creditNoValidate($customer->id, array( | |
+ $this->setExpectedException('Braintree\Exception\ValidationsFailed'); | |
+ Braintree\Customer::creditNoValidate($customer->id, [ | |
'amount' => 'invalid' | |
- )); | |
+ ]); | |
} | |
- function createCustomerViaTr($regularParams, $trParams) | |
+ public function createCustomerViaTr($regularParams, $trParams) | |
{ | |
- Braintree_TestHelper::suppressDeprecationWarnings(); | |
- $trData = Braintree_TransparentRedirect::createCustomerData( | |
- array_merge($trParams, array("redirectUrl" => "http://www.example.com")) | |
+ Test\Helper::suppressDeprecationWarnings(); | |
+ $trData = Braintree\TransparentRedirect::createCustomerData( | |
+ array_merge($trParams, ["redirectUrl" => "http://www.example.com"]) | |
); | |
- return Braintree_TestHelper::submitTrRequest( | |
- Braintree_Customer::createCustomerUrl(), | |
+ return Test\Helper::submitTrRequest( | |
+ Braintree\Customer::createCustomerUrl(), | |
$regularParams, | |
$trData | |
); | |
} | |
- function updateCustomerViaTr($regularParams, $trParams) | |
+ public function updateCustomerViaTr($regularParams, $trParams) | |
{ | |
- Braintree_TestHelper::suppressDeprecationWarnings(); | |
- $trData = Braintree_TransparentRedirect::updateCustomerData( | |
- array_merge($trParams, array("redirectUrl" => "http://www.example.com")) | |
+ Test\Helper::suppressDeprecationWarnings(); | |
+ $trData = Braintree\TransparentRedirect::updateCustomerData( | |
+ array_merge($trParams, ["redirectUrl" => "http://www.example.com"]) | |
); | |
- return Braintree_TestHelper::submitTrRequest( | |
- Braintree_Customer::updateCustomerUrl(), | |
+ return Test\Helper::submitTrRequest( | |
+ Braintree\Customer::updateCustomerUrl(), | |
$regularParams, | |
$trData | |
); | |
Index: braintree_sdk/tests/integration/DisbursementTest.php | |
=================================================================== | |
--- braintree_sdk/tests/integration/DisbursementTest.php (revision 1387260) | |
+++ braintree_sdk/tests/integration/DisbursementTest.php (working copy) | |
@@ -1,28 +1,34 @@ | |
<?php | |
-require_once realpath(dirname(__FILE__)) . '/../TestHelper.php'; | |
+namespace Test\Integration; | |
-class Braintree_DisbursementTest extends PHPUnit_Framework_TestCase | |
+require_once dirname(__DIR__) . '/Setup.php'; | |
+ | |
+use DateTime; | |
+use Test\Setup; | |
+use Braintree; | |
+ | |
+class DisbursementTest extends Setup | |
{ | |
- function testTransactions() | |
+ public function testTransactions() | |
{ | |
- $disbursement = Braintree_Disbursement::factory(array( | |
+ $disbursement = Braintree\Disbursement::factory([ | |
"id" => "123456", | |
- "merchantAccount" => array( | |
+ "merchantAccount" => [ | |
"id" => "sandbox_sub_merchant_account", | |
- "masterMerchantAccount" => array( | |
+ "masterMerchantAccount" => [ | |
"id" => "sandbox_master_merchant_account", | |
"status" => "active" | |
- ), | |
+ ], | |
"status" => "active" | |
- ), | |
- "transactionIds" => array("sub_merchant_transaction"), | |
+ ], | |
+ "transactionIds" => ["sub_merchant_transaction"], | |
"exceptionMessage" => "invalid_account_number", | |
"amount" => "100.00", | |
"disbursementDate" => new DateTime("2013-04-10"), | |
"followUpAction" => "update", | |
"retry" => false, | |
"success" => false | |
- )); | |
+ ]); | |
$transactions = $disbursement->transactions(); | |
Index: braintree_sdk/tests/integration/DiscountTest.php | |
=================================================================== | |
--- braintree_sdk/tests/integration/DiscountTest.php (revision 1387260) | |
+++ braintree_sdk/tests/integration/DiscountTest.php (working copy) | |
@@ -1,13 +1,18 @@ | |
<?php | |
-require_once realpath(dirname(__FILE__)) . '/../TestHelper.php'; | |
+namespace Test\Integration; | |
-class Braintree_DiscountTest extends PHPUnit_Framework_TestCase | |
+require_once dirname(__DIR__) . '/Setup.php'; | |
+ | |
+use Test\Setup; | |
+use Braintree; | |
+ | |
+class DiscountTest extends Setup | |
{ | |
- function testAll_returnsAllDiscounts() | |
+ public function testAll_returnsAllDiscounts() | |
{ | |
$newId = strval(rand()); | |
- $discountParams = array ( | |
+ $discountParams = [ | |
"amount" => "100.00", | |
"description" => "some description", | |
"id" => $newId, | |
@@ -15,13 +20,13 @@ | |
"name" => "php_discount", | |
"neverExpires" => "false", | |
"numberOfBillingCycles" => "1" | |
- ); | |
+ ]; | |
- $http = new Braintree_Http(Braintree_Configuration::$global); | |
- $path = Braintree_Configuration::$global->merchantPath() . "/modifications/create_modification_for_tests"; | |
- $http->post($path, array("modification" => $discountParams)); | |
+ $http = new Braintree\Http(Braintree\Configuration::$global); | |
+ $path = Braintree\Configuration::$global->merchantPath() . "/modifications/create_modification_for_tests"; | |
+ $http->post($path, ["modification" => $discountParams]); | |
- $discounts = Braintree_Discount::all(); | |
+ $discounts = Braintree\Discount::all(); | |
foreach ($discounts as $discount) | |
{ | |
@@ -41,11 +46,11 @@ | |
$this->assertEquals($discountParams["numberOfBillingCycles"], $actualDiscount->numberOfBillingCycles); | |
} | |
- function testGatewayAll_returnsAllDiscounts() | |
+ public function testGatewayAll_returnsAllDiscounts() | |
{ | |
$newId = strval(rand()); | |
- $discountParams = array ( | |
+ $discountParams = [ | |
"amount" => "100.00", | |
"description" => "some description", | |
"id" => $newId, | |
@@ -53,18 +58,18 @@ | |
"name" => "php_discount", | |
"neverExpires" => "false", | |
"numberOfBillingCycles" => "1" | |
- ); | |
+ ]; | |
- $http = new Braintree_Http(Braintree_Configuration::$global); | |
- $path = Braintree_Configuration::$global->merchantPath() . "/modifications/create_modification_for_tests"; | |
- $http->post($path, array("modification" => $discountParams)); | |
+ $http = new Braintree\Http(Braintree\Configuration::$global); | |
+ $path = Braintree\Configuration::$global->merchantPath() . "/modifications/create_modification_for_tests"; | |
+ $http->post($path, ["modification" => $discountParams]); | |
- $gateway = new Braintree_Gateway(array( | |
+ $gateway = new Braintree\Gateway([ | |
'environment' => 'development', | |
'merchantId' => 'integration_merchant_id', | |
'publicKey' => 'integration_public_key', | |
'privateKey' => 'integration_private_key' | |
- )); | |
+ ]); | |
$discounts = $gateway->discount()->all(); | |
foreach ($discounts as $discount) | |
Index: braintree_sdk/tests/integration/Error/ErrorCollectionTest.php | |
=================================================================== | |
--- braintree_sdk/tests/integration/Error/ErrorCollectionTest.php (revision 1387260) | |
+++ braintree_sdk/tests/integration/Error/ErrorCollectionTest.php (working copy) | |
@@ -1,75 +1,80 @@ | |
<?php | |
-require_once realpath(dirname(__FILE__)) . '/../../TestHelper.php'; | |
+namespace Test\Integration\Error; | |
-class Braintree_Error_ErrorCollectionTest extends PHPUnit_Framework_TestCase | |
+require_once dirname(dirname(__DIR__)) . '/Setup.php'; | |
+ | |
+use Test\Setup; | |
+use Braintree; | |
+ | |
+class ErrorCollectionTest extends Setup | |
{ | |
- function testDeepSize_withNestedErrors() | |
+ public function testDeepSize_withNestedErrors() | |
{ | |
- $result = Braintree_Customer::create(array( | |
+ $result = Braintree\Customer::create([ | |
'email' => 'invalid', | |
- 'creditCard' => array( | |
+ 'creditCard' => [ | |
'number' => 'invalid', | |
'expirationDate' => 'invalid', | |
- 'billingAddress' => array( | |
+ 'billingAddress' => [ | |
'countryName' => 'invaild' | |
- ) | |
- ) | |
- )); | |
+ ] | |
+ ] | |
+ ]); | |
$this->assertEquals(false, $result->success); | |
$this->assertEquals(4, $result->errors->deepSize()); | |
} | |
- function testOnHtmlField() | |
+ public function testOnHtmlField() | |
{ | |
- $result = Braintree_Customer::create(array( | |
+ $result = Braintree\Customer::create([ | |
'email' => 'invalid', | |
- 'creditCard' => array( | |
+ 'creditCard' => [ | |
'number' => 'invalid', | |
'expirationDate' => 'invalid', | |
- 'billingAddress' => array( | |
+ 'billingAddress' => [ | |
'countryName' => 'invaild' | |
- ) | |
- ) | |
- )); | |
+ ] | |
+ ] | |
+ ]); | |
$this->assertEquals(false, $result->success); | |
$errors = $result->errors->onHtmlField('customer[email]'); | |
- $this->assertEquals(Braintree_Error_Codes::CUSTOMER_EMAIL_IS_INVALID, $errors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::CUSTOMER_EMAIL_IS_INVALID, $errors[0]->code); | |
$errors = $result->errors->onHtmlField('customer[credit_card][number]'); | |
- $this->assertEquals(Braintree_Error_Codes::CREDIT_CARD_NUMBER_INVALID_LENGTH, $errors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::CREDIT_CARD_NUMBER_INVALID_LENGTH, $errors[0]->code); | |
$errors = $result->errors->onHtmlField('customer[credit_card][billing_address][country_name]'); | |
- $this->assertEquals(Braintree_Error_Codes::ADDRESS_COUNTRY_NAME_IS_NOT_ACCEPTED, $errors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::ADDRESS_COUNTRY_NAME_IS_NOT_ACCEPTED, $errors[0]->code); | |
} | |
- function testOnHtmlField_returnsEmptyArrayIfNone() | |
+ public function testOnHtmlField_returnsEmptyArrayIfNone() | |
{ | |
- $result = Braintree_Customer::create(array( | |
+ $result = Braintree\Customer::create([ | |
'email' => 'invalid', | |
- 'creditCard' => array( | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12', | |
- 'billingAddress' => array( | |
+ 'billingAddress' => [ | |
'streetAddress' => '1 E Main St' | |
- ) | |
- ) | |
- )); | |
+ ] | |
+ ] | |
+ ]); | |
$this->assertEquals(false, $result->success); | |
$errors = $result->errors->onHtmlField('customer[email]'); | |
- $this->assertEquals(Braintree_Error_Codes::CUSTOMER_EMAIL_IS_INVALID, $errors[0]->code); | |
- $this->assertEquals(array(), $result->errors->onHtmlField('customer[credit_card][number]')); | |
- $this->assertEquals(array(), $result->errors->onHtmlField('customer[credit_card][billing_address][country_name]')); | |
+ $this->assertEquals(Braintree\Error\Codes::CUSTOMER_EMAIL_IS_INVALID, $errors[0]->code); | |
+ $this->assertEquals([], $result->errors->onHtmlField('customer[credit_card][number]')); | |
+ $this->assertEquals([], $result->errors->onHtmlField('customer[credit_card][billing_address][country_name]')); | |
} | |
- function testOnHtmlField_returnsEmptyForCustomFieldsIfNoErrors() | |
+ public function testOnHtmlField_returnsEmptyForCustomFieldsIfNoErrors() | |
{ | |
- $result = Braintree_Customer::create(array( | |
+ $result = Braintree\Customer::create([ | |
'email' => 'invalid', | |
- 'creditCard' => array( | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12', | |
- ), | |
- 'customFields' => array('storeMe' => 'value') | |
- )); | |
+ ], | |
+ 'customFields' => ['storeMe' => 'value'] | |
+ ]); | |
$this->assertEquals(false, $result->success); | |
- $this->assertEquals(array(), $result->errors->onHtmlField('customer[custom_fields][store_me]')); | |
+ $this->assertEquals([], $result->errors->onHtmlField('customer[custom_fields][store_me]')); | |
} | |
} | |
Index: braintree_sdk/tests/integration/Error/ValidationErrorCollectionTest.php | |
=================================================================== | |
--- braintree_sdk/tests/integration/Error/ValidationErrorCollectionTest.php (revision 1387260) | |
+++ braintree_sdk/tests/integration/Error/ValidationErrorCollectionTest.php (working copy) | |
@@ -1,70 +1,74 @@ | |
<?php | |
-require_once realpath(dirname(__FILE__)) . '/../../TestHelper.php'; | |
+namespace Test\Integration\Error; | |
-class Braintree_Error_ValidationErrorCollectionTest extends PHPUnit_Framework_TestCase | |
+require_once dirname(dirname(__DIR__)) . '/Setup.php'; | |
+ | |
+use Test\Setup; | |
+use Braintree; | |
+ | |
+class ValidationErrorCollectionTest extends Setup | |
{ | |
- | |
- function mapValidationErrorsToCodes($validationErrors) | |
+ public function mapValidationErrorsToCodes($validationErrors) | |
{ | |
$codes = array_map(create_function('$validationError', 'return $validationError->code;'), $validationErrors); | |
sort($codes); | |
return $codes; | |
} | |
- function test_shallowAll_givesAllErrorsShallowly() | |
+ public function test_shallowAll_givesAllErrorsShallowly() | |
{ | |
- $result = Braintree_Customer::create(array( | |
+ $result = Braintree\Customer::create([ | |
'email' => 'invalid', | |
- 'creditCard' => array( | |
+ 'creditCard' => [ | |
'number' => '1234123412341234', | |
'expirationDate' => 'invalid', | |
- 'billingAddress' => array( | |
+ 'billingAddress' => [ | |
'countryName' => 'invalid' | |
- ) | |
- ) | |
- )); | |
+ ] | |
+ ] | |
+ ]); | |
- $this->assertEquals(array(), $result->errors->shallowAll()); | |
+ $this->assertEquals([], $result->errors->shallowAll()); | |
- $expectedCustomerErrors = array(Braintree_Error_Codes::CUSTOMER_EMAIL_IS_INVALID); | |
+ $expectedCustomerErrors = [Braintree\Error\Codes::CUSTOMER_EMAIL_IS_INVALID]; | |
$actualCustomerErrors = $result->errors->forKey('customer')->shallowAll(); | |
$this->assertEquals($expectedCustomerErrors, self::mapValidationErrorsToCodes($actualCustomerErrors)); | |
- $expectedCreditCardErrors = array( | |
- Braintree_Error_Codes::CREDIT_CARD_EXPIRATION_DATE_IS_INVALID, | |
- Braintree_Error_Codes::CREDIT_CARD_NUMBER_IS_INVALID | |
- ); | |
+ $expectedCreditCardErrors = [ | |
+ Braintree\Error\Codes::CREDIT_CARD_EXPIRATION_DATE_IS_INVALID, | |
+ Braintree\Error\Codes::CREDIT_CARD_NUMBER_IS_INVALID, | |
+ ]; | |
$actualCreditCardErrors = $result->errors->forKey('customer')->forKey('creditCard')->shallowAll(); | |
$this->assertEquals($expectedCreditCardErrors, self::mapValidationErrorsToCodes($actualCreditCardErrors)); | |
} | |
- function test_deepAll_givesAllErrorsDeeply() | |
+ public function test_deepAll_givesAllErrorsDeeply() | |
{ | |
- $result = Braintree_Customer::create(array( | |
+ $result = Braintree\Customer::create([ | |
'email' => 'invalid', | |
- 'creditCard' => array( | |
+ 'creditCard' => [ | |
'number' => '1234123412341234', | |
'expirationDate' => 'invalid', | |
- 'billingAddress' => array( | |
+ 'billingAddress' => [ | |
'countryName' => 'invalid' | |
- ) | |
- ) | |
- )); | |
+ ] | |
+ ] | |
+ ]); | |
- $expectedErrors = array( | |
- Braintree_Error_Codes::CUSTOMER_EMAIL_IS_INVALID, | |
- Braintree_Error_Codes::CREDIT_CARD_EXPIRATION_DATE_IS_INVALID, | |
- Braintree_Error_Codes::CREDIT_CARD_NUMBER_IS_INVALID, | |
- Braintree_Error_Codes::ADDRESS_COUNTRY_NAME_IS_NOT_ACCEPTED | |
- ); | |
+ $expectedErrors = [ | |
+ Braintree\Error\Codes::CUSTOMER_EMAIL_IS_INVALID, | |
+ Braintree\Error\Codes::CREDIT_CARD_EXPIRATION_DATE_IS_INVALID, | |
+ Braintree\Error\Codes::CREDIT_CARD_NUMBER_IS_INVALID, | |
+ Braintree\Error\Codes::ADDRESS_COUNTRY_NAME_IS_NOT_ACCEPTED, | |
+ ]; | |
$actualErrors = $result->errors->deepAll(); | |
$this->assertEquals($expectedErrors, self::mapValidationErrorsToCodes($actualErrors)); | |
- $expectedErrors = array( | |
- Braintree_Error_Codes::CREDIT_CARD_EXPIRATION_DATE_IS_INVALID, | |
- Braintree_Error_Codes::CREDIT_CARD_NUMBER_IS_INVALID, | |
- Braintree_Error_Codes::ADDRESS_COUNTRY_NAME_IS_NOT_ACCEPTED | |
- ); | |
+ $expectedErrors = [ | |
+ Braintree\Error\Codes::CREDIT_CARD_EXPIRATION_DATE_IS_INVALID, | |
+ Braintree\Error\Codes::CREDIT_CARD_NUMBER_IS_INVALID, | |
+ Braintree\Error\Codes::ADDRESS_COUNTRY_NAME_IS_NOT_ACCEPTED, | |
+ ]; | |
$actualErrors = $result->errors->forKey('customer')->forKey('creditCard')->deepAll(); | |
$this->assertEquals($expectedErrors, self::mapValidationErrorsToCodes($actualErrors)); | |
} | |
Index: braintree_sdk/tests/integration/EuropeBankAccountTest.php | |
=================================================================== | |
--- braintree_sdk/tests/integration/EuropeBankAccountTest.php (revision 1387260) | |
+++ braintree_sdk/tests/integration/EuropeBankAccountTest.php (working copy) | |
@@ -1,31 +1,34 @@ | |
<?php | |
-require_once realpath(dirname(__FILE__)) . '/../TestHelper.php'; | |
-require_once realpath(dirname(__FILE__)) . '/HttpClientApi.php'; | |
+namespace Test\Integration; | |
-class Braintree_EuropeBankAccountTest extends PHPUnit_Framework_TestCase | |
+require_once dirname(__DIR__) . '/Setup.php'; | |
+ | |
+use Test\Setup; | |
+use Braintree; | |
+ | |
+class EuropeBankAccountTest extends Setup | |
{ | |
- | |
- function testCanExchangeNonceForEuropeBankAccount() | |
+ public function testCanExchangeNonceForEuropeBankAccount() | |
{ | |
- $gateway = new Braintree_Gateway(array( | |
+ $gateway = new Braintree\Gateway([ | |
'environment' => 'development', | |
'merchantId' => 'altpay_merchant', | |
'publicKey' => 'altpay_merchant_public_key', | |
'privateKey' => 'altpay_merchant_private_key' | |
- )); | |
+ ]); | |
$result = $gateway->customer()->create(); | |
$this->assertTrue($result->success); | |
$customer = $result->customer; | |
- $clientApi = new Braintree_HttpClientApi($gateway->config); | |
- $nonce = $clientApi->nonceForNewEuropeanBankAccount(array( | |
+ $clientApi = new HttpClientApi($gateway->config); | |
+ $nonce = $clientApi->nonceForNewEuropeanBankAccount([ | |
"customerId" => $customer->id, | |
- "sepa_mandate" => array( | |
+ "sepa_mandate" => [ | |
"locale" => "de-DE", | |
"bic" => "DEUTDEFF", | |
"iban" => "DE89370400440532013000", | |
"accountHolderName" => "Bob Holder", | |
- "billingAddress" => array( | |
+ "billingAddress" => [ | |
"streetAddress" => "123 Currywurst Way", | |
"extendedAddress" => "Lager Suite", | |
"firstName" => "Wilhelm", | |
@@ -34,13 +37,13 @@ | |
"postalCode" => "60001", | |
"countryCodeAlpha2" => "DE", | |
"region" => "Hesse" | |
- ) | |
- ) | |
- )); | |
- $result = $gateway->paymentMethod()->create(array( | |
+ ] | |
+ ] | |
+ ]); | |
+ $result = $gateway->paymentMethod()->create([ | |
"customerId" => $customer->id, | |
"paymentMethodNonce" => $nonce | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
$paymentMethod = $result->paymentMethod; | |
Index: braintree_sdk/tests/integration/HttpClientApi.php | |
=================================================================== | |
--- braintree_sdk/tests/integration/HttpClientApi.php (revision 1387260) | |
+++ braintree_sdk/tests/integration/HttpClientApi.php (working copy) | |
@@ -1,8 +1,13 @@ | |
<?php | |
+namespace Test\Integration; | |
-class Braintree_HttpClientApi extends Braintree_Http | |
+require_once dirname(__DIR__) . '/Setup.php'; | |
+ | |
+use Braintree; | |
+use Test; | |
+ | |
+class HttpClientApi extends Braintree\Http | |
{ | |
- | |
protected function _doRequest($httpVerb, $path, $requestBody = null) | |
{ | |
return $this->_doUrlRequest($httpVerb, $this->_config->baseUrl() . "/merchants/" . $this->_config->getMerchantId() . $path, $requestBody); | |
@@ -24,10 +29,10 @@ | |
curl_setopt($curl, CURLOPT_TIMEOUT, 60); | |
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $httpVerb); | |
curl_setopt($curl, CURLOPT_URL, $url); | |
- curl_setopt($curl, CURLOPT_HTTPHEADER, array( | |
+ curl_setopt($curl, CURLOPT_HTTPHEADER, [ | |
'Content-Type: application/json', | |
- 'X-ApiVersion: ' . Braintree_Configuration::API_VERSION | |
- )); | |
+ 'X-ApiVersion: ' . Braintree\Configuration::API_VERSION, | |
+ ]); | |
curl_setopt($curl, CURLOPT_USERPWD, $this->_config->publicKey() . ':' . $this->_config->privateKey()); | |
if(!empty($requestBody)) { | |
@@ -38,7 +43,7 @@ | |
$response = curl_exec($curl); | |
$httpStatus = curl_getinfo($curl, CURLINFO_HTTP_CODE); | |
curl_close($curl); | |
- return array('status' => $httpStatus, 'body' => $response); | |
+ return ['status' => $httpStatus, 'body' => $response]; | |
} | |
public function get_cards($options) { | |
@@ -52,13 +57,13 @@ | |
} | |
public function nonce_for_new_card($options) { | |
- $clientTokenOptions = array(); | |
+ $clientTokenOptions = []; | |
if (array_key_exists("customerId", $options)) { | |
$clientTokenOptions["customerId"] = $options["customerId"]; | |
unset($options["customerId"]); | |
} | |
- $clientToken = json_decode(Braintree_TestHelper::decodedClientToken($clientTokenOptions)); | |
+ $clientToken = json_decode(Test\Helper::decodedClientToken($clientTokenOptions)); | |
$options["authorization_fingerprint"] = $clientToken->authorizationFingerprint; | |
$options["shared_customer_identifier"] = "fake_identifier_" . rand(); | |
@@ -73,17 +78,17 @@ | |
} | |
public function nonceForNewEuropeanBankAccount($options) { | |
- $clientTokenOptions = array( | |
+ $clientTokenOptions = [ | |
'sepaMandateType' => 'business', | |
'sepaMandateAcceptanceLocation' => 'Rostock, Germany' | |
- ); | |
+ ]; | |
if (array_key_exists("customerId", $options)) { | |
$clientTokenOptions["customerId"] = $options["customerId"]; | |
unset($options["customerId"]); | |
} | |
- $gateway = new Braintree_Gateway($this->_config); | |
+ $gateway = new Braintree\Gateway($this->_config); | |
$clientToken = json_decode(base64_decode($gateway->clientToken()->generate($clientTokenOptions))); | |
$options["authorization_fingerprint"] = $clientToken->authorizationFingerprint; | |
@@ -98,7 +103,7 @@ | |
} | |
public function nonceForPayPalAccount($options) { | |
- $clientToken = json_decode(Braintree_TestHelper::decodedClientToken()); | |
+ $clientToken = json_decode(Test\Helper::decodedClientToken()); | |
$options["authorization_fingerprint"] = $clientToken->authorizationFingerprint; | |
$response = $this->post('/client_api/v1/payment_methods/paypal_accounts.json', json_encode($options)); | |
if ($response["status"] == 201 || $response["status"] == 202) { | |
Index: braintree_sdk/tests/integration/HttpTest.php | |
=================================================================== | |
--- braintree_sdk/tests/integration/HttpTest.php (revision 1387260) | |
+++ braintree_sdk/tests/integration/HttpTest.php (working copy) | |
@@ -1,61 +1,66 @@ | |
<?php | |
-require_once realpath(dirname(__FILE__)) . '/../TestHelper.php'; | |
+namespace Test\Integration; | |
-class Braintree_HttpTest extends PHPUnit_Framework_TestCase | |
+require_once dirname(__DIR__) . '/Setup.php'; | |
+ | |
+use Test\Setup; | |
+use Braintree; | |
+ | |
+class HttpTest extends Setup | |
{ | |
- function testProductionSSL() | |
+ public function testProductionSSL() | |
{ | |
try { | |
- Braintree_Configuration::environment('production'); | |
- $this->setExpectedException('Braintree_Exception_Authentication'); | |
- $http = new Braintree_Http(Braintree_Configuration::$global); | |
+ Braintree\Configuration::environment('production'); | |
+ $this->setExpectedException('Braintree\Exception\Authentication'); | |
+ $http = new Braintree\Http(Braintree\Configuration::$global); | |
$http->get('/'); | |
- } catch (Exception $e) { | |
- Braintree_Configuration::environment('development'); | |
+ } catch (Braintree\Exception $e) { | |
+ Braintree\Configuration::environment('development'); | |
throw $e; | |
} | |
- Braintree_Configuration::environment('development'); | |
+ Braintree\Configuration::environment('development'); | |
} | |
- function testSandboxSSL() | |
+ public function testSandboxSSL() | |
{ | |
try { | |
- Braintree_Configuration::environment('sandbox'); | |
- $this->setExpectedException('Braintree_Exception_Authentication'); | |
- $http = new Braintree_Http(Braintree_Configuration::$global); | |
+ Braintree\Configuration::environment('sandbox'); | |
+ $this->setExpectedException('Braintree\Exception\Authentication'); | |
+ $http = new Braintree\Http(Braintree\Configuration::$global); | |
$http->get('/'); | |
- } catch (Exception $e) { | |
- Braintree_Configuration::environment('development'); | |
+ } catch (Braintree\Exception $e) { | |
+ Braintree\Configuration::environment('development'); | |
throw $e; | |
} | |
- Braintree_Configuration::environment('development'); | |
+ Braintree\Configuration::environment('development'); | |
} | |
- function testSslError() | |
+ public function testSslError() | |
{ | |
try { | |
- Braintree_Configuration::environment('sandbox'); | |
- $this->setExpectedException('Braintree_Exception_SSLCertificate'); | |
- $http = new Braintree_Http(Braintree_Configuration::$global); | |
+ Braintree\Configuration::environment('sandbox'); | |
+ $this->setExpectedException('Braintree\Exception\SSLCertificate'); | |
+ $http = new Braintree\Http(Braintree\Configuration::$global); | |
//ip address of api.braintreegateway.com | |
$http->_doUrlRequest('get', '204.109.13.121'); | |
- } catch (Exception $e) { | |
- Braintree_Configuration::environment('development'); | |
+ } catch (Braintree\Exception $e) { | |
+ Braintree\Configuration::environment('development'); | |
throw $e; | |
} | |
- Braintree_Configuration::environment('development'); | |
+ Braintree\Configuration::environment('development'); | |
} | |
- function testAuthorizationWithConfig() | |
+ public function testAuthorizationWithConfig() | |
{ | |
- $config = new Braintree_Configuration(array( | |
+ $config = new Braintree\Configuration([ | |
'environment' => 'development', | |
'merchant_id' => 'integration_merchant_id', | |
'publicKey' => 'badPublicKey', | |
'privateKey' => 'badPrivateKey' | |
- )); | |
+ ]); | |
- $http = new Braintree_Http($config); | |
+ $http = new Braintree\Http($config); | |
$result = $http->_doUrlRequest('GET', $config->baseUrl() . '/merchants/integration_merchant_id/customers'); | |
$this->assertEquals(401, $result['status']); | |
} | |
Index: braintree_sdk/tests/integration/MerchantAccountTest.php | |
=================================================================== | |
--- braintree_sdk/tests/integration/MerchantAccountTest.php (revision 1387260) | |
+++ braintree_sdk/tests/integration/MerchantAccountTest.php (working copy) | |
@@ -1,162 +1,174 @@ | |
<?php | |
-require_once realpath(dirname(__FILE__)) . '/../TestHelper.php'; | |
+namespace Test\Integration; | |
-class Braintree_MerchantAccountTest extends PHPUnit_Framework_TestCase | |
+require_once dirname(__DIR__) . '/Setup.php'; | |
+ | |
+use Test; | |
+use Test\Setup; | |
+use Braintree; | |
+ | |
+class MerchantAccountTest extends Setup | |
{ | |
- | |
- private static $deprecatedValidParams = array( | |
- 'applicantDetails' => array( | |
+ private static $deprecatedValidParams = [ | |
+ 'applicantDetails' => [ | |
'companyName' => "Robot City", | |
'firstName' => "Joe", | |
'lastName' => "Bloggs", | |
'email' => "[email protected]", | |
'phone' => "555-555-5555", | |
- 'address' => array( | |
+ 'address' => [ | |
'streetAddress' => "123 Credibility St.", | |
'postalCode' => "60606", | |
'locality' => "Chicago", | |
'region' => "IL", | |
- ), | |
+ ], | |
'dateOfBirth' => "10/9/1980", | |
'ssn' => "123-00-1234", | |
'taxId' => "123456789", | |
'routingNumber' => "122100024", | |
'accountNumber' => "43759348798" | |
- ), | |
+ ], | |
'tosAccepted' => true, | |
'masterMerchantAccountId' => "sandbox_master_merchant_account" | |
- ); | |
+ ]; | |
- private static $validParams = array( | |
- 'individual' => array( | |
+ private static $validParams = [ | |
+ 'individual' => [ | |
'firstName' => "Joe", | |
'lastName' => "Bloggs", | |
'email' => "[email protected]", | |
'phone' => "555-555-5555", | |
- 'address' => array( | |
+ 'address' => [ | |
'streetAddress' => "123 Credibility St.", | |
'postalCode' => "60606", | |
'locality' => "Chicago", | |
'region' => "IL", | |
- ), | |
+ ], | |
'dateOfBirth' => "10/9/1980", | |
'ssn' => "123-00-1234", | |
- ), | |
- 'business' => array( | |
+ ], | |
+ 'business' => [ | |
'dbaName' => "Robot City", | |
'legalName' => "Robot City INC", | |
'taxId' => "123456789", | |
- ), | |
- 'funding' => array( | |
+ ], | |
+ 'funding' => [ | |
'routingNumber' => "122100024", | |
'accountNumber' => "43759348798", | |
- 'destination' => Braintree_MerchantAccount::FUNDING_DESTINATION_BANK, | |
+ 'destination' => Braintree\MerchantAccount::FUNDING_DESTINATION_BANK, | |
'descriptor' => 'Joes Bloggs MI', | |
- ), | |
+ ], | |
'tosAccepted' => true, | |
'masterMerchantAccountId' => "sandbox_master_merchant_account" | |
- ); | |
+ ]; | |
- function testCreate() | |
+ public function testCreate() | |
{ | |
- $result = Braintree_MerchantAccount::create(self::$validParams); | |
+ $result = Braintree\MerchantAccount::create(self::$validParams); | |
$this->assertEquals(true, $result->success); | |
$merchantAccount = $result->merchantAccount; | |
- $this->assertEquals(Braintree_MerchantAccount::STATUS_PENDING, $merchantAccount->status); | |
+ $this->assertEquals(Braintree\MerchantAccount::STATUS_PENDING, $merchantAccount->status); | |
$this->assertEquals("sandbox_master_merchant_account", $merchantAccount->masterMerchantAccount->id); | |
} | |
- function testGatewayCreate() | |
+ public function testGatewayCreate() | |
{ | |
- $gateway = new Braintree_Gateway(array( | |
+ $gateway = new Braintree\Gateway([ | |
'environment' => 'development', | |
'merchantId' => 'integration_merchant_id', | |
'publicKey' => 'integration_public_key', | |
'privateKey' => 'integration_private_key' | |
- )); | |
+ ]); | |
$result = $gateway->merchantAccount()->create(self::$validParams); | |
$this->assertEquals(true, $result->success); | |
$merchantAccount = $result->merchantAccount; | |
- $this->assertEquals(Braintree_MerchantAccount::STATUS_PENDING, $merchantAccount->status); | |
+ $this->assertEquals(Braintree\MerchantAccount::STATUS_PENDING, $merchantAccount->status); | |
$this->assertEquals("sandbox_master_merchant_account", $merchantAccount->masterMerchantAccount->id); | |
} | |
- function testCreateWithDeprecatedParameters() | |
+ public function testCreateWithDeprecatedParameters() | |
{ | |
- Braintree_TestHelper::suppressDeprecationWarnings(); | |
- $result = Braintree_MerchantAccount::create(self::$deprecatedValidParams); | |
+ Test\Helper::suppressDeprecationWarnings(); | |
+ $result = Braintree\MerchantAccount::create(self::$deprecatedValidParams); | |
$this->assertEquals(true, $result->success); | |
$merchantAccount = $result->merchantAccount; | |
- $this->assertEquals(Braintree_MerchantAccount::STATUS_PENDING, $merchantAccount->status); | |
+ $this->assertEquals(Braintree\MerchantAccount::STATUS_PENDING, $merchantAccount->status); | |
$this->assertEquals("sandbox_master_merchant_account", $merchantAccount->masterMerchantAccount->id); | |
} | |
- function testCreateWithId() | |
+ public function testCreateWithId() | |
{ | |
$rand = rand(1, 1000); | |
$subMerchantAccountId = "sub_merchant_account_id" + $rand; | |
- $validParamsWithId = array_merge(array(), self::$validParams); | |
+ $validParamsWithId = array_merge([], self::$validParams); | |
$validParamsWithId['id'] = $subMerchantAccountId; | |
- $result = Braintree_MerchantAccount::create($validParamsWithId); | |
+ $result = Braintree\MerchantAccount::create($validParamsWithId); | |
$this->assertEquals(true, $result->success); | |
$merchantAccount = $result->merchantAccount; | |
- $this->assertEquals(Braintree_MerchantAccount::STATUS_PENDING, $merchantAccount->status); | |
+ $this->assertEquals(Braintree\MerchantAccount::STATUS_PENDING, $merchantAccount->status); | |
$this->assertEquals("sandbox_master_merchant_account", $merchantAccount->masterMerchantAccount->id); | |
$this->assertEquals("sub_merchant_account_id" + $rand, $merchantAccount->id); | |
} | |
- function testFailedCreate() | |
+ public function testFailedCreate() | |
{ | |
- $result = Braintree_MerchantAccount::create(array()); | |
+ $result = Braintree\MerchantAccount::create([]); | |
$this->assertEquals(false, $result->success); | |
$errors = $result->errors->forKey('merchantAccount')->onAttribute('masterMerchantAccountId'); | |
- $this->assertEquals(Braintree_Error_Codes::MERCHANT_ACCOUNT_MASTER_MERCHANT_ACCOUNT_ID_IS_REQUIRED, $errors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::MERCHANT_ACCOUNT_MASTER_MERCHANT_ACCOUNT_ID_IS_REQUIRED, $errors[0]->code); | |
} | |
- function testCreateWithFundingDestination() | |
+ public function testCreateWithFundingDestination() | |
{ | |
- $params = array_merge(array(), self::$validParams); | |
- $params['funding']['destination'] = Braintree_MerchantAccount::FUNDING_DESTINATION_BANK; | |
- $result = Braintree_MerchantAccount::create($params); | |
+ $params = array_merge([], self::$validParams); | |
+ $params['funding']['destination'] = Braintree\MerchantAccount::FUNDING_DESTINATION_BANK; | |
+ $result = Braintree\MerchantAccount::create($params); | |
$this->assertEquals(true, $result->success); | |
- $params = array_merge(array(), self::$validParams); | |
- $params['funding']['destination'] = Braintree_MerchantAccount::FUNDING_DESTINATION_EMAIL; | |
+ $params = array_merge([], self::$validParams); | |
+ $params['funding']['destination'] = Braintree\MerchantAccount::FUNDING_DESTINATION_EMAIL; | |
$params['funding']['email'] = "[email protected]"; | |
- $result = Braintree_MerchantAccount::create($params); | |
+ $result = Braintree\MerchantAccount::create($params); | |
$this->assertEquals(true, $result->success); | |
- $params = array_merge(array(), self::$validParams); | |
- $params['funding']['destination'] = Braintree_MerchantAccount::FUNDING_DESTINATION_MOBILE_PHONE; | |
+ $params = array_merge([], self::$validParams); | |
+ $params['funding']['destination'] = Braintree\MerchantAccount::FUNDING_DESTINATION_MOBILE_PHONE; | |
$params['funding']['mobilePhone'] = "1112224444"; | |
- $result = Braintree_MerchantAccount::create($params); | |
+ $result = Braintree\MerchantAccount::create($params); | |
$this->assertEquals(true, $result->success); | |
} | |
- function testFind() | |
+ public function testFind() | |
{ | |
- $params = array_merge(array(), self::$validParams); | |
- $result = Braintree_MerchantAccount::create(self::$validParams); | |
+ $params = array_merge([], self::$validParams); | |
+ $result = Braintree\MerchantAccount::create(self::$validParams); | |
$this->assertEquals(true, $result->success); | |
- $this->assertEquals(Braintree_MerchantAccount::STATUS_PENDING, $result->merchantAccount->status); | |
+ $this->assertEquals(Braintree\MerchantAccount::STATUS_PENDING, $result->merchantAccount->status); | |
$id = $result->merchantAccount->id; | |
- $merchantAccount = Braintree_MerchantAccount::find($id); | |
+ $merchantAccount = Braintree\MerchantAccount::find($id); | |
- $this->assertEquals(Braintree_MerchantAccount::STATUS_ACTIVE, $merchantAccount->status); | |
+ $this->assertEquals(Braintree\MerchantAccount::STATUS_ACTIVE, $merchantAccount->status); | |
$this->assertEquals($params['individual']['firstName'], $merchantAccount->individualDetails->firstName); | |
$this->assertEquals($params['individual']['lastName'], $merchantAccount->individualDetails->lastName); | |
} | |
- function testFind_throwsIfNotFound() | |
+ public function testRetrievesMasterMerchantAccountCurrencyIsoCode() | |
{ | |
- $this->setExpectedException('Braintree_Exception_NotFound', 'merchant account with id does-not-exist not found'); | |
- Braintree_MerchantAccount::find('does-not-exist'); | |
+ $merchantAccount = Braintree\MerchantAccount::find("sandbox_master_merchant_account"); | |
+ | |
+ $this->assertEquals("USD", $merchantAccount->currencyIsoCode); | |
} | |
- function testUpdate() | |
+ public function testFind_throwsIfNotFound() | |
{ | |
- $params = array_merge(array(), self::$validParams); | |
+ $this->setExpectedException('Braintree\Exception\NotFound', 'merchant account with id does-not-exist not found'); | |
+ Braintree\MerchantAccount::find('does-not-exist'); | |
+ } | |
+ | |
+ public function testUpdate() | |
+ { | |
+ $params = array_merge([], self::$validParams); | |
unset($params["tosAccepted"]); | |
unset($params["masterMerchantAccountId"]); | |
$params["individual"]["firstName"] = "John"; | |
@@ -179,10 +191,10 @@ | |
$params["funding"]["routingNumber"] = "071000013"; | |
$params["funding"]["email"] = "[email protected]"; | |
$params["funding"]["mobilePhone"] = "1234567890"; | |
- $params["funding"]["destination"] = Braintree_MerchantAccount::FUNDING_DESTINATION_BANK; | |
+ $params["funding"]["destination"] = Braintree\MerchantAccount::FUNDING_DESTINATION_BANK; | |
$params["funding"]["descriptor"] = "Joes Bloggs FL"; | |
- $result = Braintree_MerchantAccount::update("sandbox_sub_merchant_account", $params); | |
+ $result = Braintree\MerchantAccount::update("sandbox_sub_merchant_account", $params); | |
$this->assertEquals(true, $result->success); | |
$updatedMerchantAccount = $result->merchantAccount; | |
@@ -209,211 +221,211 @@ | |
$this->assertEquals("071000013", $updatedMerchantAccount->fundingDetails->routingNumber); | |
$this->assertEquals("[email protected]", $updatedMerchantAccount->fundingDetails->email); | |
$this->assertEquals("1234567890", $updatedMerchantAccount->fundingDetails->mobilePhone); | |
- $this->assertEquals(Braintree_MerchantAccount::FUNDING_DESTINATION_BANK, $updatedMerchantAccount->fundingDetails->destination); | |
+ $this->assertEquals(Braintree\MerchantAccount::FUNDING_DESTINATION_BANK, $updatedMerchantAccount->fundingDetails->destination); | |
$this->assertEquals("Joes Bloggs FL", $updatedMerchantAccount->fundingDetails->descriptor); | |
} | |
- function testUpdateDoesNotRequireAllFields() | |
+ public function testUpdateDoesNotRequireAllFields() | |
{ | |
- $params = array( | |
- 'individual' => array( | |
+ $params = [ | |
+ 'individual' => [ | |
'firstName' => "Joe" | |
- ) | |
- ); | |
- $result = Braintree_MerchantAccount::update("sandbox_sub_merchant_account", $params); | |
+ ] | |
+ ]; | |
+ $result = Braintree\MerchantAccount::update("sandbox_sub_merchant_account", $params); | |
$this->assertEquals(true, $result->success); | |
} | |
- function testUpdateWithBlankFields() | |
+ public function testUpdateWithBlankFields() | |
{ | |
- $params = array( | |
- 'individual' => array( | |
+ $params = [ | |
+ 'individual' => [ | |
'firstName' => "", | |
'lastName' => "", | |
'email' => "", | |
'phone' => "", | |
- 'address' => array( | |
+ 'address' => [ | |
'streetAddress' => "", | |
'postalCode' => "", | |
'locality' => "", | |
'region' => "", | |
- ), | |
+ ], | |
'dateOfBirth' => "", | |
'ssn' => "", | |
- ), | |
- 'business' => array( | |
+ ], | |
+ 'business' => [ | |
'dbaName' => "", | |
'legalName' => "", | |
'taxId' => "", | |
- ), | |
- 'funding' => array( | |
+ ], | |
+ 'funding' => [ | |
'routingNumber' => "", | |
'accountNumber' => "", | |
'destination' => "", | |
- ), | |
- ); | |
+ ], | |
+ ]; | |
- $result = Braintree_MerchantAccount::update("sandbox_sub_merchant_account", $params); | |
+ $result = Braintree\MerchantAccount::update("sandbox_sub_merchant_account", $params); | |
$this->assertEquals(false, $result->success); | |
$error = $result->errors->forKey("merchantAccount")->forKey("individual")->onAttribute("firstName"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_INDIVIDUAL_FIRST_NAME_IS_REQUIRED); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_FIRST_NAME_IS_REQUIRED); | |
$error = $result->errors->forKey("merchantAccount")->forKey("individual")->onAttribute("lastName"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_INDIVIDUAL_LAST_NAME_IS_REQUIRED); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_LAST_NAME_IS_REQUIRED); | |
$error = $result->errors->forKey("merchantAccount")->forKey("individual")->onAttribute("dateOfBirth"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_INDIVIDUAL_DATE_OF_BIRTH_IS_REQUIRED); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_DATE_OF_BIRTH_IS_REQUIRED); | |
$error = $result->errors->forKey("merchantAccount")->forKey("individual")->onAttribute("email"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_INDIVIDUAL_EMAIL_IS_REQUIRED); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_EMAIL_IS_REQUIRED); | |
$error = $result->errors->forKey("merchantAccount")->forKey("individual")->forKey("address")->onAttribute("streetAddress"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_STREET_ADDRESS_IS_REQUIRED); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_STREET_ADDRESS_IS_REQUIRED); | |
$error = $result->errors->forKey("merchantAccount")->forKey("individual")->forKey("address")->onAttribute("postalCode"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_POSTAL_CODE_IS_REQUIRED); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_POSTAL_CODE_IS_REQUIRED); | |
$error = $result->errors->forKey("merchantAccount")->forKey("individual")->forKey("address")->onAttribute("locality"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_LOCALITY_IS_REQUIRED); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_LOCALITY_IS_REQUIRED); | |
$error = $result->errors->forKey("merchantAccount")->forKey("individual")->forKey("address")->onAttribute("region"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_REGION_IS_REQUIRED); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_REGION_IS_REQUIRED); | |
$error = $result->errors->forKey("merchantAccount")->forKey("funding")->onAttribute("destination"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_FUNDING_DESTINATION_IS_REQUIRED); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_FUNDING_DESTINATION_IS_REQUIRED); | |
} | |
- function testUpdateWithInvalidFields() | |
+ public function testUpdateWithInvalidFields() | |
{ | |
- $params = array( | |
- "individual" => array( | |
+ $params = [ | |
+ "individual" => [ | |
"firstName" => "<>", | |
"lastName" => "<>", | |
"email" => "bad", | |
"phone" => "999", | |
- "address" => array( | |
+ "address" => [ | |
"streetAddress" => "nope", | |
"postalCode" => "1", | |
"region" => "QQ", | |
- ), | |
+ ], | |
"dateOfBirth" => "hah", | |
"ssn" => "12345", | |
- ), | |
- "business" => array( | |
+ ], | |
+ "business" => [ | |
"legalName" => "``{}", | |
"dbaName" => "{}``", | |
"taxId" => "bad", | |
- "address" => array( | |
+ "address" => [ | |
"streetAddress" => "nope", | |
"postalCode" => "1", | |
"region" => "QQ", | |
- ), | |
- ), | |
- "funding" => array( | |
+ ], | |
+ ], | |
+ "funding" => [ | |
"destination" => "MY WALLET", | |
"routingNumber" => "LEATHER", | |
"accountNumber" => "BACK POCKET", | |
"email" => "BILLFOLD", | |
"mobilePhone" => "TRIFOLD" | |
- ), | |
- ); | |
+ ], | |
+ ]; | |
- $result = Braintree_MerchantAccount::update("sandbox_sub_merchant_account", $params); | |
+ $result = Braintree\MerchantAccount::update("sandbox_sub_merchant_account", $params); | |
$this->assertEquals(false, $result->success); | |
$error = $result->errors->forKey("merchantAccount")->forKey("individual")->onAttribute("firstName"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_INDIVIDUAL_FIRST_NAME_IS_INVALID); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_FIRST_NAME_IS_INVALID); | |
$error = $result->errors->forKey("merchantAccount")->forKey("individual")->onAttribute("lastName"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_INDIVIDUAL_LAST_NAME_IS_INVALID); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_LAST_NAME_IS_INVALID); | |
$error = $result->errors->forKey("merchantAccount")->forKey("individual")->onAttribute("email"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_INDIVIDUAL_EMAIL_IS_INVALID); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_EMAIL_IS_INVALID); | |
$error = $result->errors->forKey("merchantAccount")->forKey("individual")->onAttribute("phone"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_INDIVIDUAL_PHONE_IS_INVALID); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_PHONE_IS_INVALID); | |
$error = $result->errors->forKey("merchantAccount")->forKey("individual")->forKey("address")->onAttribute("streetAddress"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_STREET_ADDRESS_IS_INVALID); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_STREET_ADDRESS_IS_INVALID); | |
$error = $result->errors->forKey("merchantAccount")->forKey("individual")->forKey("address")->onAttribute("postalCode"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_POSTAL_CODE_IS_INVALID); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_POSTAL_CODE_IS_INVALID); | |
$error = $result->errors->forKey("merchantAccount")->forKey("individual")->forKey("address")->onAttribute("region"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_REGION_IS_INVALID); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_REGION_IS_INVALID); | |
$error = $result->errors->forKey("merchantAccount")->forKey("individual")->onAttribute("ssn"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_INDIVIDUAL_SSN_IS_INVALID); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_SSN_IS_INVALID); | |
; | |
$error = $result->errors->forKey("merchantAccount")->forKey("business")->onAttribute("legalName"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_BUSINESS_LEGAL_NAME_IS_INVALID); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_BUSINESS_LEGAL_NAME_IS_INVALID); | |
$error = $result->errors->forKey("merchantAccount")->forKey("business")->onAttribute("dbaName"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_BUSINESS_DBA_NAME_IS_INVALID); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_BUSINESS_DBA_NAME_IS_INVALID); | |
$error = $result->errors->forKey("merchantAccount")->forKey("business")->onAttribute("taxId"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_BUSINESS_TAX_ID_IS_INVALID); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_BUSINESS_TAX_ID_IS_INVALID); | |
$error = $result->errors->forKey("merchantAccount")->forKey("business")->forKey("address")->onAttribute("streetAddress"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_BUSINESS_ADDRESS_STREET_ADDRESS_IS_INVALID); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_BUSINESS_ADDRESS_STREET_ADDRESS_IS_INVALID); | |
$error = $result->errors->forKey("merchantAccount")->forKey("business")->forKey("address")->onAttribute("postalCode"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_BUSINESS_ADDRESS_POSTAL_CODE_IS_INVALID); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_BUSINESS_ADDRESS_POSTAL_CODE_IS_INVALID); | |
$error = $result->errors->forKey("merchantAccount")->forKey("business")->forKey("address")->onAttribute("region"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_BUSINESS_ADDRESS_REGION_IS_INVALID); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_BUSINESS_ADDRESS_REGION_IS_INVALID); | |
$error = $result->errors->forKey("merchantAccount")->forKey("funding")->onAttribute("destination"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_FUNDING_DESTINATION_IS_INVALID); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_FUNDING_DESTINATION_IS_INVALID); | |
$error = $result->errors->forKey("merchantAccount")->forKey("funding")->onAttribute("routingNumber"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_FUNDING_ROUTING_NUMBER_IS_INVALID); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_FUNDING_ROUTING_NUMBER_IS_INVALID); | |
$error = $result->errors->forKey("merchantAccount")->forKey("funding")->onAttribute("accountNumber"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_FUNDING_ACCOUNT_NUMBER_IS_INVALID); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_FUNDING_ACCOUNT_NUMBER_IS_INVALID); | |
$error = $result->errors->forKey("merchantAccount")->forKey("funding")->onAttribute("email"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_FUNDING_EMAIL_IS_INVALID); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_FUNDING_EMAIL_IS_INVALID); | |
$error = $result->errors->forKey("merchantAccount")->forKey("funding")->onAttribute("mobilePhone"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_FUNDING_MOBILE_PHONE_IS_INVALID); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_FUNDING_MOBILE_PHONE_IS_INVALID); | |
} | |
- function testUpdateWithInvalidBusinessFields() | |
+ public function testUpdateWithInvalidBusinessFields() | |
{ | |
- $params = array( | |
- "business" => array( | |
+ $params = [ | |
+ "business" => [ | |
"legalName" => "", | |
"taxId" => "111223333", | |
- ) | |
- ); | |
+ ] | |
+ ]; | |
- $result = Braintree_MerchantAccount::update("sandbox_sub_merchant_account", $params); | |
+ $result = Braintree\MerchantAccount::update("sandbox_sub_merchant_account", $params); | |
$this->assertEquals(false, $result->success); | |
$error = $result->errors->forKey("merchantAccount")->forKey("business")->onAttribute("legalName"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_BUSINESS_LEGAL_NAME_IS_REQUIRED_WITH_TAX_ID); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_BUSINESS_LEGAL_NAME_IS_REQUIRED_WITH_TAX_ID); | |
$error = $result->errors->forKey("merchantAccount")->forKey("business")->onAttribute("taxId"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_BUSINESS_TAX_ID_MUST_BE_BLANK); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_BUSINESS_TAX_ID_MUST_BE_BLANK); | |
- $params = array( | |
- "business" => array( | |
+ $params = [ | |
+ "business" => [ | |
"legalName" => "legal name", | |
"taxId" => "", | |
- ) | |
- ); | |
+ ] | |
+ ]; | |
- $result = Braintree_MerchantAccount::update("sandbox_sub_merchant_account", $params); | |
+ $result = Braintree\MerchantAccount::update("sandbox_sub_merchant_account", $params); | |
$this->assertEquals(false, $result->success); | |
$error = $result->errors->forKey("merchantAccount")->forKey("business")->onAttribute("taxId"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_BUSINESS_TAX_ID_IS_REQUIRED_WITH_LEGAL_NAME); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_BUSINESS_TAX_ID_IS_REQUIRED_WITH_LEGAL_NAME); | |
} | |
- function testUpdateWithInvalidFundingFields() | |
+ public function testUpdateWithInvalidFundingFields() | |
{ | |
- $params = array( | |
- "funding" => array( | |
- "destination" => Braintree_MerchantAccount::FUNDING_DESTINATION_EMAIL, | |
+ $params = [ | |
+ "funding" => [ | |
+ "destination" => Braintree\MerchantAccount::FUNDING_DESTINATION_EMAIL, | |
"email" => "", | |
- ) | |
- ); | |
+ ] | |
+ ]; | |
- $result = Braintree_MerchantAccount::update("sandbox_sub_merchant_account", $params); | |
+ $result = Braintree\MerchantAccount::update("sandbox_sub_merchant_account", $params); | |
$this->assertEquals(false, $result->success); | |
$error = $result->errors->forKey("merchantAccount")->forKey("funding")->onAttribute("email"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_FUNDING_EMAIL_IS_REQUIRED); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_FUNDING_EMAIL_IS_REQUIRED); | |
- $params = array( | |
- "funding" => array( | |
- "destination" => Braintree_MerchantAccount::FUNDING_DESTINATION_MOBILE_PHONE, | |
+ $params = [ | |
+ "funding" => [ | |
+ "destination" => Braintree\MerchantAccount::FUNDING_DESTINATION_MOBILE_PHONE, | |
"mobilePhone" => "", | |
- ) | |
- ); | |
+ ] | |
+ ]; | |
- $result = Braintree_MerchantAccount::update("sandbox_sub_merchant_account", $params); | |
+ $result = Braintree\MerchantAccount::update("sandbox_sub_merchant_account", $params); | |
$this->assertEquals(false, $result->success); | |
$error = $result->errors->forKey("merchantAccount")->forKey("funding")->onAttribute("mobilePhone"); | |
- $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_FUNDING_MOBILE_PHONE_IS_REQUIRED); | |
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_FUNDING_MOBILE_PHONE_IS_REQUIRED); | |
} | |
} | |
Index: braintree_sdk/tests/integration/MerchantTest.php | |
=================================================================== | |
--- braintree_sdk/tests/integration/MerchantTest.php (revision 1387260) | |
+++ braintree_sdk/tests/integration/MerchantTest.php (working copy) | |
@@ -1,19 +1,25 @@ | |
<?php | |
-require_once __DIR__ . '/../TestHelper.php'; | |
+namespace Test\Integration; | |
-class Braintree_MerchantTest extends PHPUnit_Framework_TestCase | |
+require_once dirname(__DIR__) . '/Setup.php'; | |
+ | |
+use Test; | |
+use Test\Setup; | |
+use Braintree; | |
+ | |
+class MerchantTest extends Setup | |
{ | |
- function testCreateMerchant() | |
+ public function testCreateMerchant() | |
{ | |
- $gateway = new Braintree_Gateway(array( | |
+ $gateway = new Braintree\Gateway([ | |
'clientId' => 'client_id$development$integration_client_id', | |
'clientSecret' => 'client_secret$development$integration_client_secret', | |
- )); | |
- $result = $gateway->merchant()->create(array( | |
+ ]); | |
+ $result = $gateway->merchant()->create([ | |
'email' => '[email protected]', | |
'countryCodeAlpha3' => 'USA', | |
'paymentMethods' => ['credit_card', 'paypal'], | |
- )); | |
+ ]); | |
$this->assertEquals(true, $result->success); | |
$merchant = $result->merchant; | |
@@ -23,34 +29,34 @@ | |
} | |
/** | |
- * @expectedException Braintree_Exception_Configuration | |
- * @expectedExceptionMessage clientId needs to be passed to Braintree_Gateway. | |
+ * @expectedException Braintree\Exception\Configuration | |
+ * @expectedExceptionMessage clientId needs to be passed to Braintree\Gateway | |
*/ | |
- function testAssertsHasCredentials() | |
+ public function testAssertsHasCredentials() | |
{ | |
- $gateway = new Braintree_Gateway(array( | |
+ $gateway = new Braintree\Gateway([ | |
'clientSecret' => 'client_secret$development$integration_client_secret', | |
- )); | |
- $gateway->merchant()->create(array( | |
+ ]); | |
+ $gateway->merchant()->create([ | |
'email' => '[email protected]', | |
'countryCodeAlpha3' => 'USA', | |
- )); | |
+ ]); | |
} | |
- function testBadPaymentMethods() | |
+ public function testBadPaymentMethods() | |
{ | |
- $gateway = new Braintree_Gateway(array( | |
+ $gateway = new Braintree\Gateway([ | |
'clientId' => 'client_id$development$integration_client_id', | |
'clientSecret' => 'client_secret$development$integration_client_secret', | |
- )); | |
- $result = $gateway->merchant()->create(array( | |
+ ]); | |
+ $result = $gateway->merchant()->create([ | |
'email' => '[email protected]', | |
'countryCodeAlpha3' => 'USA', | |
'paymentMethods' => ['fake_money'], | |
- )); | |
+ ]); | |
$this->assertEquals(false, $result->success); | |
$errors = $result->errors->forKey('merchant')->onAttribute('paymentMethods'); | |
- $this->assertEquals(Braintree_Error_Codes::MERCHANT_ACCOUNT_PAYMENT_METHODS_ARE_INVALID, $errors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::MERCHANT_ACCOUNT_PAYMENT_METHODS_ARE_INVALID, $errors[0]->code); | |
} | |
} | |
Index: braintree_sdk/tests/integration/MultipleValueNodeTest.php | |
=================================================================== | |
--- braintree_sdk/tests/integration/MultipleValueNodeTest.php (revision 1387260) | |
+++ braintree_sdk/tests/integration/MultipleValueNodeTest.php (working copy) | |
@@ -1,89 +1,94 @@ | |
<?php | |
-require_once realpath(dirname(__FILE__)) . '/../TestHelper.php'; | |
-require_once realpath(dirname(__FILE__)) . '/SubscriptionTestHelper.php'; | |
+namespace Test\Integration; | |
-class Braintree_MultipleValueNodeTest extends PHPUnit_Framework_TestCase | |
+require_once dirname(__DIR__) . '/Setup.php'; | |
+ | |
+use Test; | |
+use Test\Setup; | |
+use Braintree; | |
+ | |
+class MultipleValueNodeTest extends Setup | |
{ | |
- function testIn_singleValue() | |
+ public function testIn_singleValue() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $triallessPlan = Braintree_SubscriptionTestHelper::triallessPlan(); | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $triallessPlan = SubscriptionHelper::triallessPlan(); | |
- $activeSubscription = Braintree_Subscription::create(array( | |
+ $activeSubscription = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $triallessPlan['id'], | |
'price' => '3' | |
- ))->subscription; | |
+ ])->subscription; | |
- $canceledSubscription = Braintree_Subscription::create(array( | |
+ $canceledSubscription = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $triallessPlan['id'], | |
'price' => '3' | |
- ))->subscription; | |
- Braintree_Subscription::cancel($canceledSubscription->id); | |
+ ])->subscription; | |
+ Braintree\Subscription::cancel($canceledSubscription->id); | |
- $collection = Braintree_Subscription::search(array( | |
- Braintree_SubscriptionSearch::status()->in(array(Braintree_Subscription::ACTIVE)), | |
- Braintree_SubscriptionSearch::price()->is('3') | |
- )); | |
+ $collection = Braintree\Subscription::search([ | |
+ Braintree\SubscriptionSearch::status()->in([Braintree\Subscription::ACTIVE]), | |
+ Braintree\SubscriptionSearch::price()->is('3'), | |
+ ]); | |
foreach ($collection AS $item) { | |
- $this->assertEquals(Braintree_Subscription::ACTIVE, $item->status); | |
+ $this->assertEquals(Braintree\Subscription::ACTIVE, $item->status); | |
} | |
- $this->assertTrue(Braintree_TestHelper::includes($collection, $activeSubscription)); | |
- $this->assertFalse(Braintree_TestHelper::includes($collection, $canceledSubscription)); | |
+ $this->assertTrue(Test\Helper::includes($collection, $activeSubscription)); | |
+ $this->assertFalse(Test\Helper::includes($collection, $canceledSubscription)); | |
} | |
- function testIs() | |
+ public function testIs() | |
{ | |
$found = false; | |
- $collection = Braintree_Subscription::search(array( | |
- Braintree_SubscriptionSearch::status()->is(Braintree_Subscription::PAST_DUE) | |
- )); | |
+ $collection = Braintree\Subscription::search([ | |
+ Braintree\SubscriptionSearch::status()->is(Braintree\Subscription::PAST_DUE) | |
+ ]); | |
foreach ($collection AS $item) { | |
$found = true; | |
- $this->assertEquals(Braintree_Subscription::PAST_DUE, $item->status); | |
+ $this->assertEquals(Braintree\Subscription::PAST_DUE, $item->status); | |
} | |
$this->assertTrue($found); | |
} | |
- function testSearch_statusIsExpired() | |
+ public function testSearch_statusIsExpired() | |
{ | |
$found = false; | |
- $collection = Braintree_Subscription::search(array( | |
- Braintree_SubscriptionSearch::status()->in(array(Braintree_Subscription::EXPIRED)) | |
- )); | |
+ $collection = Braintree\Subscription::search([ | |
+ Braintree\SubscriptionSearch::status()->in([Braintree\Subscription::EXPIRED]) | |
+ ]); | |
foreach ($collection AS $item) { | |
$found = true; | |
- $this->assertEquals(Braintree_Subscription::EXPIRED, $item->status); | |
+ $this->assertEquals(Braintree\Subscription::EXPIRED, $item->status); | |
} | |
$this->assertTrue($found); | |
} | |
- function testIn_multipleValues() | |
+ public function testIn_multipleValues() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $triallessPlan = Braintree_SubscriptionTestHelper::triallessPlan(); | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $triallessPlan = SubscriptionHelper::triallessPlan(); | |
- $activeSubscription = Braintree_Subscription::create(array( | |
+ $activeSubscription = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $triallessPlan['id'], | |
'price' => '4' | |
- ))->subscription; | |
+ ])->subscription; | |
- $canceledSubscription = Braintree_Subscription::create(array( | |
+ $canceledSubscription = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $triallessPlan['id'], | |
'price' => '4' | |
- ))->subscription; | |
- Braintree_Subscription::cancel($canceledSubscription->id); | |
+ ])->subscription; | |
+ Braintree\Subscription::cancel($canceledSubscription->id); | |
- $collection = Braintree_Subscription::search(array( | |
- Braintree_SubscriptionSearch::status()->in(array(Braintree_Subscription::ACTIVE, Braintree_Subscription::CANCELED)), | |
- Braintree_SubscriptionSearch::price()->is('4') | |
- )); | |
+ $collection = Braintree\Subscription::search([ | |
+ Braintree\SubscriptionSearch::status()->in([Braintree\Subscription::ACTIVE, Braintree\Subscription::CANCELED]), | |
+ Braintree\SubscriptionSearch::price()->is('4') | |
+ ]); | |
- $this->assertTrue(Braintree_TestHelper::includes($collection, $activeSubscription)); | |
- $this->assertTrue(Braintree_TestHelper::includes($collection, $canceledSubscription)); | |
+ $this->assertTrue(Test\Helper::includes($collection, $activeSubscription)); | |
+ $this->assertTrue(Test\Helper::includes($collection, $canceledSubscription)); | |
} | |
} | |
Index: braintree_sdk/tests/integration/OAuthTest.php | |
=================================================================== | |
--- braintree_sdk/tests/integration/OAuthTest.php (revision 1387260) | |
+++ braintree_sdk/tests/integration/OAuthTest.php (working copy) | |
@@ -1,36 +1,28 @@ | |
<?php | |
-require_once __DIR__ . '/../TestHelper.php'; | |
+namespace Test\Integration; | |
-class Braintree_OAuthTest extends PHPUnit_Framework_TestCase | |
+require_once dirname(__DIR__) . '/Setup.php'; | |
+ | |
+use Test; | |
+use Test\Setup; | |
+use Braintree; | |
+ | |
+class OAuthTest extends Setup | |
{ | |
- /** | |
- * @expectedException Braintree_Exception_Configuration | |
- * @expectedExceptionMessage clientSecret needs to be passed to Braintree_Gateway. | |
- */ | |
- public function testAssertsHasCredentials() | |
- { | |
- $gateway = new Braintree_Gateway(array( | |
- 'clientId' => 'client_id$development$integration_client_id' | |
- )); | |
- $gateway->oauth()->createTokenFromCode(array( | |
- 'code' => 'integration_oauth_auth_code_' . rand(0,299) | |
- )); | |
- } | |
- | |
public function testCreateTokenFromCode() | |
{ | |
- $gateway = new Braintree_Gateway(array( | |
+ $gateway = new Braintree\Gateway([ | |
'clientId' => 'client_id$development$integration_client_id', | |
'clientSecret' => 'client_secret$development$integration_client_secret' | |
- )); | |
- $code = Braintree_OAuthTestHelper::createGrant($gateway, array( | |
+ ]); | |
+ $code = Test\Braintree\OAuthTestHelper::createGrant($gateway, [ | |
'merchant_public_id' => 'integration_merchant_id', | |
'scope' => 'read_write' | |
- )); | |
- $result = $gateway->oauth()->createTokenFromCode(array( | |
+ ]); | |
+ $result = $gateway->oauth()->createTokenFromCode([ | |
'code' => $code, | |
'scope' => 'read_write', | |
- )); | |
+ ]); | |
$this->assertEquals(true, $result->success); | |
$credentials = $result->credentials; | |
@@ -40,21 +32,36 @@ | |
$this->assertNotNull($credentials->expiresAt); | |
} | |
+ /** | |
+ * @expectedException Braintree\Exception\Configuration | |
+ * @expectedExceptionMessage clientSecret needs to be passed to Braintree\Gateway. | |
+ */ | |
+ public function testAssertsHasCredentials() | |
+ { | |
+ $gateway = new Braintree\Gateway([ | |
+ 'clientId' => 'client_id$development$integration_client_id' | |
+ ]); | |
+ $gateway->oauth()->createTokenFromCode([ | |
+ 'code' => 'integration_oauth_auth_code_' . rand(0,299) | |
+ ]); | |
+ } | |
+ | |
+ | |
public function testCreateTokenFromCodeWithMixedCredentials() | |
{ | |
- $gateway = new Braintree_Gateway(array( | |
+ $gateway = new Braintree\Gateway([ | |
'clientId' => 'client_id$development$integration_client_id', | |
'clientSecret' => 'client_secret$development$integration_client_secret', | |
'accessToken' => 'access_token$development$integration_merchant_id$f9ac33b3dd', | |
- )); | |
- $code = Braintree_OAuthTestHelper::createGrant($gateway, array( | |
+ ]); | |
+ $code = Test\Braintree\OAuthTestHelper::createGrant($gateway, [ | |
'merchant_public_id' => 'integration_merchant_id', | |
'scope' => 'read_write' | |
- )); | |
- $result = $gateway->oauth()->createTokenFromCode(array( | |
+ ]); | |
+ $result = $gateway->oauth()->createTokenFromCode([ | |
'code' => $code, | |
'scope' => 'read_write', | |
- )); | |
+ ]); | |
$this->assertEquals(true, $result->success); | |
$credentials = $result->credentials; | |
@@ -66,18 +73,18 @@ | |
public function testCreateTokenFromCode_JsonAPI() | |
{ | |
- $gateway = new Braintree_Gateway(array( | |
+ $gateway = new Braintree\Gateway([ | |
'clientId' => 'client_id$development$integration_client_id', | |
'clientSecret' => 'client_secret$development$integration_client_secret' | |
- )); | |
- $code = Braintree_OAuthTestHelper::createGrant($gateway, array( | |
+ ]); | |
+ $code = Test\Braintree\OAuthTestHelper::createGrant($gateway, [ | |
'merchant_public_id' => 'integration_merchant_id', | |
'scope' => 'read_write' | |
- )); | |
- $result = $gateway->oauth()->createTokenFromCode(array( | |
+ ]); | |
+ $result = $gateway->oauth()->createTokenFromCode([ | |
'code' => $code, | |
'scope' => 'read_write', | |
- )); | |
+ ]); | |
$this->assertEquals(true, $result->success); | |
$this->assertNotNull($result->accessToken); | |
@@ -88,31 +95,31 @@ | |
public function testCreateTokenFromCode_ValidationErrorTest() | |
{ | |
- $gateway = new Braintree_Gateway(array( | |
+ $gateway = new Braintree\Gateway([ | |
'clientId' => 'client_id$development$integration_client_id', | |
'clientSecret' => 'client_secret$development$integration_client_secret' | |
- )); | |
- $result = $gateway->oauth()->createTokenFromCode(array( | |
+ ]); | |
+ $result = $gateway->oauth()->createTokenFromCode([ | |
'code' => 'bad_code', | |
'scope' => 'read_write', | |
- )); | |
+ ]); | |
$this->assertEquals(false, $result->success); | |
$errors = $result->errors->forKey('credentials')->onAttribute('code'); | |
- $this->assertEquals(Braintree_Error_Codes::OAUTH_INVALID_GRANT, $errors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::OAUTH_INVALID_GRANT, $errors[0]->code); | |
$this->assertEquals(1, preg_match('/Invalid grant: code not found/', $result->message)); | |
} | |
public function testCreateTokenFromCode_OldError() | |
{ | |
- $gateway = new Braintree_Gateway(array( | |
+ $gateway = new Braintree\Gateway([ | |
'clientId' => 'client_id$development$integration_client_id', | |
'clientSecret' => 'client_secret$development$integration_client_secret' | |
- )); | |
- $result = $gateway->oauth()->createTokenFromCode(array( | |
+ ]); | |
+ $result = $gateway->oauth()->createTokenFromCode([ | |
'code' => 'bad_code', | |
'scope' => 'read_write', | |
- )); | |
+ ]); | |
$this->assertEquals(false, $result->success); | |
$this->assertEquals('invalid_grant', $result->error); | |
@@ -121,23 +128,23 @@ | |
public function testCreateTokenFromRefreshToken() | |
{ | |
- $gateway = new Braintree_Gateway(array( | |
+ $gateway = new Braintree\Gateway([ | |
'clientId' => 'client_id$development$integration_client_id', | |
'clientSecret' => 'client_secret$development$integration_client_secret' | |
- )); | |
- $code = Braintree_OAuthTestHelper::createGrant($gateway, array( | |
+ ]); | |
+ $code = Test\Braintree\OAuthTestHelper::createGrant($gateway, [ | |
'merchant_public_id' => 'integration_merchant_id', | |
'scope' => 'read_write' | |
- )); | |
- $refreshToken = $gateway->oauth()->createTokenFromCode(array( | |
+ ]); | |
+ $refreshToken = $gateway->oauth()->createTokenFromCode([ | |
'code' => $code, | |
'scope' => 'read_write', | |
- ))->credentials->refreshToken; | |
+ ])->credentials->refreshToken; | |
- $result = $gateway->oauth()->createTokenFromRefreshToken(array( | |
+ $result = $gateway->oauth()->createTokenFromRefreshToken([ | |
'refreshToken' => $refreshToken, | |
'scope' => 'read_write', | |
- )); | |
+ ]); | |
$this->assertEquals(true, $result->success); | |
$credentials = $result->credentials; | |
@@ -150,16 +157,16 @@ | |
public function testBuildConnectUrl() | |
{ | |
- $gateway = new Braintree_Gateway(array( | |
+ $gateway = new Braintree\Gateway([ | |
'clientId' => 'client_id$development$integration_client_id', | |
'clientSecret' => 'client_secret$development$integration_client_secret' | |
- )); | |
- $url = $gateway->oauth()->connectUrl(array( | |
+ ]); | |
+ $url = $gateway->oauth()->connectUrl([ | |
'merchantId' => 'integration_merchant_id', | |
'redirectUri' => 'http://bar.example.com', | |
'scope' => 'read_write', | |
'state' => 'baz_state', | |
- 'user' => array( | |
+ 'user' => [ | |
'country' => 'USA', | |
'email' => '[email protected]', | |
'firstName' => 'Bob', | |
@@ -172,8 +179,8 @@ | |
'locality' => 'Chicago', | |
'region' => 'IL', | |
'postalCode' => '60606', | |
- ), | |
- 'business' => array( | |
+ ], | |
+ 'business' => [ | |
'name' => '14 Ladders', | |
'registeredAs' => '14.0 Ladders', | |
'industry' => 'Ladders', | |
@@ -190,9 +197,9 @@ | |
'fulfillmentCompletedIn' => 7, | |
'currency' => 'USD', | |
'website' => 'http://example.com', | |
- ), | |
+ ], | |
'paymentMethods' => ['credit_card'], | |
- )); | |
+ ]); | |
$components = parse_url($url); | |
$queryString = $components['query']; | |
@@ -245,10 +252,10 @@ | |
public function testBuildConnectUrlWithoutOptionalParams() | |
{ | |
- $gateway = new Braintree_Gateway(array( | |
+ $gateway = new Braintree\Gateway([ | |
'clientId' => 'client_id$development$integration_client_id', | |
'clientSecret' => 'client_secret$development$integration_client_secret' | |
- )); | |
+ ]); | |
$url = $gateway->oauth()->connectUrl(); | |
$queryString = parse_url($url)['query']; | |
@@ -262,26 +269,26 @@ | |
public function testBuildConnectUrlWithPaymentMethods() | |
{ | |
- $gateway = new Braintree_Gateway(array( | |
+ $gateway = new Braintree\Gateway([ | |
'clientId' => 'client_id$development$integration_client_id', | |
'clientSecret' => 'client_secret$development$integration_client_secret' | |
- )); | |
- $url = $gateway->oauth()->connectUrl(array( | |
- 'paymentMethods' => array('credit_card', 'paypal') | |
- )); | |
+ ]); | |
+ $url = $gateway->oauth()->connectUrl([ | |
+ 'paymentMethods' => ['credit_card', 'paypal'] | |
+ ]); | |
$queryString = parse_url($url)['query']; | |
parse_str($queryString, $query); | |
- $this->assertEquals(array('credit_card', 'paypal'), $query['payment_methods']); | |
+ $this->assertEquals(['credit_card', 'paypal'], $query['payment_methods']); | |
} | |
public function testComputeSignature() | |
{ | |
- $gateway = new Braintree_Gateway(array( | |
+ $gateway = new Braintree\Gateway([ | |
'clientId' => 'client_id$development$integration_client_id', | |
'clientSecret' => 'client_secret$development$integration_client_secret' | |
- )); | |
+ ]); | |
$urlToSign = 'http://localhost:3000/oauth/connect?business%5Bname%5D=We+Like+Spaces&client_id=client_id%24development%24integration_client_id'; | |
$signature = $gateway->oauth()->computeSignature($urlToSign); | |
Index: braintree_sdk/tests/integration/PayPalAccountTest.php | |
=================================================================== | |
--- braintree_sdk/tests/integration/PayPalAccountTest.php (revision 1387260) | |
+++ braintree_sdk/tests/integration/PayPalAccountTest.php (working copy) | |
@@ -1,57 +1,60 @@ | |
<?php | |
-require_once realpath(dirname(__FILE__)) . '/../TestHelper.php'; | |
-require_once realpath(dirname(__FILE__)) . '/SubscriptionTestHelper.php'; | |
-require_once realpath(dirname(__FILE__)) . '/HttpClientApi.php'; | |
+namespace Test\Integration; | |
-class Braintree_PayPalAccountTest extends PHPUnit_Framework_TestCase | |
+require_once dirname(__DIR__) . '/Setup.php'; | |
+ | |
+use Test\Setup; | |
+use Braintree; | |
+ | |
+class PayPalAccountTest extends Setup | |
{ | |
- function testFind() | |
+ public function testFind() | |
{ | |
$paymentMethodToken = 'PAYPALToken-' . strval(rand()); | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonceForPayPalAccount(array( | |
- 'paypal_account' => array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonceForPayPalAccount([ | |
+ 'paypal_account' => [ | |
'consent_code' => 'PAYPAL_CONSENT_CODE', | |
'token' => $paymentMethodToken | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
- Braintree_PaymentMethod::create(array( | |
+ Braintree\PaymentMethod::create([ | |
'customerId' => $customer->id, | |
'paymentMethodNonce' => $nonce | |
- )); | |
+ ]); | |
- $foundPayPalAccount = Braintree_PayPalAccount::find($paymentMethodToken); | |
+ $foundPayPalAccount = Braintree\PayPalAccount::find($paymentMethodToken); | |
$this->assertSame('[email protected]', $foundPayPalAccount->email); | |
$this->assertSame($paymentMethodToken, $foundPayPalAccount->token); | |
$this->assertNotNull($foundPayPalAccount->imageUrl); | |
} | |
- function testGatewayFind() | |
+ public function testGatewayFind() | |
{ | |
$paymentMethodToken = 'PAYPALToken-' . strval(rand()); | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonceForPayPalAccount(array( | |
- 'paypal_account' => array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonceForPayPalAccount([ | |
+ 'paypal_account' => [ | |
'consent_code' => 'PAYPAL_CONSENT_CODE', | |
'token' => $paymentMethodToken | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
- Braintree_PaymentMethod::create(array( | |
+ Braintree\PaymentMethod::create([ | |
'customerId' => $customer->id, | |
'paymentMethodNonce' => $nonce | |
- )); | |
+ ]); | |
- $gateway = new Braintree_Gateway(array( | |
+ $gateway = new Braintree\Gateway([ | |
'environment' => 'development', | |
'merchantId' => 'integration_merchant_id', | |
'publicKey' => 'integration_public_key', | |
'privateKey' => 'integration_private_key' | |
- )); | |
+ ]); | |
$foundPayPalAccount = $gateway->paypalAccount()->find($paymentMethodToken); | |
$this->assertSame('[email protected]', $foundPayPalAccount->email); | |
@@ -59,245 +62,245 @@ | |
$this->assertNotNull($foundPayPalAccount->imageUrl); | |
} | |
- function testFind_doesNotReturnIncorrectPaymentMethodType() | |
+ public function testFind_doesNotReturnIncorrectPaymentMethodType() | |
{ | |
$creditCardToken = 'creditCardToken-' . strval(rand()); | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'cardholderName' => 'Cardholder', | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12', | |
'token' => $creditCardToken | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
- $this->setExpectedException('Braintree_Exception_NotFound'); | |
- Braintree_PayPalAccount::find($creditCardToken); | |
+ $this->setExpectedException('Braintree\Exception\NotFound'); | |
+ Braintree\PayPalAccount::find($creditCardToken); | |
} | |
- function test_PayPalAccountExposesTimestamps() | |
+ public function test_PayPalAccountExposesTimestamps() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_PaymentMethod::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\PaymentMethod::create([ | |
'customerId' => $customer->id, | |
- 'paymentMethodNonce' => Braintree_Test_Nonces::$paypalFuturePayment | |
- )); | |
+ 'paymentMethodNonce' => Braintree\Test\Nonces::$paypalFuturePayment, | |
+ ]); | |
$this->assertTrue($result->success); | |
$this->assertNotNull($result->paymentMethod->createdAt); | |
$this->assertNotNull($result->paymentMethod->updatedAt); | |
} | |
- function test_PayPalAccountExposesBillingAgreementId() | |
+ public function test_PayPalAccountExposesBillingAgreementId() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_PaymentMethod::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\PaymentMethod::create([ | |
'customerId' => $customer->id, | |
- 'paymentMethodNonce' => Braintree_Test_Nonces::$paypalBillingAgreement | |
- )); | |
+ 'paymentMethodNonce' => Braintree\Test\Nonces::$paypalBillingAgreement | |
+ ]); | |
$this->assertTrue($result->success); | |
- $foundPayPalAccount = Braintree_PayPalAccount::find($result->paymentMethod->token); | |
+ $foundPayPalAccount = Braintree\PayPalAccount::find($result->paymentMethod->token); | |
$this->assertNotNull($foundPayPalAccount->billingAgreementId); | |
} | |
- function testFind_throwsIfCannotBeFound() | |
+ public function testFind_throwsIfCannotBeFound() | |
{ | |
- $this->setExpectedException('Braintree_Exception_NotFound'); | |
- Braintree_PayPalAccount::find('invalid-token'); | |
+ $this->setExpectedException('Braintree\Exception\NotFound'); | |
+ Braintree\PayPalAccount::find('invalid-token'); | |
} | |
- function testFind_throwsUsefulErrorMessagesWhenEmpty() | |
+ public function testFind_throwsUsefulErrorMessagesWhenEmpty() | |
{ | |
$this->setExpectedException('InvalidArgumentException', 'expected paypal account id to be set'); | |
- Braintree_PayPalAccount::find(''); | |
+ Braintree\PayPalAccount::find(''); | |
} | |
- function testFind_throwsUsefulErrorMessagesWhenInvalid() | |
+ public function testFind_throwsUsefulErrorMessagesWhenInvalid() | |
{ | |
$this->setExpectedException('InvalidArgumentException', '@ is an invalid paypal account token'); | |
- Braintree_PayPalAccount::find('@'); | |
+ Braintree\PayPalAccount::find('@'); | |
} | |
- function testFind_returnsSubscriptionsAssociatedWithAPaypalAccount() | |
+ public function testFind_returnsSubscriptionsAssociatedWithAPaypalAccount() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
+ $customer = Braintree\Customer::createNoValidate(); | |
$paymentMethodToken = 'paypal-account-' . strval(rand()); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonceForPayPalAccount(array( | |
- 'paypal_account' => array( | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonceForPayPalAccount([ | |
+ 'paypal_account' => [ | |
'consent_code' => 'consent-code', | |
'token' => $paymentMethodToken | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
- $result = Braintree_PaymentMethod::create(array( | |
+ $result = Braintree\PaymentMethod::create([ | |
'paymentMethodNonce' => $nonce, | |
'customerId' => $customer->id | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
$token = $result->paymentMethod->token; | |
- $triallessPlan = Braintree_SubscriptionTestHelper::triallessPlan(); | |
+ $triallessPlan = SubscriptionHelper::triallessPlan(); | |
- $subscription1 = Braintree_Subscription::create(array( | |
+ $subscription1 = Braintree\Subscription::create([ | |
'paymentMethodToken' => $token, | |
'planId' => $triallessPlan['id'] | |
- ))->subscription; | |
+ ])->subscription; | |
- $subscription2 = Braintree_Subscription::create(array( | |
+ $subscription2 = Braintree\Subscription::create([ | |
'paymentMethodToken' => $token, | |
'planId' => $triallessPlan['id'] | |
- ))->subscription; | |
+ ])->subscription; | |
- $paypalAccount = Braintree_PayPalAccount::find($token); | |
+ $paypalAccount = Braintree\PayPalAccount::find($token); | |
$getIds = function($sub) { return $sub->id; }; | |
$subIds = array_map($getIds, $paypalAccount->subscriptions); | |
$this->assertTrue(in_array($subscription1->id, $subIds)); | |
$this->assertTrue(in_array($subscription2->id, $subIds)); | |
} | |
- function testUpdate() | |
+ public function testUpdate() | |
{ | |
$originalToken = 'ORIGINAL_PAYPALToken-' . strval(rand()); | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonceForPayPalAccount(array( | |
- 'paypal_account' => array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonceForPayPalAccount([ | |
+ 'paypal_account' => [ | |
'consent_code' => 'PAYPAL_CONSENT_CODE', | |
'token' => $originalToken | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
- $createResult = Braintree_PaymentMethod::create(array( | |
+ $createResult = Braintree\PaymentMethod::create([ | |
'customerId' => $customer->id, | |
'paymentMethodNonce' => $nonce | |
- )); | |
+ ]); | |
$this->assertTrue($createResult->success); | |
$newToken = 'NEW_PAYPALToken-' . strval(rand()); | |
- $updateResult = Braintree_PayPalAccount::update($originalToken, array( | |
+ $updateResult = Braintree\PayPalAccount::update($originalToken, [ | |
'token' => $newToken | |
- )); | |
+ ]); | |
$this->assertTrue($updateResult->success); | |
$this->assertEquals($newToken, $updateResult->paypalAccount->token); | |
- $this->setExpectedException('Braintree_Exception_NotFound'); | |
- Braintree_PayPalAccount::find($originalToken); | |
+ $this->setExpectedException('Braintree\Exception\NotFound'); | |
+ Braintree\PayPalAccount::find($originalToken); | |
} | |
- function testUpdateAndMakeDefault() | |
+ public function testUpdateAndMakeDefault() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
+ $customer = Braintree\Customer::createNoValidate(); | |
- $creditCardResult = Braintree_CreditCard::create(array( | |
+ $creditCardResult = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- )); | |
+ ]); | |
$this->assertTrue($creditCardResult->success); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonceForPayPalAccount(array( | |
- 'paypal_account' => array( | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonceForPayPalAccount([ | |
+ 'paypal_account' => [ | |
'consent_code' => 'PAYPAL_CONSENT_CODE' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
- $createResult = Braintree_PaymentMethod::create(array( | |
+ $createResult = Braintree\PaymentMethod::create([ | |
'customerId' => $customer->id, | |
'paymentMethodNonce' => $nonce | |
- )); | |
+ ]); | |
$this->assertTrue($createResult->success); | |
- $updateResult = Braintree_PayPalAccount::update($createResult->paymentMethod->token, array( | |
- 'options' => array('makeDefault' => true) | |
- )); | |
+ $updateResult = Braintree\PayPalAccount::update($createResult->paymentMethod->token, [ | |
+ 'options' => ['makeDefault' => true] | |
+ ]); | |
$this->assertTrue($updateResult->success); | |
$this->assertTrue($updateResult->paypalAccount->isDefault()); | |
} | |
- function testUpdate_handleErrors() | |
+ public function testUpdate_handleErrors() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
+ $customer = Braintree\Customer::createNoValidate(); | |
$firstToken = 'FIRST_PAYPALToken-' . strval(rand()); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $firstNonce = $http->nonceForPayPalAccount(array( | |
- 'paypal_account' => array( | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $firstNonce = $http->nonceForPayPalAccount([ | |
+ 'paypal_account' => [ | |
'consent_code' => 'PAYPAL_CONSENT_CODE', | |
'token' => $firstToken | |
- ) | |
- )); | |
- $firstPaypalAccount = Braintree_PaymentMethod::create(array( | |
+ ] | |
+ ]); | |
+ $firstPaypalAccount = Braintree\PaymentMethod::create([ | |
'customerId' => $customer->id, | |
'paymentMethodNonce' => $firstNonce | |
- )); | |
+ ]); | |
$this->assertTrue($firstPaypalAccount->success); | |
$secondToken = 'SECOND_PAYPALToken-' . strval(rand()); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $secondNonce = $http->nonceForPayPalAccount(array( | |
- 'paypal_account' => array( | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $secondNonce = $http->nonceForPayPalAccount([ | |
+ 'paypal_account' => [ | |
'consent_code' => 'PAYPAL_CONSENT_CODE', | |
'token' => $secondToken | |
- ) | |
- )); | |
- $secondPaypalAccount = Braintree_PaymentMethod::create(array( | |
+ ] | |
+ ]); | |
+ $secondPaypalAccount = Braintree\PaymentMethod::create([ | |
'customerId' => $customer->id, | |
'paymentMethodNonce' => $secondNonce | |
- )); | |
+ ]); | |
$this->assertTrue($secondPaypalAccount->success); | |
- $updateResult = Braintree_PayPalAccount::update($firstToken, array( | |
+ $updateResult = Braintree\PayPalAccount::update($firstToken, [ | |
'token' => $secondToken | |
- )); | |
+ ]); | |
$this->assertFalse($updateResult->success); | |
$errors = $updateResult->errors->forKey('paypalAccount')->errors; | |
- $this->assertEquals(Braintree_Error_Codes::PAYPAL_ACCOUNT_TOKEN_IS_IN_USE, $errors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::PAYPAL_ACCOUNT_TOKEN_IS_IN_USE, $errors[0]->code); | |
} | |
- function testDelete() | |
+ public function testDelete() | |
{ | |
$paymentMethodToken = 'PAYPALToken-' . strval(rand()); | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonceForPayPalAccount(array( | |
- 'paypal_account' => array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonceForPayPalAccount([ | |
+ 'paypal_account' => [ | |
'consent_code' => 'PAYPAL_CONSENT_CODE', | |
'token' => $paymentMethodToken | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
- Braintree_PaymentMethod::create(array( | |
+ Braintree\PaymentMethod::create([ | |
'customerId' => $customer->id, | |
'paymentMethodNonce' => $nonce | |
- )); | |
+ ]); | |
- Braintree_PayPalAccount::delete($paymentMethodToken); | |
+ Braintree\PayPalAccount::delete($paymentMethodToken); | |
- $this->setExpectedException('Braintree_Exception_NotFound'); | |
- Braintree_PayPalAccount::find($paymentMethodToken); | |
+ $this->setExpectedException('Braintree\Exception\NotFound'); | |
+ Braintree\PayPalAccount::find($paymentMethodToken); | |
} | |
- function testSale_createsASaleUsingGivenToken() | |
+ public function testSale_createsASaleUsingGivenToken() | |
{ | |
- $nonce = Braintree_Test_Nonces::$paypalFuturePayment; | |
- $customer = Braintree_Customer::createNoValidate(array( | |
+ $nonce = Braintree\Test\Nonces::$paypalFuturePayment; | |
+ $customer = Braintree\Customer::createNoValidate([ | |
'paymentMethodNonce' => $nonce | |
- )); | |
+ ]); | |
$paypalAccount = $customer->paypalAccounts[0]; | |
- $result = Braintree_PayPalAccount::sale($paypalAccount->token, array( | |
+ $result = Braintree\PayPalAccount::sale($paypalAccount->token, [ | |
'amount' => '100.00' | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
$this->assertEquals('100.00', $result->transaction->amount); | |
$this->assertEquals($customer->id, $result->transaction->customerDetails->id); | |
Index: braintree_sdk/tests/integration/PaymentMethodNonceTest.php | |
=================================================================== | |
--- braintree_sdk/tests/integration/PaymentMethodNonceTest.php (revision 1387260) | |
+++ braintree_sdk/tests/integration/PaymentMethodNonceTest.php (working copy) | |
@@ -1,35 +1,39 @@ | |
<?php | |
-require_once realpath(dirname(__FILE__)) . '/../TestHelper.php'; | |
-require_once realpath(dirname(__FILE__)) . '/HttpClientApi.php'; | |
+namespace Test\Integration; | |
-class Braintree_PaymentMethodNonceTest extends PHPUnit_Framework_TestCase | |
+require_once dirname(__DIR__) . '/Setup.php'; | |
+ | |
+use Test\Setup; | |
+use Braintree; | |
+ | |
+class PaymentMethodNonceTest extends Setup | |
{ | |
- function testCreate_fromPaymentMethodToken() | |
+ public function testCreate_fromPaymentMethodToken() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $card = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $card = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'cardholderName' => 'Cardholder', | |
'number' => '5105105105105100', | |
- 'expirationDate' => '05/12' | |
- ))->creditCard; | |
+ 'expirationDate' => '05/12', | |
+ ])->creditCard; | |
- $result = Braintree_PaymentMethodNonce::create($card->token); | |
+ $result = Braintree\PaymentMethodNonce::create($card->token); | |
$this->assertTrue($result->success); | |
$this->assertNotNull($result->paymentMethodNonce); | |
$this->assertNotNull($result->paymentMethodNonce->nonce); | |
} | |
- function testCreate_fromNonExistentPaymentMethodToken() | |
+ public function testCreate_fromNonExistentPaymentMethodToken() | |
{ | |
- $this->setExpectedException('Braintree_Exception_NotFound'); | |
- Braintree_PaymentMethodNonce::create('not_a_token'); | |
+ $this->setExpectedException('Braintree\Exception\NotFound'); | |
+ Braintree\PaymentMethodNonce::create('not_a_token'); | |
} | |
- function testFind_exposesThreeDSecureInfo() | |
+ public function testFind_exposesThreeDSecureInfo() | |
{ | |
- $nonce = Braintree_PaymentMethodNonce::find('threedsecurednonce'); | |
+ $nonce = Braintree\PaymentMethodNonce::find('threedsecurednonce'); | |
$info = $nonce->threeDSecureInfo; | |
$this->assertEquals('threedsecurednonce', $nonce->nonce); | |
@@ -40,27 +44,27 @@ | |
$this->assertTrue($info->liabilityShiftPossible); | |
} | |
- function testFind_exposesNullThreeDSecureInfoIfNoneExists() | |
+ public function testFind_exposesNullThreeDSecureInfoIfNoneExists() | |
{ | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonce_for_new_card(array( | |
- "creditCard" => array( | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonce_for_new_card([ | |
+ "creditCard" => [ | |
"number" => "4111111111111111", | |
"expirationMonth" => "11", | |
"expirationYear" => "2099" | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
- $foundNonce = Braintree_PaymentMethodNonce::find($nonce); | |
+ $foundNonce = Braintree\PaymentMethodNonce::find($nonce); | |
$info = $foundNonce->threeDSecureInfo; | |
$this->assertEquals($nonce, $foundNonce->nonce); | |
$this->assertNull($info); | |
} | |
- function testFind_nonExistantNonce() | |
+ public function testFind_nonExistantNonce() | |
{ | |
- $this->setExpectedException('Braintree_Exception_NotFound'); | |
- Braintree_PaymentMethodNonce::find('not_a_nonce'); | |
+ $this->setExpectedException('Braintree\Exception\NotFound'); | |
+ Braintree\PaymentMethodNonce::find('not_a_nonce'); | |
} | |
} | |
Index: braintree_sdk/tests/integration/PaymentMethodTest.php | |
=================================================================== | |
--- braintree_sdk/tests/integration/PaymentMethodTest.php (revision 1387260) | |
+++ braintree_sdk/tests/integration/PaymentMethodTest.php (working copy) | |
@@ -1,578 +1,640 @@ | |
<?php | |
-require_once realpath(dirname(__FILE__)) . '/../TestHelper.php'; | |
-require_once realpath(dirname(__FILE__)) . '/HttpClientApi.php'; | |
+namespace Test\Integration; | |
-class Braintree_PaymentMethodTest extends PHPUnit_Framework_TestCase | |
+require_once dirname(__DIR__) . '/Setup.php'; | |
+ | |
+use Test; | |
+use Test\Setup; | |
+use Braintree; | |
+ | |
+class PaymentMethodTest extends Setup | |
{ | |
- function testCreate_fromVaultedCreditCardNonce() | |
+ public function testCreate_fromVaultedCreditCardNonce() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonce_for_new_card(array( | |
- 'credit_card' => array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonce_for_new_card([ | |
+ 'credit_card' => [ | |
'number' => '4111111111111111', | |
'expirationMonth' => '11', | |
'expirationYear' => '2099' | |
- ), | |
+ ], | |
'share' => true | |
- )); | |
+ ]); | |
- $result = Braintree_PaymentMethod::create(array( | |
+ $result = Braintree\PaymentMethod::create([ | |
'customerId' => $customer->id, | |
'paymentMethodNonce' => $nonce | |
- )); | |
+ ]); | |
$this->assertSame('411111', $result->paymentMethod->bin); | |
$this->assertSame('1111', $result->paymentMethod->last4); | |
$this->assertNotNull($result->paymentMethod->token); | |
$this->assertNotNull($result->paymentMethod->imageUrl); | |
+ $this->assertSame($customer->id, $result->paymentMethod->customerId); | |
} | |
- function testGatewayCreate_fromVaultedCreditCardNonce() | |
+ public function testGatewayCreate_fromVaultedCreditCardNonce() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonce_for_new_card(array( | |
- 'credit_card' => array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonce_for_new_card([ | |
+ 'credit_card' => [ | |
'number' => '4111111111111111', | |
'expirationMonth' => '11', | |
'expirationYear' => '2099' | |
- ), | |
+ ], | |
'share' => true | |
- )); | |
+ ]); | |
- $gateway = new Braintree_Gateway(array( | |
+ $gateway = new Braintree\Gateway([ | |
'environment' => 'development', | |
'merchantId' => 'integration_merchant_id', | |
'publicKey' => 'integration_public_key', | |
'privateKey' => 'integration_private_key' | |
- )); | |
- $result = $gateway->paymentMethod()->create(array( | |
+ ]); | |
+ $result = $gateway->paymentMethod()->create([ | |
'customerId' => $customer->id, | |
'paymentMethodNonce' => $nonce | |
- )); | |
+ ]); | |
$this->assertSame('411111', $result->paymentMethod->bin); | |
$this->assertSame('1111', $result->paymentMethod->last4); | |
$this->assertNotNull($result->paymentMethod->token); | |
$this->assertNotNull($result->paymentMethod->imageUrl); | |
+ $this->assertSame($customer->id, $result->paymentMethod->customerId); | |
} | |
- function testCreate_fromFakeApplePayNonce() | |
+ public function testCreate_fromFakeApplePayNonce() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_PaymentMethod::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\PaymentMethod::create([ | |
'customerId' => $customer->id, | |
- 'paymentMethodNonce' => Braintree_Test_Nonces::$applePayVisa | |
- )); | |
+ 'paymentMethodNonce' => Braintree\Test\Nonces::$applePayVisa, | |
+ ]); | |
$this->assertTrue($result->success); | |
$applePayCard = $result->paymentMethod; | |
$this->assertNotNull($applePayCard->token); | |
- $this->assertSame(Braintree_ApplePayCard::VISA, $applePayCard->cardType); | |
+ $this->assertSame(Braintree\ApplePayCard::VISA, $applePayCard->cardType); | |
$this->assertContains("Visa ", $applePayCard->paymentInstrumentName); | |
$this->assertContains("Visa ", $applePayCard->sourceDescription); | |
$this->assertTrue($applePayCard->default); | |
$this->assertContains('apple_pay', $applePayCard->imageUrl); | |
$this->assertTrue(intval($applePayCard->expirationMonth) > 0); | |
$this->assertTrue(intval($applePayCard->expirationYear) > 0); | |
+ $this->assertSame($customer->id, $applePayCard->customerId); | |
} | |
- function testCreate_fromFakeAndroidPayProxyCardNonce() | |
+ public function testCreate_fromFakeAndroidPayProxyCardNonce() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_PaymentMethod::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\PaymentMethod::create([ | |
'customerId' => $customer->id, | |
- 'paymentMethodNonce' => Braintree_Test_Nonces::$androidPayDiscover | |
- )); | |
+ 'paymentMethodNonce' => Braintree\Test\Nonces::$androidPayDiscover | |
+ ]); | |
$this->assertTrue($result->success); | |
$androidPayCard = $result->paymentMethod; | |
$this->assertNotNull($androidPayCard->token); | |
- $this->assertSame(Braintree_CreditCard::DISCOVER, $androidPayCard->virtualCardType); | |
- $this->assertSame(Braintree_CreditCard::DISCOVER, $androidPayCard->cardType); | |
+ $this->assertSame(Braintree\CreditCard::DISCOVER, $androidPayCard->virtualCardType); | |
+ $this->assertSame(Braintree\CreditCard::DISCOVER, $androidPayCard->cardType); | |
$this->assertSame("1117", $androidPayCard->virtualCardLast4); | |
$this->assertSame("1117", $androidPayCard->last4); | |
- $this->assertSame(Braintree_CreditCard::VISA, $androidPayCard->sourceCardType); | |
+ $this->assertSame(Braintree\CreditCard::VISA, $androidPayCard->sourceCardType); | |
$this->assertSame("1111", $androidPayCard->sourceCardLast4); | |
$this->assertSame("Visa 1111", $androidPayCard->sourceDescription); | |
$this->assertTrue($androidPayCard->default); | |
$this->assertContains('android_pay', $androidPayCard->imageUrl); | |
$this->assertTrue(intval($androidPayCard->expirationMonth) > 0); | |
$this->assertTrue(intval($androidPayCard->expirationYear) > 0); | |
+ $this->assertSame($customer->id, $androidPayCard->customerId); | |
} | |
- function testCreate_fromFakeAndroidPayNetworkTokenNonce() | |
+ public function testCreate_fromFakeAndroidPayNetworkTokenNonce() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_PaymentMethod::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\PaymentMethod::create([ | |
'customerId' => $customer->id, | |
- 'paymentMethodNonce' => Braintree_Test_Nonces::$androidPayMasterCard | |
- )); | |
+ 'paymentMethodNonce' => Braintree\Test\Nonces::$androidPayMasterCard | |
+ ]); | |
$this->assertTrue($result->success); | |
$androidPayCard = $result->paymentMethod; | |
$this->assertNotNull($androidPayCard->token); | |
- $this->assertSame(Braintree_CreditCard::MASTER_CARD, $androidPayCard->virtualCardType); | |
- $this->assertSame(Braintree_CreditCard::MASTER_CARD, $androidPayCard->cardType); | |
+ $this->assertSame(Braintree\CreditCard::MASTER_CARD, $androidPayCard->virtualCardType); | |
+ $this->assertSame(Braintree\CreditCard::MASTER_CARD, $androidPayCard->cardType); | |
$this->assertSame("4444", $androidPayCard->virtualCardLast4); | |
$this->assertSame("4444", $androidPayCard->last4); | |
- $this->assertSame(Braintree_CreditCard::MASTER_CARD, $androidPayCard->sourceCardType); | |
+ $this->assertSame(Braintree\CreditCard::MASTER_CARD, $androidPayCard->sourceCardType); | |
$this->assertSame("4444", $androidPayCard->sourceCardLast4); | |
$this->assertSame("MasterCard 4444", $androidPayCard->sourceDescription); | |
$this->assertTrue($androidPayCard->default); | |
$this->assertContains('android_pay', $androidPayCard->imageUrl); | |
$this->assertTrue(intval($androidPayCard->expirationMonth) > 0); | |
$this->assertTrue(intval($androidPayCard->expirationYear) > 0); | |
+ $this->assertSame($customer->id, $androidPayCard->customerId); | |
} | |
- function testCreate_fromUnvalidatedCreditCardNonce() | |
+ public function testCreate_fromFakeAmexExpressCheckoutCardNonce() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonce_for_new_card(array( | |
- 'credit_card' => array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\PaymentMethod::create([ | |
+ 'customerId' => $customer->id, | |
+ 'paymentMethodNonce' => Braintree\Test\Nonces::$amexExpressCheckout | |
+ ]); | |
+ | |
+ $this->assertTrue($result->success); | |
+ $amexExpressCheckoutCard = $result->paymentMethod; | |
+ $this->assertInstanceOf('Braintree\AmexExpressCheckoutCard', $amexExpressCheckoutCard); | |
+ | |
+ $this->assertNotNull($amexExpressCheckoutCard->token); | |
+ $this->assertSame(Braintree\CreditCard::AMEX, $amexExpressCheckoutCard->cardType); | |
+ $this->assertSame("341111", $amexExpressCheckoutCard->bin); | |
+ $this->assertSame("12/21", $amexExpressCheckoutCard->cardMemberExpiryDate); | |
+ $this->assertSame("0005", $amexExpressCheckoutCard->cardMemberNumber); | |
+ $this->assertSame("American Express", $amexExpressCheckoutCard->cardType); | |
+ $this->assertNotNull($amexExpressCheckoutCard->sourceDescription); | |
+ $this->assertContains(".png", $amexExpressCheckoutCard->imageUrl); | |
+ $this->assertTrue(intval($amexExpressCheckoutCard->expirationMonth) > 0); | |
+ $this->assertTrue(intval($amexExpressCheckoutCard->expirationYear) > 0); | |
+ $this->assertTrue($amexExpressCheckoutCard->default); | |
+ $this->assertSame($customer->id, $amexExpressCheckoutCard->customerId); | |
+ $this->assertEquals([], $amexExpressCheckoutCard->subscriptions); | |
+ } | |
+ | |
+ public function testCreate_fromFakeVenmoAccountNonce() | |
+ { | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\PaymentMethod::create(array( | |
+ 'customerId' => $customer->id, | |
+ 'paymentMethodNonce' => Braintree\Test\Nonces::$venmoAccount | |
+ )); | |
+ | |
+ $this->assertTrue($result->success); | |
+ $venmoAccount = $result->paymentMethod; | |
+ $this->assertInstanceOf('Braintree\VenmoAccount', $venmoAccount); | |
+ | |
+ $this->assertNotNull($venmoAccount->token); | |
+ $this->assertNotNull($venmoAccount->sourceDescription); | |
+ $this->assertContains(".png", $venmoAccount->imageUrl); | |
+ $this->assertTrue($venmoAccount->default); | |
+ $this->assertSame($customer->id, $venmoAccount->customerId); | |
+ $this->assertEquals(array(), $venmoAccount->subscriptions); | |
+ $this->assertSame("venmojoe", $venmoAccount->username); | |
+ $this->assertSame("Venmo-Joe-1", $venmoAccount->venmoUserId); | |
+ } | |
+ | |
+ public function testCreate_fromUnvalidatedCreditCardNonce() | |
+ { | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonce_for_new_card([ | |
+ 'credit_card' => [ | |
'number' => '4111111111111111', | |
'expirationMonth' => '11', | |
'expirationYear' => '2099', | |
- 'options' => array( | |
+ 'options' => [ | |
'validate' => false | |
- ) | |
- ) | |
- )); | |
+ ] | |
+ ] | |
+ ]); | |
- $result = Braintree_PaymentMethod::create(array( | |
+ $result = Braintree\PaymentMethod::create([ | |
'customerId' => $customer->id, | |
'paymentMethodNonce' => $nonce | |
- )); | |
+ ]); | |
$this->assertSame('411111', $result->paymentMethod->bin); | |
$this->assertSame('1111', $result->paymentMethod->last4); | |
+ $this->assertSame($customer->id, $result->paymentMethod->customerId); | |
$this->assertNotNull($result->paymentMethod->token); | |
} | |
- function testCreate_fromUnvalidatedFuturePaypalAccountNonce() | |
+ public function testCreate_fromUnvalidatedFuturePaypalAccountNonce() | |
{ | |
$paymentMethodToken = 'PAYPAL_TOKEN-' . strval(rand()); | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonceForPayPalAccount(array( | |
- 'paypal_account' => array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonceForPayPalAccount([ | |
+ 'paypal_account' => [ | |
'consent_code' => 'PAYPAL_CONSENT_CODE', | |
'token' => $paymentMethodToken | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
- $result = Braintree_PaymentMethod::create(array( | |
+ $result = Braintree\PaymentMethod::create([ | |
'customerId' => $customer->id, | |
'paymentMethodNonce' => $nonce | |
- )); | |
+ ]); | |
$this->assertSame('[email protected]', $result->paymentMethod->email); | |
$this->assertSame($paymentMethodToken, $result->paymentMethod->token); | |
+ $this->assertSame($customer->id, $result->paymentMethod->customerId); | |
} | |
- function testCreate_fromAbstractPaymentMethodNonce() | |
+ public function testCreate_fromAbstractPaymentMethodNonce() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
+ $customer = Braintree\Customer::createNoValidate(); | |
- $result = Braintree_PaymentMethod::create(array( | |
+ $result = Braintree\PaymentMethod::create([ | |
'customerId' => $customer->id, | |
- 'paymentMethodNonce' => Braintree_Test_Nonces::$abstractTransactable | |
- )); | |
+ 'paymentMethodNonce' => Braintree\Test\Nonces::$abstractTransactable, | |
+ ]); | |
$this->assertTrue($result->success); | |
$this->assertNotNull($result->paymentMethod->token); | |
+ $this->assertSame($customer->id, $result->paymentMethod->customerId); | |
} | |
- function testCreate_doesNotWorkForUnvalidatedOnetimePaypalAccountNonce() | |
+ public function testCreate_doesNotWorkForUnvalidatedOnetimePaypalAccountNonce() | |
{ | |
$paymentMethodToken = 'PAYPAL_TOKEN-' . strval(rand()); | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonceForPayPalAccount(array( | |
- 'paypal_account' => array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonceForPayPalAccount([ | |
+ 'paypal_account' => [ | |
'access_token' => 'PAYPAL_ACCESS_TOKEN', | |
'token' => $paymentMethodToken | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
- $result = Braintree_PaymentMethod::create(array( | |
+ $result = Braintree\PaymentMethod::create([ | |
'customerId' => $customer->id, | |
'paymentMethodNonce' => $nonce | |
- )); | |
+ ]); | |
$this->assertFalse($result->success); | |
$errors = $result->errors->forKey('paypalAccount')->errors; | |
- $this->assertEquals(Braintree_Error_Codes::PAYPAL_ACCOUNT_CANNOT_VAULT_ONE_TIME_USE_PAYPAL_ACCOUNT, $errors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::PAYPAL_ACCOUNT_CANNOT_VAULT_ONE_TIME_USE_PAYPAL_ACCOUNT, $errors[0]->code); | |
} | |
- function testCreate_handlesValidationErrorsForPayPalAccounts() | |
+ public function testCreate_handlesValidationErrorsForPayPalAccounts() | |
{ | |
$paymentMethodToken = 'PAYPAL_TOKEN-' . strval(rand()); | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonceForPayPalAccount(array( | |
- 'paypal_account' => array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonceForPayPalAccount([ | |
+ 'paypal_account' => [ | |
'token' => $paymentMethodToken | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
- $result = Braintree_PaymentMethod::create(array( | |
+ $result = Braintree\PaymentMethod::create([ | |
'customerId' => $customer->id, | |
'paymentMethodNonce' => $nonce | |
- )); | |
+ ]); | |
$this->assertFalse($result->success); | |
$errors = $result->errors->forKey('paypalAccount')->errors; | |
- $this->assertEquals(Braintree_Error_Codes::PAYPAL_ACCOUNT_CANNOT_VAULT_ONE_TIME_USE_PAYPAL_ACCOUNT, $errors[0]->code); | |
- $this->assertEquals(Braintree_Error_Codes::PAYPAL_ACCOUNT_CONSENT_CODE_OR_ACCESS_TOKEN_IS_REQUIRED, $errors[1]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::PAYPAL_ACCOUNT_CANNOT_VAULT_ONE_TIME_USE_PAYPAL_ACCOUNT, $errors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::PAYPAL_ACCOUNT_CONSENT_CODE_OR_ACCESS_TOKEN_IS_REQUIRED, $errors[1]->code); | |
} | |
- function testCreate_allowsPassingDefaultOptionWithNonce() | |
+ public function testCreate_allowsPassingDefaultOptionWithNonce() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $card1 = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $card1 = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'cardholderName' => 'Cardholder', | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- ))->creditCard; | |
+ ])->creditCard; | |
$this->assertTrue($card1->isDefault()); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonce_for_new_card(array( | |
- 'credit_card' => array( | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonce_for_new_card([ | |
+ 'credit_card' => [ | |
'number' => '4111111111111111', | |
'expirationMonth' => '11', | |
'expirationYear' => '2099', | |
- 'options' => array( | |
+ 'options' => [ | |
'validate' => false | |
- ) | |
- ) | |
- )); | |
+ ] | |
+ ] | |
+ ]); | |
- $result = Braintree_PaymentMethod::create(array( | |
+ $result = Braintree\PaymentMethod::create([ | |
'customerId' => $customer->id, | |
'paymentMethodNonce' => $nonce, | |
- 'options' => array( | |
+ 'options' => [ | |
'makeDefault' => true | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$card2 = $result->paymentMethod; | |
- $card1 = Braintree_CreditCard::find($card1->token); | |
+ $card1 = Braintree\CreditCard::find($card1->token); | |
$this->assertFalse($card1->isDefault()); | |
$this->assertTrue($card2->isDefault()); | |
} | |
- function testCreate_overridesNonceToken() | |
+ public function testCreate_overridesNonceToken() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
+ $customer = Braintree\Customer::createNoValidate(); | |
$firstToken = 'FIRST_TOKEN-' . strval(rand()); | |
$secondToken = 'SECOND_TOKEN-' . strval(rand()); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonce_for_new_card(array( | |
- 'credit_card' => array( | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonce_for_new_card([ | |
+ 'credit_card' => [ | |
'token' => $firstToken, | |
'number' => '4111111111111111', | |
'expirationMonth' => '11', | |
'expirationYear' => '2099', | |
- 'options' => array( | |
+ 'options' => [ | |
'validate' => false | |
- ) | |
- ) | |
- )); | |
+ ] | |
+ ] | |
+ ]); | |
- $result = Braintree_PaymentMethod::create(array( | |
+ $result = Braintree\PaymentMethod::create([ | |
'customerId' => $customer->id, | |
'paymentMethodNonce' => $nonce, | |
'token' => $secondToken | |
- )); | |
+ ]); | |
$card = $result->paymentMethod; | |
$this->assertEquals($secondToken, $card->token); | |
} | |
- function testCreate_respectsVerifyCardAndVerificationMerchantAccountIdWhenIncludedOutsideOfTheNonce() | |
+ public function testCreate_respectsVerifyCardAndVerificationMerchantAccountIdWhenIncludedOutsideOfTheNonce() | |
{ | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonce_for_new_card(array( | |
- 'credit_card' => array( | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonce_for_new_card([ | |
+ 'credit_card' => [ | |
'number' => '4000111111111115', | |
'expirationMonth' => '11', | |
'expirationYear' => '2099', | |
- ) | |
- )); | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_PaymentMethod::create(array( | |
+ ] | |
+ ]); | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\PaymentMethod::create([ | |
'paymentMethodNonce' => $nonce, | |
'customerId' => $customer->id, | |
- 'options' => array( | |
+ 'options' => [ | |
'verifyCard' => 'true', | |
- 'verificationMerchantAccountId' => Braintree_TestHelper::nonDefaultMerchantAccountId() | |
- ) | |
- )); | |
+ 'verificationMerchantAccountId' => Test\Helper::nonDefaultMerchantAccountId(), | |
+ ] | |
+ ]); | |
$this->assertFalse($result->success); | |
- $this->assertEquals(Braintree_Result_CreditCardVerification::PROCESSOR_DECLINED, $result->creditCardVerification->status); | |
+ $this->assertEquals(Braintree\Result\CreditCardVerification::PROCESSOR_DECLINED, $result->creditCardVerification->status); | |
$this->assertEquals('2000', $result->creditCardVerification->processorResponseCode); | |
$this->assertEquals('Do Not Honor', $result->creditCardVerification->processorResponseText); | |
- $this->assertEquals(Braintree_TestHelper::nonDefaultMerchantAccountId(), $result->creditCardVerification->merchantAccountId); | |
+ $this->assertEquals(Test\Helper::nonDefaultMerchantAccountId(), $result->creditCardVerification->merchantAccountId); | |
} | |
- function testCreate_respectsFailOnDuplicatePaymentMethodWhenIncludedOutsideTheNonce() | |
+ public function testCreate_respectsFailOnDuplicatePaymentMethodWhenIncludedOutsideTheNonce() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
- 'number' => Braintree_Test_CreditCardNumbers::$visa, | |
+ 'number' => Braintree\Test\CreditCardNumbers::$visa, | |
'expirationDate' => "05/2012" | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonce_for_new_card(array( | |
- 'credit_card' => array( | |
- 'number' => Braintree_Test_CreditCardNumbers::$visa, | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonce_for_new_card([ | |
+ 'credit_card' => [ | |
+ 'number' => Braintree\Test\CreditCardNumbers::$visa, | |
'expirationDate' => "05/2012" | |
- ) | |
- )); | |
- $updateResult = Braintree_PaymentMethod::create(array( | |
+ ] | |
+ ]); | |
+ $updateResult = Braintree\PaymentMethod::create([ | |
'paymentMethodNonce' => $nonce, | |
'customerId' => $customer->id, | |
- 'options' => array( | |
+ 'options' => [ | |
'failOnDuplicatePaymentMethod' => 'true', | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$this->assertFalse($updateResult->success); | |
$resultErrors = $updateResult->errors->deepAll(); | |
$this->assertEquals("81724", $resultErrors[0]->code); | |
} | |
- function testCreate_allowsPassingABillingAddressOutsideOfTheNonce() | |
+ public function testCreate_allowsPassingABillingAddressOutsideOfTheNonce() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonce_for_new_card(array( | |
- 'credit_card' => array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonce_for_new_card([ | |
+ 'credit_card' => [ | |
'number' => '4111111111111111', | |
'expirationMonth' => '12', | |
'expirationYear' => '2020', | |
- 'options' => array( | |
+ 'options' => [ | |
'validate' => false | |
- ) | |
- ) | |
- )); | |
+ ] | |
+ ] | |
+ ]); | |
- $result = Braintree_PaymentMethod::create(array( | |
+ $result = Braintree\PaymentMethod::create([ | |
'paymentMethodNonce' => $nonce, | |
'customerId' => $customer->id, | |
- 'billingAddress' => array( | |
+ 'billingAddress' => [ | |
'streetAddress' => '123 Abc Way' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$this->assertTrue($result->success); | |
- $this->assertTrue(is_a($result->paymentMethod,'Braintree_CreditCard')); | |
+ $this->assertTrue(is_a($result->paymentMethod, 'Braintree\CreditCard')); | |
$token = $result->paymentMethod->token; | |
- $foundCreditCard = Braintree_CreditCard::find($token); | |
+ $foundCreditCard = Braintree\CreditCard::find($token); | |
$this->assertTrue(NULL != $foundCreditCard); | |
$this->assertEquals('123 Abc Way', $foundCreditCard->billingAddress->streetAddress); | |
} | |
- function testCreate_overridesTheBillingAddressInTheNonce() | |
+ public function testCreate_overridesTheBillingAddressInTheNonce() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonce_for_new_card(array( | |
- 'credit_card' => array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonce_for_new_card([ | |
+ 'credit_card' => [ | |
'number' => '4111111111111111', | |
'expirationMonth' => '12', | |
'expirationYear' => '2020', | |
- 'options' => array( | |
+ 'options' => [ | |
'validate' => false | |
- ), | |
- 'billingAddress' => array( | |
+ ], | |
+ 'billingAddress' => [ | |
'streetAddress' => '456 Xyz Way' | |
- ) | |
- ) | |
- )); | |
+ ] | |
+ ] | |
+ ]); | |
- $result = Braintree_PaymentMethod::create(array( | |
+ $result = Braintree\PaymentMethod::create([ | |
'paymentMethodNonce' => $nonce, | |
'customerId' => $customer->id, | |
- 'billingAddress' => array( | |
+ 'billingAddress' => [ | |
'streetAddress' => '123 Abc Way' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$this->assertTrue($result->success); | |
- $this->assertTrue(is_a($result->paymentMethod,'Braintree_CreditCard')); | |
+ $this->assertTrue(is_a($result->paymentMethod, 'Braintree\CreditCard')); | |
$token = $result->paymentMethod->token; | |
- $foundCreditCard = Braintree_CreditCard::find($token); | |
+ $foundCreditCard = Braintree\CreditCard::find($token); | |
$this->assertTrue(NULL != $foundCreditCard); | |
$this->assertEquals('123 Abc Way', $foundCreditCard->billingAddress->streetAddress); | |
} | |
- function testCreate_doesNotOverrideTheBillingAddressForAVaultedCreditCard() | |
+ public function testCreate_doesNotOverrideTheBillingAddressForAVaultedCreditCard() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonce_for_new_card(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonce_for_new_card([ | |
'customerId' => $customer->id, | |
- 'credit_card' => array( | |
+ 'credit_card' => [ | |
'number' => '4111111111111111', | |
'expirationMonth' => '12', | |
'expirationYear' => '2020', | |
- 'billingAddress' => array( | |
+ 'billingAddress' => [ | |
'streetAddress' => '456 Xyz Way' | |
- ) | |
- ) | |
- )); | |
+ ] | |
+ ] | |
+ ]); | |
- $result = Braintree_PaymentMethod::create(array( | |
+ $result = Braintree\PaymentMethod::create([ | |
'paymentMethodNonce' => $nonce, | |
'customerId' => $customer->id, | |
- 'billingAddress' => array( | |
+ 'billingAddress' => [ | |
'streetAddress' => '123 Abc Way' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$this->assertTrue($result->success); | |
- $this->assertTrue(is_a($result->paymentMethod,'Braintree_CreditCard')); | |
+ $this->assertTrue(is_a($result->paymentMethod, 'Braintree\CreditCard')); | |
$token = $result->paymentMethod->token; | |
- $foundCreditCard = Braintree_CreditCard::find($token); | |
+ $foundCreditCard = Braintree\CreditCard::find($token); | |
$this->assertTrue(NULL != $foundCreditCard); | |
$this->assertEquals('456 Xyz Way', $foundCreditCard->billingAddress->streetAddress); | |
} | |
- function testCreate_allowsPassingABillingAddressIdOutsideOfTheNonce() | |
+ public function testCreate_allowsPassingABillingAddressIdOutsideOfTheNonce() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonce_for_new_card(array( | |
- 'credit_card' => array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonce_for_new_card([ | |
+ 'credit_card' => [ | |
'number' => '4111111111111111', | |
'expirationMonth' => '12', | |
'expirationYear' => '2020', | |
- 'options' => array( | |
+ 'options' => [ | |
'validate' => false | |
- ) | |
- ) | |
- )); | |
+ ] | |
+ ] | |
+ ]); | |
- $address = Braintree_Address::create(array( | |
+ $address = Braintree\Address::create([ | |
'customerId' => $customer->id, | |
'firstName' => 'Bobby', | |
'lastName' => 'Tables' | |
- ))->address; | |
- $result = Braintree_PaymentMethod::create(array( | |
+ ])->address; | |
+ $result = Braintree\PaymentMethod::create([ | |
'paymentMethodNonce' => $nonce, | |
'customerId' => $customer->id, | |
'billingAddressId' => $address->id | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
- $this->assertTrue(is_a($result->paymentMethod,'Braintree_CreditCard')); | |
+ $this->assertTrue(is_a($result->paymentMethod, 'Braintree\CreditCard')); | |
$token = $result->paymentMethod->token; | |
- $foundCreditCard = Braintree_CreditCard::find($token); | |
+ $foundCreditCard = Braintree\CreditCard::find($token); | |
$this->assertTrue(NULL != $foundCreditCard); | |
$this->assertEquals('Bobby', $foundCreditCard->billingAddress->firstName); | |
$this->assertEquals('Tables', $foundCreditCard->billingAddress->lastName); | |
} | |
- function testCreate_doesNotReturnAnErrorIfCreditCardOptionsArePresentForAPaypalNonce() | |
+ public function testCreate_doesNotReturnAnErrorIfCreditCardOptionsArePresentForAPaypalNonce() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
+ $customer = Braintree\Customer::createNoValidate(); | |
$originalToken = 'paypal-account-' . strval(rand()); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonceForPaypalAccount(array( | |
- 'paypalAccount' => array( | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonceForPaypalAccount([ | |
+ 'paypalAccount' => [ | |
'consentCode' => 'consent-code', | |
'token' => $originalToken | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
- $result = Braintree_PaymentMethod::create(array( | |
+ $result = Braintree\PaymentMethod::create([ | |
'paymentMethodNonce' => $nonce, | |
'customerId' => $customer->id, | |
- 'options' => array( | |
+ 'options' => [ | |
'verifyCard' => 'true', | |
'failOnDuplicatePaymentMethod' => 'true', | |
'verificationMerchantAccountId' => 'Not a Real Merchant Account Id' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$this->assertTrue($result->success); | |
} | |
- function testCreate_ignoresPassedBillingAddressParamsForPaypalAccount() | |
+ public function testCreate_ignoresPassedBillingAddressParamsForPaypalAccount() | |
{ | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonceForPaypalAccount(array( | |
- 'paypalAccount' => array( | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonceForPaypalAccount([ | |
+ 'paypalAccount' => [ | |
'consentCode' => 'PAYPAL_CONSENT_CODE', | |
- ) | |
- )); | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_PaymentMethod::create(array( | |
+ ] | |
+ ]); | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\PaymentMethod::create([ | |
'paymentMethodNonce' => $nonce, | |
'customerId' => $customer->id, | |
- 'billingAddress' => array( | |
+ 'billingAddress' => [ | |
'streetAddress' => '123 Abc Way' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$this->assertTrue($result->success); | |
- $this->assertTrue(is_a($result->paymentMethod,'Braintree_PaypalAccount')); | |
+ $this->assertTrue(is_a($result->paymentMethod, 'Braintree\PaypalAccount')); | |
$token = $result->paymentMethod->token; | |
- $foundPaypalAccount = Braintree_PaypalAccount::find($token); | |
+ $foundPaypalAccount = Braintree\PaypalAccount::find($token); | |
$this->assertTrue(NULL != $foundPaypalAccount); | |
} | |
- function testCreate_ignoresPassedBillingAddressIdForPaypalAccount() | |
+ public function testCreate_ignoresPassedBillingAddressIdForPaypalAccount() | |
{ | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonceForPaypalAccount(array( | |
- 'paypalAccount' => array( | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonceForPaypalAccount([ | |
+ 'paypalAccount' => [ | |
'consentCode' => 'PAYPAL_CONSENT_CODE', | |
- ) | |
- )); | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_PaymentMethod::create(array( | |
+ ] | |
+ ]); | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\PaymentMethod::create([ | |
'paymentMethodNonce' => $nonce, | |
'customerId' => $customer->id, | |
'billingAddressId' => 'address_id' | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
- $this->assertTrue(is_a($result->paymentMethod,'Braintree_PaypalAccount')); | |
+ $this->assertTrue(is_a($result->paymentMethod, 'Braintree\PaypalAccount')); | |
$token = $result->paymentMethod->token; | |
- $foundPaypalAccount = Braintree_PaypalAccount::find($token); | |
+ $foundPaypalAccount = Braintree\PaypalAccount::find($token); | |
$this->assertTrue(NULL != $foundPaypalAccount); | |
} | |
- function testCreate_acceptsNumberAndOtherCreditCardParameters() | |
+ public function testCreate_acceptsNumberAndOtherCreditCardParameters() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_PaymentMethod::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\PaymentMethod::create([ | |
'customerId' => $customer->id, | |
- 'paymentMethodNonce' => Braintree_Test_Nonces::$transactable, | |
+ 'paymentMethodNonce' => Braintree\Test\Nonces::$transactable, | |
'cardholderName' => 'Jane Doe', | |
'cvv' => '123', | |
'expirationMonth' => '10', | |
'expirationYear' => '24', | |
'number' => '4242424242424242' | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
$this->assertTrue('Jane Doe' == $result->paymentMethod->cardholderName); | |
@@ -582,19 +644,19 @@ | |
$this->assertTrue('4242' == $result->paymentMethod->last4); | |
} | |
- function testFind_returnsCreditCards() | |
+ public function testFind_returnsCreditCards() | |
{ | |
$paymentMethodToken = 'CREDIT_CARD_TOKEN-' . strval(rand()); | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $creditCardResult = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $creditCardResult = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'number' => '5105105105105100', | |
'expirationDate' => '05/2011', | |
'token' => $paymentMethodToken | |
- )); | |
+ ]); | |
$this->assertTrue($creditCardResult->success); | |
- $foundCreditCard = Braintree_PaymentMethod::find($creditCardResult->creditCard->token); | |
+ $foundCreditCard = Braintree\PaymentMethod::find($creditCardResult->creditCard->token); | |
$this->assertEquals($paymentMethodToken, $foundCreditCard->token); | |
$this->assertEquals('510510', $foundCreditCard->bin); | |
@@ -602,186 +664,188 @@ | |
$this->assertEquals('05/2011', $foundCreditCard->expirationDate); | |
} | |
- function testFind_returnsCreditCardsWithSubscriptions() | |
+ public function testFind_returnsCreditCardsWithSubscriptions() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $creditCardResult = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $creditCardResult = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'number' => '5105105105105100', | |
'expirationDate' => '05/2011', | |
- )); | |
+ ]); | |
$this->assertTrue($creditCardResult->success); | |
$subscriptionId = strval(rand()); | |
- Braintree_Subscription::create(array( | |
+ Braintree\Subscription::create([ | |
'id' => $subscriptionId, | |
'paymentMethodToken' => $creditCardResult->creditCard->token, | |
'planId' => 'integration_trialless_plan', | |
'price' => '1.00' | |
- )); | |
+ ]); | |
- $foundCreditCard = Braintree_PaymentMethod::find($creditCardResult->creditCard->token); | |
+ $foundCreditCard = Braintree\PaymentMethod::find($creditCardResult->creditCard->token); | |
$this->assertEquals($subscriptionId, $foundCreditCard->subscriptions[0]->id); | |
$this->assertEquals('integration_trialless_plan', $foundCreditCard->subscriptions[0]->planId); | |
$this->assertEquals('1.00', $foundCreditCard->subscriptions[0]->price); | |
} | |
- function testFind_returnsPayPalAccounts() | |
+ public function testFind_returnsPayPalAccounts() | |
{ | |
$paymentMethodToken = 'PAYPAL_TOKEN-' . strval(rand()); | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonceForPayPalAccount(array( | |
- 'paypal_account' => array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonceForPayPalAccount([ | |
+ 'paypal_account' => [ | |
'consent_code' => 'PAYPAL_CONSENT_CODE', | |
'token' => $paymentMethodToken | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
- Braintree_PaymentMethod::create(array( | |
+ Braintree\PaymentMethod::create([ | |
'customerId' => $customer->id, | |
'paymentMethodNonce' => $nonce | |
- )); | |
+ ]); | |
- $foundPayPalAccount = Braintree_PaymentMethod::find($paymentMethodToken); | |
+ $foundPayPalAccount = Braintree\PaymentMethod::find($paymentMethodToken); | |
$this->assertSame('[email protected]', $foundPayPalAccount->email); | |
$this->assertSame($paymentMethodToken, $foundPayPalAccount->token); | |
} | |
- function testFind_returnsApplePayCards() | |
+ public function testFind_returnsApplePayCards() | |
{ | |
$paymentMethodToken = 'APPLE_PAY-' . strval(rand()); | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $nonce = Braintree_Test_Nonces::$applePayVisa; | |
- Braintree_PaymentMethod::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $nonce = Braintree\Test\Nonces::$applePayVisa; | |
+ Braintree\PaymentMethod::create([ | |
'customerId' => $customer->id, | |
'paymentMethodNonce' => $nonce, | |
'token' => $paymentMethodToken | |
- )); | |
+ ]); | |
- $foundApplePayCard = Braintree_PaymentMethod::find($paymentMethodToken); | |
+ $foundApplePayCard = Braintree\PaymentMethod::find($paymentMethodToken); | |
$this->assertSame($paymentMethodToken, $foundApplePayCard->token); | |
- $this->assertInstanceOf('Braintree_ApplePayCard', $foundApplePayCard); | |
+ $this->assertInstanceOf('Braintree\ApplePayCard', $foundApplePayCard); | |
$this->assertTrue(intval($foundApplePayCard->expirationMonth) > 0); | |
$this->assertTrue(intval($foundApplePayCard->expirationYear) > 0); | |
} | |
- function testFind_returnsAndroidPayCards() | |
+ public function testFind_returnsAndroidPayCards() | |
{ | |
$paymentMethodToken = 'ANDROID-PAY-' . strval(rand()); | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $nonce = Braintree_Test_Nonces::$androidPay; | |
- Braintree_PaymentMethod::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $nonce = Braintree\Test\Nonces::$androidPay; | |
+ Braintree\PaymentMethod::create([ | |
'customerId' => $customer->id, | |
'paymentMethodNonce' => $nonce, | |
'token' => $paymentMethodToken | |
- )); | |
+ ]); | |
- $foundAndroidPayCard = Braintree_PaymentMethod::find($paymentMethodToken); | |
+ $foundAndroidPayCard = Braintree\PaymentMethod::find($paymentMethodToken); | |
$this->assertSame($paymentMethodToken, $foundAndroidPayCard->token); | |
- $this->assertInstanceOf('Braintree_AndroidPayCard', $foundAndroidPayCard); | |
- $this->assertSame(Braintree_CreditCard::DISCOVER, $foundAndroidPayCard->virtualCardType); | |
+ $this->assertInstanceOf('Braintree\AndroidPayCard', $foundAndroidPayCard); | |
+ $this->assertSame(Braintree\CreditCard::DISCOVER, $foundAndroidPayCard->virtualCardType); | |
$this->assertSame("1117", $foundAndroidPayCard->virtualCardLast4); | |
- $this->assertSame(Braintree_CreditCard::VISA, $foundAndroidPayCard->sourceCardType); | |
+ $this->assertSame(Braintree\CreditCard::VISA, $foundAndroidPayCard->sourceCardType); | |
$this->assertSame("1111", $foundAndroidPayCard->sourceCardLast4); | |
+ $this->assertSame($customer->id, $foundAndroidPayCard->customerId); | |
$this->assertTrue($foundAndroidPayCard->default); | |
$this->assertContains('android_pay', $foundAndroidPayCard->imageUrl); | |
$this->assertTrue(intval($foundAndroidPayCard->expirationMonth) > 0); | |
$this->assertTrue(intval($foundAndroidPayCard->expirationYear) > 0); | |
} | |
- function testFind_returnsCoinbaseAccounts() | |
+ public function testFind_returnsCoinbaseAccounts() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $result = Braintree_PaymentMethod::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $result = Braintree\PaymentMethod::create([ | |
'customerId' => $customer->id, | |
- 'paymentMethodNonce' => Braintree_Test_Nonces::$coinbase | |
- )); | |
+ 'paymentMethodNonce' => Braintree\Test\Nonces::$coinbase | |
+ ]); | |
$this->assertTrue($result->success); | |
$coinbaseAccount = $result->paymentMethod; | |
$this->assertNotNull($coinbaseAccount->token); | |
- $foundCoinbaseAccount = Braintree_PaymentMethod::find($coinbaseAccount->token); | |
- $this->assertInstanceOf('Braintree_CoinbaseAccount', $foundCoinbaseAccount); | |
+ $foundCoinbaseAccount = Braintree\PaymentMethod::find($coinbaseAccount->token); | |
+ $this->assertInstanceOf('Braintree\CoinbaseAccount', $foundCoinbaseAccount); | |
$this->assertNotNull($foundCoinbaseAccount->userId); | |
$this->assertNotNull($foundCoinbaseAccount->userName); | |
$this->assertNotNull($foundCoinbaseAccount->userEmail); | |
+ $this->assertNotNull($foundCoinbaseAccount->customerId); | |
} | |
- function testFind_returnsAbstractPaymentMethods() | |
+ public function testFind_returnsAbstractPaymentMethods() | |
{ | |
$paymentMethodToken = 'ABSTRACT-' . strval(rand()); | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $nonce = Braintree_test_Nonces::$abstractTransactable; | |
- Braintree_PaymentMethod::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $nonce = Braintree\Test\Nonces::$abstractTransactable; | |
+ Braintree\PaymentMethod::create([ | |
'customerId' => $customer->id, | |
'paymentMethodNonce' => $nonce, | |
'token' => $paymentMethodToken | |
- )); | |
+ ]); | |
- $foundPaymentMethod = Braintree_PaymentMethod::find($paymentMethodToken); | |
+ $foundPaymentMethod = Braintree\PaymentMethod::find($paymentMethodToken); | |
$this->assertSame($paymentMethodToken, $foundPaymentMethod-> token); | |
} | |
- function testFind_throwsIfCannotBeFound() | |
+ public function testFind_throwsIfCannotBeFound() | |
{ | |
- $this->setExpectedException('Braintree_Exception_NotFound'); | |
- Braintree_PaymentMethod::find('NON_EXISTENT_TOKEN'); | |
+ $this->setExpectedException('Braintree\Exception\NotFound'); | |
+ Braintree\PaymentMethod::find('NON_EXISTENT_TOKEN'); | |
} | |
- function testUpdate_updatesTheCreditCard() | |
+ public function testUpdate_updatesTheCreditCard() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $creditCardResult = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $creditCardResult = Braintree\CreditCard::create([ | |
'cardholderName' => 'Original Holder', | |
'customerId' => $customer->id, | |
'cvv' => '123', | |
- 'number' => Braintree_Test_CreditCardNumbers::$visa, | |
+ 'number' => Braintree\Test\CreditCardNumbers::$visa, | |
'expirationDate' => "05/2012" | |
- )); | |
+ ]); | |
$this->assertTrue($creditCardResult->success); | |
$creditCard = $creditCardResult->creditCard; | |
- $updateResult = Braintree_PaymentMethod::update($creditCard->token, array( | |
+ $updateResult = Braintree\PaymentMethod::update($creditCard->token, [ | |
'cardholderName' => 'New Holder', | |
'cvv' => '456', | |
- 'number' => Braintree_Test_CreditCardNumbers::$masterCard, | |
+ 'number' => Braintree\Test\CreditCardNumbers::$masterCard, | |
'expirationDate' => "06/2013" | |
- )); | |
+ ]); | |
$this->assertTrue($updateResult->success); | |
$this->assertSame($updateResult->paymentMethod->token, $creditCard->token); | |
$updatedCreditCard = $updateResult->paymentMethod; | |
$this->assertSame("New Holder", $updatedCreditCard->cardholderName); | |
- $this->assertSame(substr(Braintree_Test_CreditCardNumbers::$masterCard, 0, 6), $updatedCreditCard->bin); | |
- $this->assertSame(substr(Braintree_Test_CreditCardNumbers::$masterCard, -4), $updatedCreditCard->last4); | |
+ $this->assertSame(substr(Braintree\Test\CreditCardNumbers::$masterCard, 0, 6), $updatedCreditCard->bin); | |
+ $this->assertSame(substr(Braintree\Test\CreditCardNumbers::$masterCard, -4), $updatedCreditCard->last4); | |
$this->assertSame("06/2013", $updatedCreditCard->expirationDate); | |
} | |
- function testUpdate_createsANewBillingAddressByDefault() | |
+ public function testUpdate_createsANewBillingAddressByDefault() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $creditCardResult = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $creditCardResult = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
- 'number' => Braintree_Test_CreditCardNumbers::$visa, | |
+ 'number' => Braintree\Test\CreditCardNumbers::$visa, | |
'expirationDate' => "05/2012", | |
- 'billingAddress' => array( | |
+ 'billingAddress' => [ | |
'streetAddress' => '123 Nigeria Ave' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$this->assertTrue($creditCardResult->success); | |
$creditCard = $creditCardResult->creditCard; | |
- $updateResult = Braintree_PaymentMethod::update($creditCard->token, array( | |
- 'billingAddress' => array( | |
+ $updateResult = Braintree\PaymentMethod::update($creditCard->token, [ | |
+ 'billingAddress' => [ | |
'region' => 'IL' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$this->assertTrue($updateResult->success); | |
$updatedCreditCard = $updateResult->paymentMethod; | |
@@ -790,28 +854,28 @@ | |
$this->assertFalse($creditCard->billingAddress->id == $updatedCreditCard->billingAddress->id); | |
} | |
- function testUpdate_updatesTheBillingAddressIfOptionIsSpecified() | |
+ public function testUpdate_updatesTheBillingAddressIfOptionIsSpecified() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $creditCardResult = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $creditCardResult = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
- 'number' => Braintree_Test_CreditCardNumbers::$visa, | |
+ 'number' => Braintree\Test\CreditCardNumbers::$visa, | |
'expirationDate' => "05/2012", | |
- 'billingAddress' => array( | |
+ 'billingAddress' => [ | |
'streetAddress' => '123 Nigeria Ave' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$this->assertTrue($creditCardResult->success); | |
$creditCard = $creditCardResult->creditCard; | |
- $updateResult = Braintree_PaymentMethod::update($creditCard->token, array( | |
- 'billingAddress' => array( | |
+ $updateResult = Braintree\PaymentMethod::update($creditCard->token, [ | |
+ 'billingAddress' => [ | |
'region' => 'IL', | |
- 'options' => array( | |
+ 'options' => [ | |
'updateExisting' => 'true' | |
- ) | |
- ), | |
- )); | |
+ ] | |
+ ], | |
+ ]); | |
$this->assertTrue($updateResult->success); | |
$updatedCreditCard = $updateResult->paymentMethod; | |
@@ -820,31 +884,31 @@ | |
$this->assertTrue($creditCard->billingAddress->id == $updatedCreditCard->billingAddress->id); | |
} | |
- function testUpdate_updatesTheCountryViaCodes() | |
+ public function testUpdate_updatesTheCountryViaCodes() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $creditCardResult = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $creditCardResult = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
- 'number' => Braintree_Test_CreditCardNumbers::$visa, | |
+ 'number' => Braintree\Test\CreditCardNumbers::$visa, | |
'expirationDate' => "05/2012", | |
- 'billingAddress' => array( | |
+ 'billingAddress' => [ | |
'streetAddress' => '123 Nigeria Ave' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$this->assertTrue($creditCardResult->success); | |
$creditCard = $creditCardResult->creditCard; | |
- $updateResult = Braintree_PaymentMethod::update($creditCard->token, array( | |
- 'billingAddress' => array( | |
+ $updateResult = Braintree\PaymentMethod::update($creditCard->token, [ | |
+ 'billingAddress' => [ | |
'countryName' => 'American Samoa', | |
'countryCodeAlpha2' => 'AS', | |
'countryCodeAlpha3' => 'ASM', | |
'countryCodeNumeric' => '016', | |
- 'options' => array( | |
+ 'options' => [ | |
'updateExisting' => 'true' | |
- ) | |
- ), | |
- )); | |
+ ] | |
+ ], | |
+ ]); | |
$this->assertTrue($updateResult->success); | |
$updatedCreditCard = $updateResult->paymentMethod; | |
@@ -854,22 +918,22 @@ | |
$this->assertSame("016", $updatedCreditCard->billingAddress->countryCodeNumeric); | |
} | |
- function testUpdate_canPassExpirationMonthAndExpirationYear() | |
+ public function testUpdate_canPassExpirationMonthAndExpirationYear() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $creditCardResult = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $creditCardResult = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
- 'number' => Braintree_Test_CreditCardNumbers::$visa, | |
+ 'number' => Braintree\Test\CreditCardNumbers::$visa, | |
'expirationDate' => "05/2012" | |
- )); | |
+ ]); | |
$this->assertTrue($creditCardResult->success); | |
$creditCard = $creditCardResult->creditCard; | |
- $updateResult = Braintree_PaymentMethod::update($creditCard->token, array( | |
- 'number' => Braintree_Test_CreditCardNumbers::$masterCard, | |
+ $updateResult = Braintree\PaymentMethod::update($creditCard->token, [ | |
+ 'number' => Braintree\Test\CreditCardNumbers::$masterCard, | |
'expirationMonth' => "07", | |
'expirationYear' => "2011" | |
- )); | |
+ ]); | |
$this->assertTrue($updateResult->success); | |
$this->assertSame($updateResult->paymentMethod->token, $creditCard->token); | |
@@ -879,44 +943,44 @@ | |
$this->assertSame("07/2011", $updatedCreditCard->expirationDate); | |
} | |
- function testUpdate_verifiesTheUpdateIfOptionsVerifyCardIsTrue() | |
+ public function testUpdate_verifiesTheUpdateIfOptionsVerifyCardIsTrue() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $creditCardResult = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $creditCardResult = Braintree\CreditCard::create([ | |
'cardholderName' => 'Original Holder', | |
'customerId' => $customer->id, | |
'cvv' => '123', | |
- 'number' => Braintree_Test_CreditCardNumbers::$visa, | |
+ 'number' => Braintree\Test\CreditCardNumbers::$visa, | |
'expirationDate' => "05/2012" | |
- )); | |
+ ]); | |
$this->assertTrue($creditCardResult->success); | |
$creditCard = $creditCardResult->creditCard; | |
- $updateResult = Braintree_PaymentMethod::update($creditCard->token, array( | |
+ $updateResult = Braintree\PaymentMethod::update($creditCard->token, [ | |
'cardholderName' => 'New Holder', | |
'cvv' => '456', | |
- 'number' => Braintree_Test_CreditCardNumbers::$failsSandboxVerification['MasterCard'], | |
+ 'number' => Braintree\Test\CreditCardNumbers::$failsSandboxVerification['MasterCard'], | |
'expirationDate' => "06/2013", | |
- 'options' => array( | |
+ 'options' => [ | |
'verifyCard' => 'true' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$this->assertFalse($updateResult->success); | |
- $this->assertEquals(Braintree_Result_CreditCardVerification::PROCESSOR_DECLINED, $updateResult->creditCardVerification->status); | |
+ $this->assertEquals(Braintree\Result\CreditCardVerification::PROCESSOR_DECLINED, $updateResult->creditCardVerification->status); | |
$this->assertEquals(NULL, $updateResult->creditCardVerification->gatewayRejectionReason); | |
} | |
- function testUpdate_canUpdateTheBillingAddress() | |
+ public function testUpdate_canUpdateTheBillingAddress() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $creditCardResult = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $creditCardResult = Braintree\CreditCard::create([ | |
'cardholderName' => 'Original Holder', | |
'customerId' => $customer->id, | |
'cvv' => '123', | |
- 'number' => Braintree_Test_CreditCardNumbers::$visa, | |
+ 'number' => Braintree\Test\CreditCardNumbers::$visa, | |
'expirationDate' => '05/2012', | |
- 'billingAddress' => array( | |
+ 'billingAddress' => [ | |
'firstName' => 'Old First Name', | |
'lastName' => 'Old Last Name', | |
'company' => 'Old Company', | |
@@ -926,13 +990,13 @@ | |
'region' => 'Old State', | |
'postalCode' => '12345', | |
'countryName' => 'Canada' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$this->assertTrue($creditCardResult->success); | |
$creditCard = $creditCardResult->creditCard; | |
- $updateResult = Braintree_PaymentMethod::update($creditCard->token, array( | |
- 'billingAddress' => array( | |
+ $updateResult = Braintree\PaymentMethod::update($creditCard->token, [ | |
+ 'billingAddress' => [ | |
'firstName' => 'New First Name', | |
'lastName' => 'New Last Name', | |
'company' => 'New Company', | |
@@ -942,8 +1006,8 @@ | |
'region' => 'New State', | |
'postalCode' => '56789', | |
'countryName' => 'United States of America' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$this->assertTrue($updateResult->success); | |
$address = $updateResult->paymentMethod->billingAddress; | |
@@ -958,46 +1022,46 @@ | |
$this->assertSame('United States of America', $address->countryName); | |
} | |
- function testUpdate_returnsAnErrorIfInvalid() | |
+ public function testUpdate_returnsAnErrorIfInvalid() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $creditCardResult = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $creditCardResult = Braintree\CreditCard::create([ | |
'cardholderName' => 'Original Holder', | |
'customerId' => $customer->id, | |
- 'number' => Braintree_Test_CreditCardNumbers::$visa, | |
+ 'number' => Braintree\Test\CreditCardNumbers::$visa, | |
'expirationDate' => "05/2012" | |
- )); | |
+ ]); | |
$this->assertTrue($creditCardResult->success); | |
$creditCard = $creditCardResult->creditCard; | |
- $updateResult = Braintree_PaymentMethod::update($creditCard->token, array( | |
+ $updateResult = Braintree\PaymentMethod::update($creditCard->token, [ | |
'cardholderName' => 'New Holder', | |
'number' => 'invalid', | |
'expirationDate' => "05/2014", | |
- )); | |
+ ]); | |
$this->assertFalse($updateResult->success); | |
$numberErrors = $updateResult->errors->forKey('creditCard')->onAttribute('number'); | |
$this->assertEquals("Credit card number must be 12-19 digits.", $numberErrors[0]->message); | |
} | |
- function testUpdate_canUpdateTheDefault() | |
+ public function testUpdate_canUpdateTheDefault() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
+ $customer = Braintree\Customer::createNoValidate(); | |
- $creditCardResult1 = Braintree_CreditCard::create(array( | |
+ $creditCardResult1 = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
- 'number' => Braintree_Test_CreditCardNumbers::$visa, | |
+ 'number' => Braintree\Test\CreditCardNumbers::$visa, | |
'expirationDate' => "05/2009" | |
- )); | |
+ ]); | |
$this->assertTrue($creditCardResult1->success); | |
$creditCard1 = $creditCardResult1->creditCard; | |
- $creditCardResult2 = Braintree_CreditCard::create(array( | |
+ $creditCardResult2 = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
- 'number' => Braintree_Test_CreditCardNumbers::$visa, | |
+ 'number' => Braintree\Test\CreditCardNumbers::$visa, | |
'expirationDate' => "05/2009" | |
- )); | |
+ ]); | |
$this->assertTrue($creditCardResult2->success); | |
$creditCard2 = $creditCardResult2->creditCard; | |
@@ -1005,128 +1069,128 @@ | |
$this->assertFalse($creditCard2->default); | |
- $updateResult = Braintree_PaymentMethod::update($creditCard2->token, array( | |
- 'options' => array( | |
+ $updateResult = Braintree\PaymentMethod::update($creditCard2->token, [ | |
+ 'options' => [ | |
'makeDefault' => 'true' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$this->assertTrue($updateResult->success); | |
- $this->assertFalse(Braintree_PaymentMethod::find($creditCard1->token)->default); | |
- $this->assertTrue(Braintree_PaymentMethod::find($creditCard2->token)->default); | |
+ $this->assertFalse(Braintree\PaymentMethod::find($creditCard1->token)->default); | |
+ $this->assertTrue(Braintree\PaymentMethod::find($creditCard2->token)->default); | |
} | |
- function testUpdate_updatesAPaypalAccountsToken() | |
+ public function testUpdate_updatesAPaypalAccountsToken() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
+ $customer = Braintree\Customer::createNoValidate(); | |
$originalToken = 'paypal-account-' . strval(rand()); | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonceForPayPalAccount(array( | |
- 'paypal_account' => array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonceForPayPalAccount([ | |
+ 'paypal_account' => [ | |
'consent_code' => 'consent-code', | |
'token' => $originalToken | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
- $originalResult = Braintree_PaymentMethod::create(array( | |
+ $originalResult = Braintree\PaymentMethod::create([ | |
'paymentMethodNonce' => $nonce, | |
'customerId' => $customer->id | |
- )); | |
+ ]); | |
$this->assertTrue($originalResult->success); | |
$originalPaypalAccount = $originalResult->paymentMethod; | |
$updatedToken = 'UPDATED_TOKEN-' . strval(rand()); | |
- $updateResult = Braintree_PaymentMethod::update($originalPaypalAccount->token, array( | |
+ $updateResult = Braintree\PaymentMethod::update($originalPaypalAccount->token, [ | |
'token' => $updatedToken | |
- )); | |
+ ]); | |
$this->assertTrue($updateResult->success); | |
- $updatedPaypalAccount = Braintree_PaymentMethod::find($updatedToken); | |
+ $updatedPaypalAccount = Braintree\PaymentMethod::find($updatedToken); | |
$this->assertEquals($originalPaypalAccount->email, $updatedPaypalAccount->email); | |
- $this->setExpectedException('Braintree_Exception_NotFound', 'payment method with token ' . $originalToken . ' not found'); | |
- Braintree_PaymentMethod::find($originalToken); | |
+ $this->setExpectedException('Braintree\Exception\NotFound', 'payment method with token ' . $originalToken . ' not found'); | |
+ Braintree\PaymentMethod::find($originalToken); | |
} | |
- function testUpdate_canMakeAPaypalAccountTheDefaultPaymentMethod() | |
+ public function testUpdate_canMakeAPaypalAccountTheDefaultPaymentMethod() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $creditCardResult = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $creditCardResult = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
- 'number' => Braintree_Test_CreditCardNumbers::$visa, | |
- 'expirationDate' => "05/2009", | |
- 'options' => array( | |
+ 'number' => Braintree\Test\CreditCardNumbers::$visa, | |
+ 'expirationDate' => '05/2009', | |
+ 'options' => [ | |
'makeDefault' => 'true' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$this->assertTrue($creditCardResult->success); | |
$creditCard = $creditCardResult->creditCard; | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonceForPayPalAccount(array( | |
- 'paypal_account' => array( | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonceForPayPalAccount([ | |
+ 'paypal_account' => [ | |
'consent_code' => 'consent-code', | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
- $originalToken = Braintree_PaymentMethod::create(array( | |
+ $originalToken = Braintree\PaymentMethod::create([ | |
'paymentMethodNonce' => $nonce, | |
'customerId' => $customer->id | |
- ))->paymentMethod->token; | |
+ ])->paymentMethod->token; | |
- $updateResult = Braintree_PaymentMethod::update($originalToken, array( | |
- 'options' => array( | |
+ $updateResult = Braintree\PaymentMethod::update($originalToken, [ | |
+ 'options' => [ | |
'makeDefault' => 'true' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$this->assertTrue($updateResult->success); | |
- $updatedPaypalAccount = Braintree_PaymentMethod::find($originalToken); | |
+ $updatedPaypalAccount = Braintree\PaymentMethod::find($originalToken); | |
$this->assertTrue($updatedPaypalAccount->default); | |
} | |
- function testUpdate_returnsAnErrorIfATokenForAccountIsUsedToAttemptAnUpdate() | |
+ public function testUpdate_returnsAnErrorIfATokenForAccountIsUsedToAttemptAnUpdate() | |
{ | |
- $customer = Braintree_Customer::createNoValidate(); | |
+ $customer = Braintree\Customer::createNoValidate(); | |
$firstToken = 'paypal-account-' . strval(rand()); | |
$secondToken = 'paypal-account-' . strval(rand()); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $firstNonce = $http->nonceForPayPalAccount(array( | |
- 'paypal_account' => array( | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $firstNonce = $http->nonceForPayPalAccount([ | |
+ 'paypal_account' => [ | |
'consent_code' => 'consent-code', | |
'token' => $firstToken | |
- ) | |
- )); | |
- $firstResult = Braintree_PaymentMethod::create(array( | |
+ ] | |
+ ]); | |
+ $firstResult = Braintree\PaymentMethod::create([ | |
'paymentMethodNonce' => $firstNonce, | |
'customerId' => $customer->id | |
- )); | |
+ ]); | |
$this->assertTrue($firstResult->success); | |
$firstPaypalAccount = $firstResult->paymentMethod; | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $secondNonce = $http->nonceForPayPalAccount(array( | |
- 'paypal_account' => array( | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $secondNonce = $http->nonceForPayPalAccount([ | |
+ 'paypal_account' => [ | |
'consent_code' => 'consent-code', | |
'token' => $secondToken | |
- ) | |
- )); | |
- $secondResult = Braintree_PaymentMethod::create(array( | |
+ ] | |
+ ]); | |
+ $secondResult = Braintree\PaymentMethod::create([ | |
'paymentMethodNonce' => $secondNonce, | |
'customerId' => $customer->id | |
- )); | |
+ ]); | |
$this->assertTrue($secondResult->success); | |
$secondPaypalAccount = $firstResult->paymentMethod; | |
- $updateResult = Braintree_PaymentMethod::update($firstToken, array( | |
+ $updateResult = Braintree\PaymentMethod::update($firstToken, [ | |
'token' => $secondToken | |
- )); | |
+ ]); | |
$this->assertFalse($updateResult->success); | |
$resultErrors = $updateResult->errors->deepAll(); | |
@@ -1134,47 +1198,299 @@ | |
} | |
- function testDelete_worksWithCreditCards() | |
+ public function testDelete_worksWithCreditCards() | |
{ | |
$paymentMethodToken = 'CREDIT_CARD_TOKEN-' . strval(rand()); | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $creditCardResult = Braintree_CreditCard::create(array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $creditCardResult = Braintree\CreditCard::create([ | |
'customerId' => $customer->id, | |
'number' => '5105105105105100', | |
'expirationDate' => '05/2011', | |
'token' => $paymentMethodToken | |
- )); | |
+ ]); | |
$this->assertTrue($creditCardResult->success); | |
- Braintree_PaymentMethod::delete($paymentMethodToken); | |
+ Braintree\PaymentMethod::delete($paymentMethodToken); | |
- $this->setExpectedException('Braintree_Exception_NotFound'); | |
- Braintree_PaymentMethod::find($paymentMethodToken); | |
- integrationMerchantConfig(); | |
+ $this->setExpectedException('Braintree\Exception\NotFound'); | |
+ Braintree\PaymentMethod::find($paymentMethodToken); | |
+ self::integrationMerchantConfig(); | |
} | |
- function testDelete_worksWithPayPalAccounts() | |
+ public function testDelete_worksWithPayPalAccounts() | |
{ | |
$paymentMethodToken = 'PAYPAL_TOKEN-' . strval(rand()); | |
- $customer = Braintree_Customer::createNoValidate(); | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonceForPayPalAccount(array( | |
- 'paypal_account' => array( | |
+ $customer = Braintree\Customer::createNoValidate(); | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonceForPayPalAccount([ | |
+ 'paypal_account' => [ | |
'consent_code' => 'PAYPAL_CONSENT_CODE', | |
'token' => $paymentMethodToken | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
- $paypalAccountResult = Braintree_PaymentMethod::create(array( | |
+ $paypalAccountResult = Braintree\PaymentMethod::create([ | |
'customerId' => $customer->id, | |
'paymentMethodNonce' => $nonce | |
- )); | |
+ ]); | |
$this->assertTrue($paypalAccountResult->success); | |
- Braintree_PaymentMethod::delete($paymentMethodToken); | |
+ Braintree\PaymentMethod::delete($paymentMethodToken); | |
- $this->setExpectedException('Braintree_Exception_NotFound'); | |
- Braintree_PaymentMethod::find($paymentMethodToken); | |
+ $this->setExpectedException('Braintree\Exception\NotFound'); | |
+ Braintree\PaymentMethod::find($paymentMethodToken); | |
} | |
+ public function testGrant_returnsASingleUseNonce() | |
+ { | |
+ $partnerMerchantGateway = new Braintree\Gateway([ | |
+ 'environment' => 'development', | |
+ 'merchantId' => 'integration_merchant_public_id', | |
+ 'publicKey' => 'oauth_app_partner_user_public_key', | |
+ 'privateKey' => 'oauth_app_partner_user_private_key' | |
+ ]); | |
+ | |
+ $customer = $partnerMerchantGateway->customer()->create([ | |
+ 'firstName' => 'Joe', | |
+ 'lastName' => 'Brown' | |
+ ])->customer; | |
+ $creditCard = $partnerMerchantGateway->creditCard()->create([ | |
+ 'customerId' => $customer->id, | |
+ 'cardholderName' => 'Adam Davis', | |
+ 'number' => '4111111111111111', | |
+ 'expirationDate' => '05/2009' | |
+ ])->creditCard; | |
+ | |
+ $oauthAppGateway = new Braintree\Gateway([ | |
+ 'clientId' => 'client_id$development$integration_client_id', | |
+ 'clientSecret' => 'client_secret$development$integration_client_secret' | |
+ ]); | |
+ | |
+ $code = Test\Braintree\OAuthTestHelper::createGrant($oauthAppGateway, [ | |
+ 'merchant_public_id' => 'integration_merchant_id', | |
+ 'scope' => 'grant_payment_method' | |
+ ]); | |
+ | |
+ $credentials = $oauthAppGateway->oauth()->createTokenFromCode([ | |
+ 'code' => $code, | |
+ ]); | |
+ | |
+ $grantingGateway = new Braintree\Gateway([ | |
+ 'accessToken' => $credentials->accessToken | |
+ ]); | |
+ | |
+ $grantResult = $grantingGateway->paymentMethod()->grant($creditCard->token, false); | |
+ $this->assertTrue($grantResult->success); | |
+ | |
+ $result = Braintree\Transaction::sale([ | |
+ 'amount' => '100.00', | |
+ 'paymentMethodNonce' => $grantResult->paymentMethodNonce->nonce | |
+ ]); | |
+ $this->assertTrue($result->success); | |
+ | |
+ $secondResult = Braintree\Transaction::sale([ | |
+ 'amount' => '100.00', | |
+ 'paymentMethodNonce' => $grantResult->paymentMethodNonce->nonce | |
+ ]); | |
+ $this->assertFalse($secondResult->success); | |
+ } | |
+ | |
+ public function testGrant_returnsANonceThatIsNotVaultable() | |
+ { | |
+ $partnerMerchantGateway = new Braintree\Gateway([ | |
+ 'environment' => 'development', | |
+ 'merchantId' => 'integration_merchant_public_id', | |
+ 'publicKey' => 'oauth_app_partner_user_public_key', | |
+ 'privateKey' => 'oauth_app_partner_user_private_key' | |
+ ]); | |
+ | |
+ $customer = $partnerMerchantGateway->customer()->create([ | |
+ 'firstName' => 'Joe', | |
+ 'lastName' => 'Brown' | |
+ ])->customer; | |
+ $creditCard = $partnerMerchantGateway->creditCard()->create([ | |
+ 'customerId' => $customer->id, | |
+ 'cardholderName' => 'Adam Davis', | |
+ 'number' => '4111111111111111', | |
+ 'expirationDate' => '05/2009' | |
+ ])->creditCard; | |
+ | |
+ $oauthAppGateway = new Braintree\Gateway([ | |
+ 'clientId' => 'client_id$development$integration_client_id', | |
+ 'clientSecret' => 'client_secret$development$integration_client_secret' | |
+ ]); | |
+ | |
+ $code = Test\Braintree\OAuthTestHelper::createGrant($oauthAppGateway, [ | |
+ 'merchant_public_id' => 'integration_merchant_id', | |
+ 'scope' => 'grant_payment_method' | |
+ ]); | |
+ | |
+ $credentials = $oauthAppGateway->oauth()->createTokenFromCode([ | |
+ 'code' => $code, | |
+ ]); | |
+ | |
+ $grantingGateway = new Braintree\Gateway([ | |
+ 'accessToken' => $credentials->accessToken | |
+ ]); | |
+ | |
+ $grantResult = $grantingGateway->paymentMethod()->grant($creditCard->token, false); | |
+ | |
+ $customer = $partnerMerchantGateway->customer()->create([ | |
+ 'firstName' => 'Bob', | |
+ 'lastName' => 'Rob' | |
+ ])->customer; | |
+ $result = Braintree\PaymentMethod::create([ | |
+ 'customerId' => $customer->id, | |
+ 'paymentMethodNonce' => $grantResult->paymentMethodNonce->nonce | |
+ ]); | |
+ $this->assertFalse($result->success); | |
+ } | |
+ | |
+ public function testGrant_returnsANonceThatIsVaultable() | |
+ { | |
+ $partnerMerchantGateway = new Braintree\Gateway([ | |
+ 'environment' => 'development', | |
+ 'merchantId' => 'integration_merchant_public_id', | |
+ 'publicKey' => 'oauth_app_partner_user_public_key', | |
+ 'privateKey' => 'oauth_app_partner_user_private_key' | |
+ ]); | |
+ | |
+ $customer = $partnerMerchantGateway->customer()->create([ | |
+ 'firstName' => 'Joe', | |
+ 'lastName' => 'Brown' | |
+ ])->customer; | |
+ $creditCard = $partnerMerchantGateway->creditCard()->create([ | |
+ 'customerId' => $customer->id, | |
+ 'cardholderName' => 'Adam Davis', | |
+ 'number' => '4111111111111111', | |
+ 'expirationDate' => '05/2009' | |
+ ])->creditCard; | |
+ | |
+ $oauthAppGateway = new Braintree\Gateway([ | |
+ 'clientId' => 'client_id$development$integration_client_id', | |
+ 'clientSecret' => 'client_secret$development$integration_client_secret' | |
+ ]); | |
+ | |
+ $code = Test\Braintree\OAuthTestHelper::createGrant($oauthAppGateway, [ | |
+ 'merchant_public_id' => 'integration_merchant_id', | |
+ 'scope' => 'grant_payment_method' | |
+ ]); | |
+ | |
+ $credentials = $oauthAppGateway->oauth()->createTokenFromCode([ | |
+ 'code' => $code, | |
+ ]); | |
+ | |
+ $grantingGateway = new Braintree\Gateway([ | |
+ 'accessToken' => $credentials->accessToken | |
+ ]); | |
+ | |
+ $grantResult = $grantingGateway->paymentMethod()->grant($creditCard->token, true); | |
+ | |
+ $customer = Braintree\Customer::create([ | |
+ 'firstName' => 'Bob', | |
+ 'lastName' => 'Rob' | |
+ ])->customer; | |
+ $result = Braintree\PaymentMethod::create([ | |
+ 'customerId' => $customer->id, | |
+ 'paymentMethodNonce' => $grantResult->paymentMethodNonce->nonce | |
+ ]); | |
+ $this->assertTrue($result->success); | |
+ } | |
+ | |
+ public function testGrant_raisesAnErrorIfTokenIsNotFound() | |
+ { | |
+ $oauthAppGateway = new Braintree\Gateway([ | |
+ 'clientId' => 'client_id$development$integration_client_id', | |
+ 'clientSecret' => 'client_secret$development$integration_client_secret' | |
+ ]); | |
+ | |
+ $code = Test\Braintree\OAuthTestHelper::createGrant($oauthAppGateway, [ | |
+ 'merchant_public_id' => 'integration_merchant_id', | |
+ 'scope' => 'grant_payment_method' | |
+ ]); | |
+ | |
+ $credentials = $oauthAppGateway->oauth()->createTokenFromCode([ | |
+ 'code' => $code, | |
+ ]); | |
+ | |
+ $grantingGateway = new Braintree\Gateway([ | |
+ 'accessToken' => $credentials->accessToken | |
+ ]); | |
+ | |
+ $this->setExpectedException('Braintree\Exception\NotFound'); | |
+ $grantResult = $grantingGateway->paymentMethod()->grant("not_a_real_token", false); | |
+ } | |
+ | |
+ public function testRevoke_rendersANonceUnusable() | |
+ { | |
+ $partnerMerchantGateway = new Braintree\Gateway([ | |
+ 'environment' => 'development', | |
+ 'merchantId' => 'integration_merchant_public_id', | |
+ 'publicKey' => 'oauth_app_partner_user_public_key', | |
+ 'privateKey' => 'oauth_app_partner_user_private_key' | |
+ ]); | |
+ | |
+ $customer = $partnerMerchantGateway->customer()->create([ | |
+ 'firstName' => 'Joe', | |
+ 'lastName' => 'Brown' | |
+ ])->customer; | |
+ $creditCard = $partnerMerchantGateway->creditCard()->create([ | |
+ 'customerId' => $customer->id, | |
+ 'cardholderName' => 'Adam Davis', | |
+ 'number' => '4111111111111111', | |
+ 'expirationDate' => '05/2009' | |
+ ])->creditCard; | |
+ | |
+ $oauthAppGateway = new Braintree\Gateway([ | |
+ 'clientId' => 'client_id$development$integration_client_id', | |
+ 'clientSecret' => 'client_secret$development$integration_client_secret' | |
+ ]); | |
+ | |
+ $code = Test\Braintree\OAuthTestHelper::createGrant($oauthAppGateway, [ | |
+ 'merchant_public_id' => 'integration_merchant_id', | |
+ 'scope' => 'grant_payment_method' | |
+ ]); | |
+ | |
+ $credentials = $oauthAppGateway->oauth()->createTokenFromCode([ | |
+ 'code' => $code, | |
+ ]); | |
+ | |
+ $grantingGateway = new Braintree\Gateway([ | |
+ 'accessToken' => $credentials->accessToken | |
+ ]); | |
+ | |
+ $grantResult = $grantingGateway->paymentMethod()->grant($creditCard->token, false); | |
+ $revokeResult = $grantingGateway->paymentMethod()->revoke($creditCard->token); | |
+ $this->assertTrue($revokeResult->success); | |
+ | |
+ $result = Braintree\Transaction::sale([ | |
+ 'amount' => '100.00', | |
+ 'paymentMethodNonce' => $grantResult->paymentMethodNonce->nonce | |
+ ]); | |
+ $this->assertFalse($result->success); | |
+ } | |
+ | |
+ public function testRevoke_raisesAnErrorIfTokenIsNotFound() | |
+ { | |
+ $oauthAppGateway = new Braintree\Gateway([ | |
+ 'clientId' => 'client_id$development$integration_client_id', | |
+ 'clientSecret' => 'client_secret$development$integration_client_secret' | |
+ ]); | |
+ | |
+ $code = Test\Braintree\OAuthTestHelper::createGrant($oauthAppGateway, [ | |
+ 'merchant_public_id' => 'integration_merchant_id', | |
+ 'scope' => 'grant_payment_method' | |
+ ]); | |
+ | |
+ $credentials = $oauthAppGateway->oauth()->createTokenFromCode([ | |
+ 'code' => $code, | |
+ ]); | |
+ | |
+ $grantingGateway = new Braintree\Gateway([ | |
+ 'accessToken' => $credentials->accessToken | |
+ ]); | |
+ | |
+ $this->setExpectedException('Braintree\Exception\NotFound'); | |
+ $grantResult = $grantingGateway->paymentMethod()->revoke("not_a_real_token"); | |
+ } | |
} | |
Index: braintree_sdk/tests/integration/PlanTest.php | |
=================================================================== | |
--- braintree_sdk/tests/integration/PlanTest.php (revision 1387260) | |
+++ braintree_sdk/tests/integration/PlanTest.php (working copy) | |
@@ -1,21 +1,27 @@ | |
<?php | |
-require_once realpath(dirname(__FILE__)) . '/../TestHelper.php'; | |
+namespace Test\Integration; | |
-class Braintree_PlanTest extends PHPUnit_Framework_TestCase | |
+require_once dirname(__DIR__) . '/Setup.php'; | |
+ | |
+use Test\Setup; | |
+use Test\Helper; | |
+use Braintree; | |
+ | |
+class PlanTest extends Setup | |
{ | |
- function testAll_withNoPlans_returnsEmptyArray() | |
+ public function testAll_withNoPlans_returnsEmptyArray() | |
{ | |
- testMerchantConfig(); | |
- $plans = Braintree_Plan::all(); | |
- $this->assertEquals($plans, array()); | |
- integrationMerchantConfig(); | |
+ Helper::testMerchantConfig(); | |
+ $plans = Braintree\Plan::all(); | |
+ $this->assertEquals($plans, []); | |
+ self::integrationMerchantConfig(); | |
} | |
- function testAll_returnsAllPlans() | |
+ public function testAll_returnsAllPlans() | |
{ | |
$newId = strval(rand()); | |
- $params = array ( | |
+ $params = [ | |
"id" => $newId, | |
"billingDayOfMonth" => "1", | |
"billingFrequency" => "1", | |
@@ -25,35 +31,35 @@ | |
"numberOfBillingCycles" => "1", | |
"price" => "1.00", | |
"trialPeriod" => "false" | |
- ); | |
+ ]; | |
- $http = new Braintree_Http(Braintree_Configuration::$global); | |
- $path = Braintree_Configuration::$global->merchantPath() . "/plans/create_plan_for_tests"; | |
- $http->post($path, array("plan" => $params)); | |
+ $http = new Braintree\Http(Braintree\Configuration::$global); | |
+ $path = Braintree\Configuration::$global->merchantPath() . '/plans/create_plan_for_tests'; | |
+ $http->post($path, ["plan" => $params]); | |
- $addOnParams = array ( | |
+ $addOnParams = [ | |
"kind" => "add_on", | |
"plan_id" => $newId, | |
"amount" => "1.00", | |
"name" => "add_on_name" | |
- ); | |
+ ]; | |
- $http = new Braintree_Http(Braintree_Configuration::$global); | |
- $path = Braintree_Configuration::$global->merchantPath() . "/modifications/create_modification_for_tests"; | |
- $http->post($path, array("modification" => $addOnParams)); | |
+ $http = new Braintree\Http(Braintree\Configuration::$global); | |
+ $path = Braintree\Configuration::$global->merchantPath() . '/modifications/create_modification_for_tests'; | |
+ $http->post($path, ['modification' => $addOnParams]); | |
- $discountParams = array ( | |
+ $discountParams = [ | |
"kind" => "discount", | |
"plan_id" => $newId, | |
"amount" => "1.00", | |
"name" => "discount_name" | |
- ); | |
+ ]; | |
- $http = new Braintree_Http(Braintree_Configuration::$global); | |
- $path = Braintree_Configuration::$global->merchantPath() . "/modifications/create_modification_for_tests"; | |
- $http->post($path, array("modification" => $discountParams)); | |
+ $http = new Braintree\Http(Braintree\Configuration::$global); | |
+ $path = Braintree\Configuration::$global->merchantPath() . '/modifications/create_modification_for_tests'; | |
+ $http->post($path, ["modification" => $discountParams]); | |
- $plans = Braintree_Plan::all(); | |
+ $plans = Braintree\Plan::all(); | |
foreach ($plans as $plan) | |
{ | |
@@ -79,10 +85,10 @@ | |
$this->assertEquals($discountParams["name"], $discount->name); | |
} | |
- function testGatewayAll_returnsAllPlans() | |
+ public function testGatewayAll_returnsAllPlans() | |
{ | |
$newId = strval(rand()); | |
- $params = array ( | |
+ $params = [ | |
"id" => $newId, | |
"billingDayOfMonth" => "1", | |
"billingFrequency" => "1", | |
@@ -92,18 +98,18 @@ | |
"numberOfBillingCycles" => "1", | |
"price" => "1.00", | |
"trialPeriod" => "false" | |
- ); | |
+ ]; | |
- $http = new Braintree_Http(Braintree_Configuration::$global); | |
- $path = Braintree_Configuration::$global->merchantPath() . "/plans/create_plan_for_tests"; | |
- $http->post($path, array("plan" => $params)); | |
+ $http = new Braintree\Http(Braintree\Configuration::$global); | |
+ $path = Braintree\Configuration::$global->merchantPath() . '/plans/create_plan_for_tests'; | |
+ $http->post($path, ["plan" => $params]); | |
- $gateway = new Braintree_Gateway(array( | |
+ $gateway = new Braintree\Gateway([ | |
'environment' => 'development', | |
'merchantId' => 'integration_merchant_id', | |
'publicKey' => 'integration_public_key', | |
'privateKey' => 'integration_private_key' | |
- )); | |
+ ]); | |
$plans = $gateway->plan()->all(); | |
foreach ($plans as $plan) | |
Index: braintree_sdk/tests/integration/Result/ErrorTest.php | |
=================================================================== | |
--- braintree_sdk/tests/integration/Result/ErrorTest.php (revision 1387260) | |
+++ braintree_sdk/tests/integration/Result/ErrorTest.php (working copy) | |
@@ -1,23 +1,28 @@ | |
<?php | |
-require_once realpath(dirname(__FILE__)) . '/../../TestHelper.php'; | |
+namespace Test\Integration\Result; | |
-class Braintree_Result_ErrorTest extends PHPUnit_Framework_TestCase | |
+require_once dirname(dirname(__DIR__)) . '/Setup.php'; | |
+ | |
+use Test\Setup; | |
+use Braintree; | |
+ | |
+class ErrorTest extends Setup | |
{ | |
- function testValueForHtmlField() | |
+ public function testValueForHtmlField() | |
{ | |
- $result = Braintree_Customer::create(array( | |
+ $result = Braintree\Customer::create([ | |
'email' => 'invalid-email', | |
- 'creditCard' => array( | |
+ 'creditCard' => [ | |
'number' => 'invalid-number', | |
'expirationDate' => 'invalid-exp', | |
- 'billingAddress' => array( | |
+ 'billingAddress' => [ | |
'countryName' => 'invalid-country' | |
- ) | |
- ), | |
- 'customFields' => array( | |
+ ] | |
+ ], | |
+ 'customFields' => [ | |
'store_me' => 'some custom value' | |
- ) | |
- )); | |
+ ] | |
+ ]); | |
$this->assertEquals(false, $result->success); | |
$this->assertEquals('invalid-email', $result->valueForHtmlField('customer[email]')); | |
$this->assertEquals('', $result->valueForHtmlField('customer[credit_card][number]')); | |
Index: braintree_sdk/tests/integration/SettlementBatchSummaryTest.php | |
=================================================================== | |
--- braintree_sdk/tests/integration/SettlementBatchSummaryTest.php (revision 1387260) | |
+++ braintree_sdk/tests/integration/SettlementBatchSummaryTest.php (working copy) | |
@@ -1,85 +1,92 @@ | |
<?php | |
-require_once realpath(dirname(__FILE__)) . '/../TestHelper.php'; | |
+namespace Test\Integration; | |
-class Braintree_SettlementBatchSummaryTest extends PHPUnit_Framework_TestCase | |
+require_once dirname(__DIR__) . '/Setup.php'; | |
+ | |
+use DateTime; | |
+use Test; | |
+use Test\Setup; | |
+use Braintree; | |
+ | |
+class SettlementBatchSummaryTest extends Setup | |
{ | |
- function isMasterCard($record) | |
+ public function isMasterCard($record) | |
{ | |
- return $record['cardType'] == Braintree_CreditCard::MASTER_CARD; | |
+ return $record['cardType'] == Braintree\CreditCard::MASTER_CARD; | |
} | |
- function testGenerate_returnsAnEmptyCollectionWhenThereIsNoData() | |
+ public function testGenerate_returnsAnEmptyCollectionWhenThereIsNoData() | |
{ | |
- $result = Braintree_SettlementBatchSummary::generate('2000-01-01'); | |
+ $result = Braintree\SettlementBatchSummary::generate('2000-01-01'); | |
$this->assertTrue($result->success); | |
$this->assertEquals(0, count($result->settlementBatchSummary->records)); | |
} | |
- function testGatewayGenerate_returnsAnEmptyCollectionWhenThereIsNoData() | |
+ public function testGatewayGenerate_returnsAnEmptyCollectionWhenThereIsNoData() | |
{ | |
- $gateway = new Braintree_Gateway(array( | |
+ $gateway = new Braintree\Gateway([ | |
'environment' => 'development', | |
'merchantId' => 'integration_merchant_id', | |
'publicKey' => 'integration_public_key', | |
'privateKey' => 'integration_private_key' | |
- )); | |
+ ]); | |
$result = $gateway->settlementBatchSummary()->generate('2000-01-01'); | |
$this->assertTrue($result->success); | |
$this->assertEquals(0, count($result->settlementBatchSummary->records)); | |
} | |
- function testGenerate_returnsAnErrorIfTheDateCanNotBeParsed() | |
+ public function testGenerate_returnsAnErrorIfTheDateCanNotBeParsed() | |
{ | |
- $result = Braintree_SettlementBatchSummary::generate('OMG NOT A DATE'); | |
+ $result = Braintree\SettlementBatchSummary::generate('OMG NOT A DATE'); | |
$this->assertFalse($result->success); | |
$errors = $result->errors->forKey('settlementBatchSummary')->onAttribute('settlementDate'); | |
- $this->assertEquals(Braintree_Error_Codes::SETTLEMENT_BATCH_SUMMARY_SETTLEMENT_DATE_IS_INVALID, $errors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::SETTLEMENT_BATCH_SUMMARY_SETTLEMENT_DATE_IS_INVALID, $errors[0]->code); | |
} | |
- function testGenerate_returnsTransactionsSettledOnAGivenDay() | |
+ public function testGenerate_returnsTransactionsSettledOnAGivenDay() | |
{ | |
- $transaction = Braintree_Transaction::saleNoValidate(array( | |
+ $transaction = Braintree\Transaction::saleNoValidate([ | |
'amount' => '100.00', | |
- 'creditCard' => array( | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- ), | |
- 'options' => array('submitForSettlement' => true) | |
- )); | |
- Braintree_Test_Transaction::settle($transaction->id); | |
+ ], | |
+ 'options' => ['submitForSettlement' => true] | |
+ ]); | |
+ Braintree\Test\Transaction::settle($transaction->id); | |
$today = new Datetime; | |
- $result = Braintree_SettlementBatchSummary::generate(Braintree_TestHelper::nowInEastern()); | |
+ $result = Braintree\SettlementBatchSummary::generate(Test\Helper::nowInEastern()); | |
$this->assertTrue($result->success); | |
$masterCardRecords = array_filter($result->settlementBatchSummary->records, 'self::isMasterCard'); | |
$masterCardKeys = array_keys($masterCardRecords); | |
$masterCardIndex = $masterCardKeys[0]; | |
$this->assertTrue(count($masterCardRecords) > 0); | |
- $this->assertEquals(Braintree_CreditCard::MASTER_CARD, $masterCardRecords[$masterCardIndex]['cardType']); | |
+ $this->assertEquals(Braintree\CreditCard::MASTER_CARD, $masterCardRecords[$masterCardIndex]['cardType']); | |
} | |
- function testGenerate_canBeGroupedByACustomField() | |
+ public function testGenerate_canBeGroupedByACustomField() | |
{ | |
- $transaction = Braintree_Transaction::saleNoValidate(array( | |
+ $transaction = Braintree\Transaction::saleNoValidate([ | |
'amount' => '100.00', | |
- 'creditCard' => array( | |
+ 'creditCard' => [ | |
'number' => '5105105105105100', | |
'expirationDate' => '05/12' | |
- ), | |
- 'customFields' => array( | |
+ ], | |
+ 'customFields' => [ | |
'store_me' => 'custom value' | |
- ), | |
- 'options' => array('submitForSettlement' => true) | |
- )); | |
+ ], | |
+ 'options' => ['submitForSettlement' => true] | |
+ ]); | |
- Braintree_Test_Transaction::settle($transaction->id); | |
+ Braintree\Test\Transaction::settle($transaction->id); | |
$today = new Datetime; | |
- $result = Braintree_SettlementBatchSummary::generate(Braintree_TestHelper::nowInEastern(), 'store_me'); | |
+ $result = Braintree\SettlementBatchSummary::generate(Test\Helper::nowInEastern(), 'store_me'); | |
$this->assertTrue($result->success); | |
$this->assertTrue(count($result->settlementBatchSummary->records) > 0); | |
Index: braintree_sdk/tests/integration/SubscriptionHelper.php | |
=================================================================== | |
--- braintree_sdk/tests/integration/SubscriptionHelper.php (revision 0) | |
+++ braintree_sdk/tests/integration/SubscriptionHelper.php (working copy) | |
@@ -0,0 +1,86 @@ | |
+<?php | |
+namespace Test\Integration; | |
+ | |
+use Braintree; | |
+ | |
+class SubscriptionHelper | |
+{ | |
+ public static function addOnDiscountPlan() | |
+ { | |
+ return [ | |
+ 'description' => "Plan for integration tests -- with add-ons and discounts", | |
+ 'id' => "integration_plan_with_add_ons_and_discounts", | |
+ 'price' => '9.99', | |
+ 'trial_period' => true, | |
+ 'trial_duration' => 2, | |
+ 'trial_duration_unit' => 'day' | |
+ ]; | |
+ } | |
+ | |
+ public static function billingDayOfMonthPlan() | |
+ { | |
+ return [ | |
+ 'description' => 'Plan for integration tests -- with billing day of month', | |
+ 'id' => 'integration_plan_with_billing_day_of_month', | |
+ 'numberOfBillingCycles' => 5, | |
+ 'price' => '8.88', | |
+ 'trial_period' => false | |
+ ]; | |
+ } | |
+ | |
+ public static function trialPlan() | |
+ { | |
+ return [ | |
+ 'description' => 'Plan for integration tests -- with trial', | |
+ 'id' => 'integration_trial_plan', | |
+ 'numberOfBillingCycles' => 12, | |
+ 'price' => '43.21', | |
+ 'trial_period' => true, | |
+ 'trial_duration' => 2, | |
+ 'trial_duration_unit' => 'day' | |
+ ]; | |
+ } | |
+ | |
+ public static function triallessPlan() | |
+ { | |
+ return [ | |
+ 'description' => 'Plan for integration tests -- without a trial', | |
+ 'id' => 'integration_trialless_plan', | |
+ 'numberOfBillingCycles' => 12, | |
+ 'price' => '12.34', | |
+ 'trial_period' => false | |
+ ]; | |
+ } | |
+ | |
+ public static function createCreditCard() | |
+ { | |
+ $customer = Braintree\Customer::createNoValidate([ | |
+ 'creditCard' => [ | |
+ 'number' => '5105105105105100', | |
+ 'expirationDate' => '05/2010' | |
+ ] | |
+ ]); | |
+ return $customer->creditCards[0]; | |
+ } | |
+ | |
+ public static function createSubscription() | |
+ { | |
+ $plan = self::triallessPlan(); | |
+ $result = Braintree\Subscription::create([ | |
+ 'paymentMethodToken' => self::createCreditCard()->token, | |
+ 'price' => '54.99', | |
+ 'planId' => $plan['id'] | |
+ ]); | |
+ return $result->subscription; | |
+ } | |
+ | |
+ public static function compareModificationsById($left, $right) | |
+ { | |
+ return strcmp($left->id, $right->id); | |
+ } | |
+ | |
+ public static function sortModificationsById(&$modifications) | |
+ { | |
+ usort($modifications, ['Test\Integration\SubscriptionHelper', 'compareModificationsById']); | |
+ } | |
+} | |
Index: braintree_sdk/tests/integration/SubscriptionSearchTest.php | |
=================================================================== | |
--- braintree_sdk/tests/integration/SubscriptionSearchTest.php (revision 1387260) | |
+++ braintree_sdk/tests/integration/SubscriptionSearchTest.php (working copy) | |
@@ -1,44 +1,50 @@ | |
<?php | |
-require_once realpath(dirname(__FILE__)) . '/../TestHelper.php'; | |
-require_once realpath(dirname(__FILE__)) . '/SubscriptionTestHelper.php'; | |
+namespace Test\Integration; | |
-class Braintree_SubscriptionSearchTest extends PHPUnit_Framework_TestCase | |
+require_once dirname(__DIR__) . '/Setup.php'; | |
+ | |
+use DateTime; | |
+use Test; | |
+use Test\Setup; | |
+use Braintree; | |
+ | |
+class SubscriptionSearchTest extends Setup | |
{ | |
- function testSearch_planIdIs() | |
+ public function testSearch_planIdIs() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $triallessPlan = Braintree_SubscriptionTestHelper::triallessPlan(); | |
- $trialPlan = Braintree_SubscriptionTestHelper::trialPlan(); | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $triallessPlan = SubscriptionHelper::triallessPlan(); | |
+ $trialPlan = SubscriptionHelper::trialPlan(); | |
- $trialSubscription = Braintree_Subscription::create(array( | |
+ $trialSubscription = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $trialPlan['id'], | |
'price' => '1' | |
- ))->subscription; | |
+ ])->subscription; | |
- $triallessSubscription = Braintree_Subscription::create(array( | |
+ $triallessSubscription = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $triallessPlan['id'], | |
'price' => '1' | |
- ))->subscription; | |
+ ])->subscription; | |
- $collection = Braintree_Subscription::search(array( | |
- Braintree_SubscriptionSearch::planId()->is('integration_trial_plan'), | |
- Braintree_SubscriptionSearch::price()->is('1') | |
- )); | |
+ $collection = Braintree\Subscription::search([ | |
+ Braintree\SubscriptionSearch::planId()->is('integration_trial_plan'), | |
+ Braintree\SubscriptionSearch::price()->is('1') | |
+ ]); | |
- $this->assertTrue(Braintree_TestHelper::includes($collection, $trialSubscription)); | |
- $this->assertFalse(Braintree_TestHelper::includes($collection, $triallessSubscription)); | |
+ $this->assertTrue(Test\Helper::includes($collection, $trialSubscription)); | |
+ $this->assertFalse(Test\Helper::includes($collection, $triallessSubscription)); | |
} | |
- function test_noRequestsWhenIterating() | |
+ public function test_noRequestsWhenIterating() | |
{ | |
$resultsReturned = false; | |
- $collection = Braintree_Subscription::search(array( | |
- Braintree_SubscriptionSearch::planId()->is('imaginary') | |
- )); | |
+ $collection = Braintree\Subscription::search([ | |
+ Braintree\SubscriptionSearch::planId()->is('imaginary') | |
+ ]); | |
- foreach($collection as $transaction) { | |
+ foreach ($collection as $transaction) { | |
$resultsReturned = true; | |
break; | |
} | |
@@ -47,204 +53,204 @@ | |
$this->assertEquals(false, $resultsReturned); | |
} | |
- function testSearch_inTrialPeriod() | |
+ public function testSearch_inTrialPeriod() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $triallessPlan = Braintree_SubscriptionTestHelper::triallessPlan(); | |
- $trialPlan = Braintree_SubscriptionTestHelper::trialPlan(); | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $triallessPlan = SubscriptionHelper::triallessPlan(); | |
+ $trialPlan = SubscriptionHelper::trialPlan(); | |
- $trialSubscription = Braintree_Subscription::create(array( | |
+ $trialSubscription = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $trialPlan['id'], | |
'price' => '1' | |
- ))->subscription; | |
+ ])->subscription; | |
- $triallessSubscription = Braintree_Subscription::create(array( | |
+ $triallessSubscription = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $triallessPlan['id'], | |
'price' => '1' | |
- ))->subscription; | |
+ ])->subscription; | |
- $subscriptions_in_trial = Braintree_Subscription::search(array( | |
- Braintree_SubscriptionSearch::inTrialPeriod()->is(true) | |
- )); | |
+ $subscriptions_in_trial = Braintree\Subscription::search([ | |
+ Braintree\SubscriptionSearch::inTrialPeriod()->is(true) | |
+ ]); | |
- $this->assertTrue(Braintree_TestHelper::includes($subscriptions_in_trial, $trialSubscription)); | |
- $this->assertFalse(Braintree_TestHelper::includes($subscriptions_in_trial, $triallessSubscription)); | |
+ $this->assertTrue(Test\Helper::includes($subscriptions_in_trial, $trialSubscription)); | |
+ $this->assertFalse(Test\Helper::includes($subscriptions_in_trial, $triallessSubscription)); | |
- $subscriptions_not_in_trial = Braintree_Subscription::search(array( | |
- Braintree_SubscriptionSearch::inTrialPeriod()->is(false) | |
- )); | |
+ $subscriptions_not_in_trial = Braintree\Subscription::search([ | |
+ Braintree\SubscriptionSearch::inTrialPeriod()->is(false) | |
+ ]); | |
- $this->assertTrue(Braintree_TestHelper::includes($subscriptions_not_in_trial, $triallessSubscription)); | |
- $this->assertFalse(Braintree_TestHelper::includes($subscriptions_not_in_trial, $trialSubscription)); | |
+ $this->assertTrue(Test\Helper::includes($subscriptions_not_in_trial, $triallessSubscription)); | |
+ $this->assertFalse(Test\Helper::includes($subscriptions_not_in_trial, $trialSubscription)); | |
} | |
- function testSearch_statusIsPastDue() | |
+ public function testSearch_statusIsPastDue() | |
{ | |
$found = false; | |
- $collection = Braintree_Subscription::search(array( | |
- Braintree_SubscriptionSearch::status()->in(array(Braintree_Subscription::PAST_DUE)) | |
- )); | |
+ $collection = Braintree\Subscription::search([ | |
+ Braintree\SubscriptionSearch::status()->in([Braintree\Subscription::PAST_DUE]) | |
+ ]); | |
foreach ($collection AS $item) { | |
$found = true; | |
- $this->assertEquals(Braintree_Subscription::PAST_DUE, $item->status); | |
+ $this->assertEquals(Braintree\Subscription::PAST_DUE, $item->status); | |
} | |
$this->assertTrue($found); | |
} | |
- function testSearch_statusIsExpired() | |
+ public function testSearch_statusIsExpired() | |
{ | |
$found = false; | |
- $collection = Braintree_Subscription::search(array( | |
- Braintree_SubscriptionSearch::status()->in(array(Braintree_Subscription::EXPIRED)) | |
- )); | |
- foreach ($collection AS $item) { | |
+ $collection = Braintree\Subscription::search([ | |
+ Braintree\SubscriptionSearch::status()->in([Braintree\Subscription::EXPIRED]) | |
+ ]); | |
+ foreach ($collection as $item) { | |
$found = true; | |
- $this->assertEquals(Braintree_Subscription::EXPIRED, $item->status); | |
+ $this->assertEquals(Braintree\Subscription::EXPIRED, $item->status); | |
} | |
$this->assertTrue($found); | |
} | |
- function testSearch_billingCyclesRemaing() | |
+ public function testSearch_billingCyclesRemaing() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $triallessPlan = Braintree_SubscriptionTestHelper::triallessPlan(); | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $triallessPlan = SubscriptionHelper::triallessPlan(); | |
- $subscription_4 = Braintree_Subscription::create(array( | |
+ $subscription_4 = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $triallessPlan['id'], | |
'numberOfBillingCycles' => 4 | |
- ))->subscription; | |
+ ])->subscription; | |
- $subscription_8 = Braintree_Subscription::create(array( | |
+ $subscription_8 = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $triallessPlan['id'], | |
'numberOfBillingCycles' => 8 | |
- ))->subscription; | |
+ ])->subscription; | |
- $subscription_10 = Braintree_Subscription::create(array( | |
+ $subscription_10 = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $triallessPlan['id'], | |
'numberOfBillingCycles' => 10 | |
- ))->subscription; | |
+ ])->subscription; | |
- $collection = Braintree_Subscription::search(array( | |
- Braintree_SubscriptionSearch::billingCyclesRemaining()->between(5, 10) | |
- )); | |
+ $collection = Braintree\Subscription::search([ | |
+ Braintree\SubscriptionSearch::billingCyclesRemaining()->between(5, 10) | |
+ ]); | |
- $this->assertFalse(Braintree_TestHelper::includes($collection, $subscription_4)); | |
- $this->assertTrue(Braintree_TestHelper::includes($collection, $subscription_8)); | |
- $this->assertTrue(Braintree_TestHelper::includes($collection, $subscription_10)); | |
+ $this->assertFalse(Test\Helper::includes($collection, $subscription_4)); | |
+ $this->assertTrue(Test\Helper::includes($collection, $subscription_8)); | |
+ $this->assertTrue(Test\Helper::includes($collection, $subscription_10)); | |
} | |
- function testSearch_subscriptionId() | |
+ public function testSearch_subscriptionId() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $triallessPlan = Braintree_SubscriptionTestHelper::triallessPlan(); | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $triallessPlan = SubscriptionHelper::triallessPlan(); | |
$rand_id = strval(rand()); | |
- $subscription_1 = Braintree_Subscription::create(array( | |
+ $subscription_1 = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $triallessPlan['id'], | |
'id' => 'subscription_123_id_' . $rand_id | |
- ))->subscription; | |
+ ])->subscription; | |
- $subscription_2 = Braintree_Subscription::create(array( | |
+ $subscription_2 = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $triallessPlan['id'], | |
'id' => 'subscription_23_id_' . $rand_id | |
- ))->subscription; | |
+ ])->subscription; | |
- $subscription_3 = Braintree_Subscription::create(array( | |
+ $subscription_3 = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $triallessPlan['id'], | |
'id' => 'subscription_3_id_' . $rand_id | |
- ))->subscription; | |
+ ])->subscription; | |
- $collection = Braintree_Subscription::search(array( | |
- Braintree_SubscriptionSearch::id()->contains("23_id_") | |
- )); | |
+ $collection = Braintree\Subscription::search([ | |
+ Braintree\SubscriptionSearch::id()->contains('23_id_') | |
+ ]); | |
- $this->assertTrue(Braintree_TestHelper::includes($collection, $subscription_1)); | |
- $this->assertTrue(Braintree_TestHelper::includes($collection, $subscription_2)); | |
- $this->assertFalse(Braintree_TestHelper::includes($collection, $subscription_3)); | |
+ $this->assertTrue(Test\Helper::includes($collection, $subscription_1)); | |
+ $this->assertTrue(Test\Helper::includes($collection, $subscription_2)); | |
+ $this->assertFalse(Test\Helper::includes($collection, $subscription_3)); | |
} | |
- function testSearch_merchantAccountId() | |
+ public function testSearch_merchantAccountId() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $triallessPlan = Braintree_SubscriptionTestHelper::triallessPlan(); | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $triallessPlan = SubscriptionHelper::triallessPlan(); | |
$rand_id = strval(rand()); | |
- $subscription_1 = Braintree_Subscription::create(array( | |
+ $subscription_1 = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $triallessPlan['id'], | |
'id' => strval(rand()) . '_subscription_' . $rand_id, | |
'price' => '2' | |
- ))->subscription; | |
+ ])->subscription; | |
- $subscription_2 = Braintree_Subscription::create(array( | |
+ $subscription_2 = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $triallessPlan['id'], | |
'id' => strval(rand()) . '_subscription_' . $rand_id, | |
- 'merchantAccountId' => Braintree_TestHelper::nonDefaultMerchantAccountId(), | |
+ 'merchantAccountId' => Test\Helper::nonDefaultMerchantAccountId(), | |
'price' => '2' | |
- ))->subscription; | |
+ ])->subscription; | |
- $collection = Braintree_Subscription::search(array( | |
- Braintree_SubscriptionSearch::id()->endsWith('subscription_' . $rand_id), | |
- Braintree_SubscriptionSearch::merchantAccountId()->in(array(Braintree_TestHelper::nonDefaultMerchantAccountId())), | |
- Braintree_SubscriptionSearch::price()->is('2') | |
- )); | |
+ $collection = Braintree\Subscription::search([ | |
+ Braintree\SubscriptionSearch::id()->endsWith('subscription_' . $rand_id), | |
+ Braintree\SubscriptionSearch::merchantAccountId()->in([Test\Helper::nonDefaultMerchantAccountId()]), | |
+ Braintree\SubscriptionSearch::price()->is('2') | |
+ ]); | |
- $this->assertFalse(Braintree_TestHelper::includes($collection, $subscription_1)); | |
- $this->assertTrue(Braintree_TestHelper::includes($collection, $subscription_2)); | |
+ $this->assertFalse(Test\Helper::includes($collection, $subscription_1)); | |
+ $this->assertTrue(Test\Helper::includes($collection, $subscription_2)); | |
} | |
- function testSearch_bogusMerchantAccountId() | |
+ public function testSearch_bogusMerchantAccountId() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $triallessPlan = Braintree_SubscriptionTestHelper::triallessPlan(); | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $triallessPlan = SubscriptionHelper::triallessPlan(); | |
$rand_id = strval(rand()); | |
- $subscription = Braintree_Subscription::create(array( | |
+ $subscription = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $triallessPlan['id'], | |
'id' => strval(rand()) . '_subscription_' . $rand_id, | |
'price' => '11.38' | |
- ))->subscription; | |
+ ])->subscription; | |
- $collection = Braintree_Subscription::search(array( | |
- Braintree_SubscriptionSearch::id()->endsWith('subscription_' . $rand_id), | |
- Braintree_SubscriptionSearch::merchantAccountId()->in(array("bogus_merchant_account")), | |
- Braintree_SubscriptionSearch::price()->is('11.38') | |
- )); | |
+ $collection = Braintree\Subscription::search([ | |
+ Braintree\SubscriptionSearch::id()->endsWith('subscription_' . $rand_id), | |
+ Braintree\SubscriptionSearch::merchantAccountId()->in(['bogus_merchant_account']), | |
+ Braintree\SubscriptionSearch::price()->is('11.38') | |
+ ]); | |
- $this->assertFalse(Braintree_TestHelper::includes($collection, $subscription)); | |
+ $this->assertFalse(Test\Helper::includes($collection, $subscription)); | |
} | |
- function testSearch_daysPastDue() | |
+ public function testSearch_daysPastDue() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $triallessPlan = Braintree_SubscriptionTestHelper::triallessPlan(); | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $triallessPlan = SubscriptionHelper::triallessPlan(); | |
- $subscription = Braintree_Subscription::create(array( | |
+ $subscription = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $triallessPlan['id'] | |
- ))->subscription; | |
+ ])->subscription; | |
- $http = new Braintree_Http(Braintree_Configuration::$global); | |
- $path = Braintree_Configuration::$global->merchantPath() . '/subscriptions/' . $subscription->id . '/make_past_due'; | |
- $http->put($path, array('daysPastDue' => 5)); | |
+ $http = new Braintree\Http(Braintree\Configuration::$global); | |
+ $path = Braintree\Configuration::$global->merchantPath() . '/subscriptions/' . $subscription->id . '/make_past_due'; | |
+ $http->put($path, ['daysPastDue' => 5]); | |
$found = false; | |
- $collection = Braintree_Subscription::search(array( | |
- Braintree_SubscriptionSearch::daysPastDue()->between(2, 10) | |
- )); | |
+ $collection = Braintree\Subscription::search([ | |
+ Braintree\SubscriptionSearch::daysPastDue()->between(2, 10) | |
+ ]); | |
foreach ($collection AS $item) { | |
$found = true; | |
$this->assertTrue($item->daysPastDue <= 10); | |
@@ -253,85 +259,85 @@ | |
$this->assertTrue($found); | |
} | |
- function testSearch_price() | |
+ public function testSearch_price() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $triallessPlan = Braintree_SubscriptionTestHelper::triallessPlan(); | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $triallessPlan = SubscriptionHelper::triallessPlan(); | |
- $subscription_850 = Braintree_Subscription::create(array( | |
+ $subscription_850 = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $triallessPlan['id'], | |
'price' => '8.50' | |
- ))->subscription; | |
+ ])->subscription; | |
- $subscription_851 = Braintree_Subscription::create(array( | |
+ $subscription_851 = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $triallessPlan['id'], | |
'price' => '8.51' | |
- ))->subscription; | |
+ ])->subscription; | |
- $subscription_852 = Braintree_Subscription::create(array( | |
+ $subscription_852 = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $triallessPlan['id'], | |
'price' => '8.52' | |
- ))->subscription; | |
+ ])->subscription; | |
- $collection = Braintree_Subscription::search(array( | |
- Braintree_SubscriptionSearch::price()->between('8.51', '8.52') | |
- )); | |
+ $collection = Braintree\Subscription::search([ | |
+ Braintree\SubscriptionSearch::price()->between('8.51', '8.52') | |
+ ]); | |
- $this->assertTrue(Braintree_TestHelper::includes($collection, $subscription_851)); | |
- $this->assertTrue(Braintree_TestHelper::includes($collection, $subscription_852)); | |
- $this->assertFalse(Braintree_TestHelper::includes($collection, $subscription_850)); | |
+ $this->assertTrue(Test\Helper::includes($collection, $subscription_851)); | |
+ $this->assertTrue(Test\Helper::includes($collection, $subscription_852)); | |
+ $this->assertFalse(Test\Helper::includes($collection, $subscription_850)); | |
} | |
- function testSearch_nextBillingDate() | |
+ public function testSearch_nextBillingDate() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $triallessPlan = Braintree_SubscriptionTestHelper::triallessPlan(); | |
- $trialPlan = Braintree_SubscriptionTestHelper::trialPlan(); | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $triallessPlan = SubscriptionHelper::triallessPlan(); | |
+ $trialPlan = SubscriptionHelper::trialPlan(); | |
- $triallessSubscription = Braintree_Subscription::create(array( | |
+ $triallessSubscription = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $triallessPlan['id'], | |
- ))->subscription; | |
+ ])->subscription; | |
- $trialSubscription = Braintree_Subscription::create(array( | |
+ $trialSubscription = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $trialPlan['id'], | |
- ))->subscription; | |
+ ])->subscription; | |
$fiveDaysFromNow = new DateTime(); | |
$fiveDaysFromNow->modify("+5 days"); | |
- $collection = Braintree_Subscription::search(array( | |
- Braintree_SubscriptionSearch::nextBillingDate()->greaterThanOrEqualTo($fiveDaysFromNow) | |
- )); | |
+ $collection = Braintree\Subscription::search([ | |
+ Braintree\SubscriptionSearch::nextBillingDate()->greaterThanOrEqualTo($fiveDaysFromNow), | |
+ ]); | |
- $this->assertTrue(Braintree_TestHelper::includes($collection, $triallessSubscription)); | |
- $this->assertFalse(Braintree_TestHelper::includes($collection, $trialSubscription)); | |
+ $this->assertTrue(Test\Helper::includes($collection, $triallessSubscription)); | |
+ $this->assertFalse(Test\Helper::includes($collection, $trialSubscription)); | |
} | |
- function testSearch_transactionId() | |
+ public function testSearch_transactionId() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $triallessPlan = Braintree_SubscriptionTestHelper::triallessPlan(); | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $triallessPlan = SubscriptionHelper::triallessPlan(); | |
- $matchingSubscription = Braintree_Subscription::create(array( | |
+ $matchingSubscription = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $triallessPlan['id'], | |
- ))->subscription; | |
+ ])->subscription; | |
- $nonMatchingSubscription = Braintree_Subscription::create(array( | |
+ $nonMatchingSubscription = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $triallessPlan['id'], | |
- ))->subscription; | |
+ ])->subscription; | |
- $collection = Braintree_Subscription::search(array( | |
- Braintree_SubscriptionSearch::transactionId()->is($matchingSubscription->transactions[0]->id) | |
- )); | |
+ $collection = Braintree\Subscription::search([ | |
+ Braintree\SubscriptionSearch::transactionId()->is($matchingSubscription->transactions[0]->id), | |
+ ]); | |
- $this->assertTrue(Braintree_TestHelper::includes($collection, $matchingSubscription)); | |
- $this->assertFalse(Braintree_TestHelper::includes($collection, $nonMatchingSubscription)); | |
+ $this->assertTrue(Test\Helper::includes($collection, $matchingSubscription)); | |
+ $this->assertFalse(Test\Helper::includes($collection, $nonMatchingSubscription)); | |
} | |
} | |
Index: braintree_sdk/tests/integration/SubscriptionTest.php | |
=================================================================== | |
--- braintree_sdk/tests/integration/SubscriptionTest.php (revision 1387260) | |
+++ braintree_sdk/tests/integration/SubscriptionTest.php (working copy) | |
@@ -1,35 +1,40 @@ | |
<?php | |
-require_once realpath(dirname(__FILE__)) . '/../TestHelper.php'; | |
-require_once realpath(dirname(__FILE__)) . '/SubscriptionTestHelper.php'; | |
-require_once realpath(dirname(__FILE__)) . '/HttpClientApi.php'; | |
+namespace Test\Integration; | |
-class Braintree_SubscriptionTest extends PHPUnit_Framework_TestCase | |
+require_once dirname(__DIR__) . '/Setup.php'; | |
+ | |
+use DateTime; | |
+use Test; | |
+use Test\Setup; | |
+use Braintree; | |
+ | |
+class SubscriptionTest extends Setup | |
{ | |
- function testCreate_doesNotAcceptBadAttributes() | |
+ public function testCreate_doesNotAcceptBadAttributes() | |
{ | |
$this->setExpectedException('InvalidArgumentException', 'invalid keys: bad'); | |
- $result = Braintree_Subscription::create(array( | |
+ $result = Braintree\Subscription::create([ | |
'bad' => 'value' | |
- )); | |
+ ]); | |
} | |
- function testCreate_whenSuccessful() | |
+ public function testCreate_whenSuccessful() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $plan = Braintree_SubscriptionTestHelper::triallessPlan(); | |
- $result = Braintree_Subscription::create(array( | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $plan = SubscriptionHelper::triallessPlan(); | |
+ $result = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $plan['id'] | |
- )); | |
- Braintree_TestHelper::assertPrintable($result); | |
+ ]); | |
+ Test\Helper::assertPrintable($result); | |
$this->assertTrue($result->success); | |
$subscription = $result->subscription; | |
$this->assertEquals($creditCard->token, $subscription->paymentMethodToken); | |
$this->assertEquals(0, $subscription->failureCount); | |
$this->assertEquals($plan['id'], $subscription->planId); | |
- $this->assertEquals(Braintree_TestHelper::defaultMerchantAccountId(), $subscription->merchantAccountId); | |
- $this->assertEquals(Braintree_Subscription::ACTIVE, $subscription->status); | |
+ $this->assertEquals(Test\Helper::defaultMerchantAccountId(), $subscription->merchantAccountId); | |
+ $this->assertEquals(Braintree\Subscription::ACTIVE, $subscription->status); | |
$this->assertEquals('12.34', $subscription->nextBillAmount); | |
$this->assertEquals('12.34', $subscription->nextBillingPeriodAmount); | |
$this->assertEquals('0.00', $subscription->balance); | |
@@ -44,54 +49,54 @@ | |
$this->assertEquals('12.34', $subscription->statusHistory[0]->price); | |
$this->assertEquals('0.00', $subscription->statusHistory[0]->balance); | |
- $this->assertEquals(Braintree_Subscription::ACTIVE, $subscription->statusHistory[0]->status); | |
- $this->assertEquals(Braintree_Subscription::API, $subscription->statusHistory[0]->subscriptionSource); | |
+ $this->assertEquals(Braintree\Subscription::ACTIVE, $subscription->statusHistory[0]->status); | |
+ $this->assertEquals(Braintree\Subscription::API, $subscription->statusHistory[0]->subscriptionSource); | |
} | |
- function testGatewayCreate_whenSuccessful() | |
+ public function testGatewayCreate_whenSuccessful() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $plan = Braintree_SubscriptionTestHelper::triallessPlan(); | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $plan = SubscriptionHelper::triallessPlan(); | |
- $gateway = new Braintree_Gateway(array( | |
+ $gateway = new Braintree\Gateway([ | |
'environment' => 'development', | |
'merchantId' => 'integration_merchant_id', | |
'publicKey' => 'integration_public_key', | |
'privateKey' => 'integration_private_key' | |
- )); | |
- $result = $gateway->subscription()->create(array( | |
+ ]); | |
+ $result = $gateway->subscription()->create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $plan['id'] | |
- )); | |
- Braintree_TestHelper::assertPrintable($result); | |
+ ]); | |
+ Test\Helper::assertPrintable($result); | |
$this->assertTrue($result->success); | |
$subscription = $result->subscription; | |
$this->assertEquals($creditCard->token, $subscription->paymentMethodToken); | |
$this->assertEquals(0, $subscription->failureCount); | |
$this->assertEquals($plan['id'], $subscription->planId); | |
- $this->assertEquals(Braintree_TestHelper::defaultMerchantAccountId(), $subscription->merchantAccountId); | |
- $this->assertEquals(Braintree_Subscription::ACTIVE, $subscription->status); | |
+ $this->assertEquals(Test\Helper::defaultMerchantAccountId(), $subscription->merchantAccountId); | |
+ $this->assertEquals(Braintree\Subscription::ACTIVE, $subscription->status); | |
} | |
- function testCreate_withPaymentMethodNonce() | |
+ public function testCreate_withPaymentMethodNonce() | |
{ | |
- $customerId = Braintree_Customer::create()->customer->id; | |
- $http = new Braintree_HttpClientApi(Braintree_Configuration::$global); | |
- $nonce = $http->nonce_for_new_card(array( | |
- "creditCard" => array( | |
+ $customerId = Braintree\Customer::create()->customer->id; | |
+ $http = new HttpClientApi(Braintree\Configuration::$global); | |
+ $nonce = $http->nonce_for_new_card([ | |
+ "creditCard" => [ | |
"number" => "4111111111111111", | |
"expirationMonth" => "11", | |
"expirationYear" => "2099" | |
- ), | |
+ ], | |
"customerId" => $customerId, | |
"share" => true | |
- )); | |
- $plan = Braintree_SubscriptionTestHelper::triallessPlan(); | |
- $result = Braintree_Subscription::create(array( | |
+ ]); | |
+ $plan = SubscriptionHelper::triallessPlan(); | |
+ $result = Braintree\Subscription::create([ | |
'paymentMethodNonce' => $nonce, | |
'planId' => $plan['id'] | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
@@ -100,309 +105,309 @@ | |
$this->assertEquals("1111", $transaction->creditCardDetails->last4); | |
} | |
- function testCreate_returnsTransactionWhenTransactionFails() | |
+ public function testCreate_returnsTransactionWhenTransactionFails() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $plan = Braintree_SubscriptionTestHelper::triallessPlan(); | |
- $result = Braintree_Subscription::create(array( | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $plan = SubscriptionHelper::triallessPlan(); | |
+ $result = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $plan['id'], | |
- 'price' => Braintree_Test_TransactionAmounts::$decline | |
+ 'price' => Braintree\Test\TransactionAmounts::$decline | |
- )); | |
- Braintree_TestHelper::assertPrintable($result); | |
+ ]); | |
+ Test\Helper::assertPrintable($result); | |
$this->assertFalse($result->success); | |
- $this->assertEquals(Braintree_Transaction::PROCESSOR_DECLINED, $result->transaction->status); | |
+ $this->assertEquals(Braintree\Transaction::PROCESSOR_DECLINED, $result->transaction->status); | |
} | |
- function testCreate_canSetTheId() | |
+ public function testCreate_canSetTheId() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
$newId = strval(rand()); | |
- $plan = Braintree_SubscriptionTestHelper::triallessPlan(); | |
- $result = Braintree_Subscription::create(array( | |
+ $plan = SubscriptionHelper::triallessPlan(); | |
+ $result = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $plan['id'], | |
'id' => $newId | |
- )); | |
+ ]); | |
$this->assertTrue($result->success); | |
$subscription = $result->subscription; | |
$this->assertEquals($newId, $subscription->id); | |
} | |
- function testCreate_canSetTheMerchantAccountId() | |
+ public function testCreate_canSetTheMerchantAccountId() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $plan = Braintree_SubscriptionTestHelper::triallessPlan(); | |
- $result = Braintree_Subscription::create(array( | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $plan = SubscriptionHelper::triallessPlan(); | |
+ $result = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $plan['id'], | |
- 'merchantAccountId' => Braintree_TestHelper::nonDefaultMerchantAccountId() | |
- )); | |
+ 'merchantAccountId' => Test\Helper::nonDefaultMerchantAccountId() | |
+ ]); | |
$this->assertTrue($result->success); | |
$subscription = $result->subscription; | |
- $this->assertEquals(Braintree_TestHelper::nonDefaultMerchantAccountId(), $subscription->merchantAccountId); | |
+ $this->assertEquals(Test\Helper::nonDefaultMerchantAccountId(), $subscription->merchantAccountId); | |
} | |
- function testCreate_trialPeriodDefaultsToPlanWithoutTrial() | |
+ public function testCreate_trialPeriodDefaultsToPlanWithoutTrial() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $plan = Braintree_SubscriptionTestHelper::triallessPlan(); | |
- $result = Braintree_Subscription::create(array( | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $plan = SubscriptionHelper::triallessPlan(); | |
+ $result = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $plan['id'], | |
- )); | |
+ ]); | |
$subscription = $result->subscription; | |
$this->assertFalse($subscription->trialPeriod); | |
$this->assertNull($subscription->trialDuration); | |
$this->assertNull($subscription->trialDurationUnit); | |
} | |
- function testCreate_trialPeriondDefaultsToPlanWithTrial() | |
+ public function testCreate_trialPeriondDefaultsToPlanWithTrial() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $plan = Braintree_SubscriptionTestHelper::trialPlan(); | |
- $result = Braintree_Subscription::create(array( | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $plan = SubscriptionHelper::trialPlan(); | |
+ $result = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $plan['id'], | |
- )); | |
+ ]); | |
$subscription = $result->subscription; | |
$this->assertTrue($subscription->trialPeriod); | |
$this->assertEquals(2, $subscription->trialDuration); | |
$this->assertEquals('day', $subscription->trialDurationUnit); | |
} | |
- function testCreate_alterPlanTrialPeriod() | |
+ public function testCreate_alterPlanTrialPeriod() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $plan = Braintree_SubscriptionTestHelper::trialPlan(); | |
- $result = Braintree_Subscription::create(array( | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $plan = SubscriptionHelper::trialPlan(); | |
+ $result = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $plan['id'], | |
'trialDuration' => 5, | |
'trialDurationUnit' => 'month' | |
- )); | |
+ ]); | |
$subscription = $result->subscription; | |
$this->assertTrue($subscription->trialPeriod); | |
$this->assertEquals(5, $subscription->trialDuration); | |
$this->assertEquals('month', $subscription->trialDurationUnit); | |
} | |
- function testCreate_removePlanTrialPeriod() | |
+ public function testCreate_removePlanTrialPeriod() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $plan = Braintree_SubscriptionTestHelper::trialPlan(); | |
- $result = Braintree_Subscription::create(array( | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $plan = SubscriptionHelper::trialPlan(); | |
+ $result = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $plan['id'], | |
'trialPeriod' => false, | |
- )); | |
+ ]); | |
$subscription = $result->subscription; | |
$this->assertFalse($subscription->trialPeriod); | |
} | |
- function testCreate_createsATransactionIfNoTrialPeriod() | |
+ public function testCreate_createsATransactionIfNoTrialPeriod() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $plan = Braintree_SubscriptionTestHelper::triallessPlan(); | |
- $result = Braintree_Subscription::create(array( | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $plan = SubscriptionHelper::triallessPlan(); | |
+ $result = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $plan['id'], | |
- )); | |
+ ]); | |
$subscription = $result->subscription; | |
$this->assertEquals(1, sizeof($subscription->transactions)); | |
$transaction = $subscription->transactions[0]; | |
- $this->assertInstanceOf('Braintree_Transaction', $transaction); | |
+ $this->assertInstanceOf('Braintree\Transaction', $transaction); | |
$this->assertEquals($plan['price'], $transaction->amount); | |
- $this->assertEquals(Braintree_Transaction::SALE, $transaction->type); | |
+ $this->assertEquals(Braintree\Transaction::SALE, $transaction->type); | |
$this->assertEquals($subscription->id, $transaction->subscriptionId); | |
} | |
- function testCreate_doesNotCreateTransactionIfTrialPeriod() | |
+ public function testCreate_doesNotCreateTransactionIfTrialPeriod() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $plan = Braintree_SubscriptionTestHelper::trialPlan(); | |
- $result = Braintree_Subscription::create(array( | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $plan = SubscriptionHelper::trialPlan(); | |
+ $result = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $plan['id'], | |
- )); | |
+ ]); | |
$subscription = $result->subscription; | |
$this->assertEquals(0, sizeof($subscription->transactions)); | |
} | |
- function testCreate_returnsATransactionWithSubscriptionBillingPeriod() | |
+ public function testCreate_returnsATransactionWithSubscriptionBillingPeriod() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $plan = Braintree_SubscriptionTestHelper::triallessPlan(); | |
- $result = Braintree_Subscription::create(array( | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $plan = SubscriptionHelper::triallessPlan(); | |
+ $result = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $plan['id'], | |
- )); | |
+ ]); | |
$subscription = $result->subscription; | |
$transaction = $subscription->transactions[0]; | |
$this->assertEquals($subscription->billingPeriodStartDate, $transaction->subscriptionDetails->billingPeriodStartDate); | |
$this->assertEquals($subscription->billingPeriodEndDate, $transaction->subscriptionDetails->billingPeriodEndDate); | |
} | |
- function testCreate_priceCanBeOverriden() | |
+ public function testCreate_priceCanBeOverriden() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $plan = Braintree_SubscriptionTestHelper::trialPlan(); | |
- $result = Braintree_Subscription::create(array( | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $plan = SubscriptionHelper::trialPlan(); | |
+ $result = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $plan['id'], | |
'price' => '2.00' | |
- )); | |
+ ]); | |
$subscription = $result->subscription; | |
$this->assertEquals('2.00', $subscription->price); | |
} | |
- function testCreate_billingDayOfMonthIsInheritedFromPlan() | |
+ public function testCreate_billingDayOfMonthIsInheritedFromPlan() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $plan = Braintree_SubscriptionTestHelper::billingDayOfMonthPlan(); | |
- $result = Braintree_Subscription::create(array( | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $plan = SubscriptionHelper::billingDayOfMonthPlan(); | |
+ $result = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $plan['id'] | |
- )); | |
+ ]); | |
$subscription = $result->subscription; | |
$this->assertEquals(5, $subscription->billingDayOfMonth); | |
} | |
- function testCreate_billingDayOfMonthCanBeOverriden() | |
+ public function testCreate_billingDayOfMonthCanBeOverriden() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $plan = Braintree_SubscriptionTestHelper::billingDayOfMonthPlan(); | |
- $result = Braintree_Subscription::create(array( | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $plan = SubscriptionHelper::billingDayOfMonthPlan(); | |
+ $result = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $plan['id'], | |
'billingDayOfMonth' => 14 | |
- )); | |
+ ]); | |
$subscription = $result->subscription; | |
$this->assertEquals(14, $subscription->billingDayOfMonth); | |
} | |
- function testCreate_billingDayOfMonthCanBeOverridenWithStartImmediately() | |
+ public function testCreate_billingDayOfMonthCanBeOverridenWithStartImmediately() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $plan = Braintree_SubscriptionTestHelper::billingDayOfMonthPlan(); | |
- $result = Braintree_Subscription::create(array( | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $plan = SubscriptionHelper::billingDayOfMonthPlan(); | |
+ $result = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $plan['id'], | |
- 'options' => array('startImmediately' => true) | |
- )); | |
+ 'options' => ['startImmediately' => true] | |
+ ]); | |
$subscription = $result->subscription; | |
$this->assertEquals(1, sizeof($subscription->transactions)); | |
} | |
- function testCreate_firstBillingDateCanBeSet() | |
+ public function testCreate_firstBillingDateCanBeSet() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $plan = Braintree_SubscriptionTestHelper::billingDayOfMonthPlan(); | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $plan = SubscriptionHelper::billingDayOfMonthPlan(); | |
$tomorrow = new DateTime("now + 1 day"); | |
$tomorrow->setTime(0,0,0); | |
- $result = Braintree_Subscription::create(array( | |
+ $result = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $plan['id'], | |
'firstBillingDate' => $tomorrow | |
- )); | |
+ ]); | |
$subscription = $result->subscription; | |
$this->assertEquals($tomorrow, $subscription->firstBillingDate); | |
- $this->assertEquals(Braintree_Subscription::PENDING, $result->subscription->status); | |
+ $this->assertEquals(Braintree\Subscription::PENDING, $result->subscription->status); | |
} | |
- function testCreate_firstBillingDateInThePast() | |
+ public function testCreate_firstBillingDateInThePast() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $plan = Braintree_SubscriptionTestHelper::billingDayOfMonthPlan(); | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $plan = SubscriptionHelper::billingDayOfMonthPlan(); | |
$past = new DateTime("now - 3 days"); | |
$past->setTime(0,0,0); | |
- $result = Braintree_Subscription::create(array( | |
+ $result = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $plan['id'], | |
'firstBillingDate' => $past | |
- )); | |
+ ]); | |
$this->assertFalse($result->success); | |
$errors = $result->errors->forKey('subscription')->onAttribute('firstBillingDate'); | |
- $this->assertEquals(Braintree_Error_Codes::SUBSCRIPTION_FIRST_BILLING_DATE_CANNOT_BE_IN_THE_PAST, $errors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::SUBSCRIPTION_FIRST_BILLING_DATE_CANNOT_BE_IN_THE_PAST, $errors[0]->code); | |
} | |
- function testCreate_numberOfBillingCyclesCanBeOverridden() | |
+ public function testCreate_numberOfBillingCyclesCanBeOverridden() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $plan = Braintree_SubscriptionTestHelper::trialPlan(); | |
- $result = Braintree_Subscription::create(array( | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $plan = SubscriptionHelper::trialPlan(); | |
+ $result = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $plan['id'] | |
- )); | |
+ ]); | |
$subscription = $result->subscription; | |
$this->assertEquals($plan['numberOfBillingCycles'], $subscription->numberOfBillingCycles); | |
- $result = Braintree_Subscription::create(array( | |
+ $result = Braintree\Subscription::create([ | |
'numberOfBillingCycles' => '10', | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $plan['id'] | |
- )); | |
+ ]); | |
$subscription = $result->subscription; | |
$this->assertEquals(10, $subscription->numberOfBillingCycles); | |
$this->assertFalse($subscription->neverExpires); | |
} | |
- function testCreate_numberOfBillingCyclesCanBeOverriddenToNeverExpire() | |
+ public function testCreate_numberOfBillingCyclesCanBeOverriddenToNeverExpire() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $plan = Braintree_SubscriptionTestHelper::trialPlan(); | |
- $result = Braintree_Subscription::create(array( | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $plan = SubscriptionHelper::trialPlan(); | |
+ $result = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $plan['id'] | |
- )); | |
+ ]); | |
$subscription = $result->subscription; | |
$this->assertEquals($plan['numberOfBillingCycles'], $subscription->numberOfBillingCycles); | |
- $result = Braintree_Subscription::create(array( | |
+ $result = Braintree\Subscription::create([ | |
'neverExpires' => true, | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $plan['id'] | |
- )); | |
+ ]); | |
$subscription = $result->subscription; | |
$this->assertNull($subscription->numberOfBillingCycles); | |
$this->assertTrue($subscription->neverExpires); | |
} | |
- function testCreate_doesNotInheritAddOnsAndDiscountsWhenDoNotInheritAddOnsOrDiscountsIsSet() | |
+ public function testCreate_doesNotInheritAddOnsAndDiscountsWhenDoNotInheritAddOnsOrDiscountsIsSet() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $plan = Braintree_SubscriptionTestHelper::addOnDiscountPlan(); | |
- $result = Braintree_Subscription::create(array( | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $plan = SubscriptionHelper::addOnDiscountPlan(); | |
+ $result = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $plan['id'], | |
- 'options' => array('doNotInheritAddOnsOrDiscounts' => true) | |
- )); | |
+ 'options' => ['doNotInheritAddOnsOrDiscounts' => true] | |
+ ]); | |
$subscription = $result->subscription; | |
$this->assertEquals(0, sizeof($subscription->addOns)); | |
$this->assertEquals(0, sizeof($subscription->discounts)); | |
} | |
- function testCreate_inheritsAddOnsAndDiscountsFromPlanByDefault() | |
+ public function testCreate_inheritsAddOnsAndDiscountsFromPlanByDefault() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $plan = Braintree_SubscriptionTestHelper::addOnDiscountPlan(); | |
- $result = Braintree_Subscription::create(array( | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $plan = SubscriptionHelper::addOnDiscountPlan(); | |
+ $result = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $plan['id'], | |
- )); | |
+ ]); | |
$subscription = $result->subscription; | |
$this->assertEquals(2, sizeof($subscription->addOns)); | |
$addOns = $subscription->addOns; | |
- Braintree_SubscriptionTestHelper::sortModificationsById($addOns); | |
+ SubscriptionHelper::sortModificationsById($addOns); | |
$this->assertEquals($addOns[0]->amount, "10.00"); | |
$this->assertEquals($addOns[0]->quantity, 1); | |
@@ -418,7 +423,7 @@ | |
$this->assertEquals(2, sizeof($subscription->discounts)); | |
$discounts = $subscription->discounts; | |
- Braintree_SubscriptionTestHelper::sortModificationsById($discounts); | |
+ SubscriptionHelper::sortModificationsById($discounts); | |
$this->assertEquals($discounts[0]->amount, "11.00"); | |
$this->assertEquals($discounts[0]->quantity, 1); | |
@@ -433,44 +438,44 @@ | |
$this->assertEquals($discounts[1]->currentBillingCycle, 0); | |
} | |
- function testCreate_allowsOverridingInheritedAddOnsAndDiscounts() | |
+ public function testCreate_allowsOverridingInheritedAddOnsAndDiscounts() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $plan = Braintree_SubscriptionTestHelper::addOnDiscountPlan(); | |
- $result = Braintree_Subscription::create(array( | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $plan = SubscriptionHelper::addOnDiscountPlan(); | |
+ $result = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $plan['id'], | |
- 'addOns' => array( | |
- 'update' => array( | |
- array( | |
+ 'addOns' => [ | |
+ 'update' => [ | |
+ [ | |
'amount' => '50.00', | |
'existingId' => 'increase_10', | |
'quantity' => 2, | |
'numberOfBillingCycles' => 5 | |
- ), | |
- array( | |
+ ], | |
+ [ | |
'amount' => '60.00', | |
'existingId' => 'increase_20', | |
'quantity' => 4, | |
'numberOfBillingCycles' => 9 | |
- ) | |
- ), | |
- ), | |
- 'discounts' => array( | |
- 'update' => array( | |
- array( | |
+ ] | |
+ ], | |
+ ], | |
+ 'discounts' => [ | |
+ 'update' => [ | |
+ [ | |
'amount' => '15.00', | |
'existingId' => 'discount_7', | |
'quantity' => 2, | |
'neverExpires' => true | |
- ) | |
- ) | |
- ) | |
- )); | |
+ ] | |
+ ] | |
+ ] | |
+ ]); | |
$subscription = $result->subscription; | |
$this->assertEquals(2, sizeof($subscription->addOns)); | |
$addOns = $subscription->addOns; | |
- Braintree_SubscriptionTestHelper::sortModificationsById($addOns); | |
+ SubscriptionHelper::sortModificationsById($addOns); | |
$this->assertEquals($addOns[0]->amount, "50.00"); | |
$this->assertEquals($addOns[0]->quantity, 2); | |
@@ -486,7 +491,7 @@ | |
$this->assertEquals(2, sizeof($subscription->discounts)); | |
$discounts = $subscription->discounts; | |
- Braintree_SubscriptionTestHelper::sortModificationsById($discounts); | |
+ SubscriptionHelper::sortModificationsById($discounts); | |
$this->assertEquals($discounts[0]->amount, "11.00"); | |
$this->assertEquals($discounts[0]->quantity, 1); | |
@@ -501,20 +506,20 @@ | |
$this->assertEquals($discounts[1]->currentBillingCycle, 0); | |
} | |
- function testCreate_allowsRemovalOfInheritedAddOnsAndDiscounts() | |
+ public function testCreate_allowsRemovalOfInheritedAddOnsAndDiscounts() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $plan = Braintree_SubscriptionTestHelper::addOnDiscountPlan(); | |
- $result = Braintree_Subscription::create(array( | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $plan = SubscriptionHelper::addOnDiscountPlan(); | |
+ $result = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $plan['id'], | |
- 'addOns' => array( | |
- 'remove' => array('increase_10', 'increase_20') | |
- ), | |
- 'discounts' => array( | |
- 'remove' => array('discount_7') | |
- ) | |
- )); | |
+ 'addOns' => [ | |
+ 'remove' => ['increase_10', 'increase_20'] | |
+ ], | |
+ 'discounts' => [ | |
+ 'remove' => ['discount_7'] | |
+ ] | |
+ ]); | |
$subscription = $result->subscription; | |
$this->assertEquals(0, sizeof($subscription->addOns)); | |
@@ -527,39 +532,39 @@ | |
$this->assertEquals($subscription->discounts[0]->currentBillingCycle, 0); | |
} | |
- function testCreate_allowsAddingNewAddOnsAndDiscounts() | |
+ public function testCreate_allowsAddingNewAddOnsAndDiscounts() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $plan = Braintree_SubscriptionTestHelper::addOnDiscountPlan(); | |
- $result = Braintree_Subscription::create(array( | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $plan = SubscriptionHelper::addOnDiscountPlan(); | |
+ $result = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $plan['id'], | |
- 'addOns' => array( | |
- 'add' => array( | |
- array( | |
+ 'addOns' => [ | |
+ 'add' => [ | |
+ [ | |
'inheritedFromId' => 'increase_30', | |
'amount' => '35.00', | |
'neverExpires' => true, | |
'quantity' => 2 | |
- ), | |
- ), | |
- ), | |
- 'discounts' => array( | |
- 'add' => array( | |
- array( | |
+ ], | |
+ ], | |
+ ], | |
+ 'discounts' => [ | |
+ 'add' => [ | |
+ [ | |
'inheritedFromId' => 'discount_15', | |
'amount' => '15.50', | |
'numberOfBillingCycles' => 10, | |
'quantity' => 3 | |
- ) | |
- ) | |
- ) | |
- )); | |
+ ] | |
+ ] | |
+ ] | |
+ ]); | |
$subscription = $result->subscription; | |
$this->assertEquals(3, sizeof($subscription->addOns)); | |
$addOns = $subscription->addOns; | |
- Braintree_SubscriptionTestHelper::sortModificationsById($addOns); | |
+ SubscriptionHelper::sortModificationsById($addOns); | |
$this->assertEquals($addOns[0]->amount, "10.00"); | |
$this->assertEquals($addOns[1]->amount, "20.00"); | |
@@ -573,7 +578,7 @@ | |
$this->assertEquals(3, sizeof($subscription->discounts)); | |
$discounts = $subscription->discounts; | |
- Braintree_SubscriptionTestHelper::sortModificationsById($discounts); | |
+ SubscriptionHelper::sortModificationsById($discounts); | |
$this->assertEquals($discounts[0]->amount, "11.00"); | |
@@ -587,47 +592,47 @@ | |
$this->assertEquals($discounts[2]->amount, "7.00"); | |
} | |
- function testCreate_properlyParsesValidationErrorsForArrays() | |
+ public function testCreate_properlyParsesValidationErrorsForArrays() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $plan = Braintree_SubscriptionTestHelper::addOnDiscountPlan(); | |
- $result = Braintree_Subscription::create(array( | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $plan = SubscriptionHelper::addOnDiscountPlan(); | |
+ $result = Braintree\Subscription::create([ | |
'paymentMethodToken' => $creditCard->token, | |
'planId' => $plan['id'], | |
- 'addOns' => array( | |
- 'update' => array( | |
- array( | |
+ 'addOns' => [ | |
+ 'update' => [ | |
+ [ | |
'existingId' => 'increase_10', | |
'amount' => 'invalid', | |
- ), | |
- array( | |
+ ], | |
+ [ | |
'existingId' => 'increase_20', | |
'quantity' => -10, | |
- ) | |
- ) | |
- ) | |
- )); | |
+ ] | |
+ ] | |
+ ] | |
+ ]); | |
$this->assertFalse($result->success); | |
$errors = $result->errors->forKey('subscription')->forKey('addOns')->forKey('update')->forIndex(0)->onAttribute('amount'); | |
- $this->assertEquals(Braintree_Error_Codes::SUBSCRIPTION_MODIFICATION_AMOUNT_IS_INVALID, $errors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::SUBSCRIPTION_MODIFICATION_AMOUNT_IS_INVALID, $errors[0]->code); | |
$errors = $result->errors->forKey('subscription')->forKey('addOns')->forKey('update')->forIndex(1)->onAttribute('quantity'); | |
- $this->assertEquals(Braintree_Error_Codes::SUBSCRIPTION_MODIFICATION_QUANTITY_IS_INVALID, $errors[0]->code); | |
+ $this->assertEquals(Braintree\Error\Codes::SUBSCRIPTION_MODIFICATION_QUANTITY_IS_INVALID, $errors[0]->code); | |
} | |
- function testCreate_withDescriptor() | |
+ public function testCreate_withDescriptor() | |
{ | |
- $creditCard = Braintree_SubscriptionTestHelper::createCreditCard(); | |
- $plan = Braintree_SubscriptionTestHelper::triallessPlan(); | |
- $result = Braintree_Subscription::create(array( | |
+ $creditCard = SubscriptionHelper::createCreditCard(); | |
+ $plan = SubscriptionHelper::triallessPlan(); | |
+ $result = Braintree\Subscription::create([ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment