Ejemplo n.º 1
0
 /**
  * @ignore
  */
 protected function _initialize($attributes)
 {
     $this->_attributes = $attributes;
     $addOnArray = array();
     if (isset($attributes['addOns'])) {
         foreach ($attributes['addOns'] as $addOn) {
             $addOnArray[] = Braintree_AddOn::factory($addOn);
         }
     }
     $this->_attributes['addOns'] = $addOnArray;
     $discountArray = array();
     if (isset($attributes['discounts'])) {
         foreach ($attributes['discounts'] as $discount) {
             $discountArray[] = Braintree_Discount::factory($discount);
         }
     }
     $this->_attributes['discounts'] = $discountArray;
     if (isset($attributes['descriptor'])) {
         $this->_set('descriptor', new Braintree_Descriptor($attributes['descriptor']));
     }
     $statusHistory = array();
     if (isset($attributes['statusHistory'])) {
         foreach ($attributes['statusHistory'] as $history) {
             $statusHistory[] = new Braintree_Subscription_StatusDetails($history);
         }
     }
     $this->_attributes['statusHistory'] = $statusHistory;
     $transactionArray = array();
     if (isset($attributes['transactions'])) {
         foreach ($attributes['transactions'] as $transaction) {
             $transactionArray[] = Braintree_Transaction::factory($transaction);
         }
     }
     $this->_attributes['transactions'] = $transactionArray;
 }
Ejemplo n.º 2
0
 protected function _initialize($attributes)
 {
     $this->_attributes = $attributes;
     $addOnArray = array();
     if (isset($attributes['addOns'])) {
         foreach ($attributes['addOns'] as $addOn) {
             $addOnArray[] = Braintree_AddOn::factory($addOn);
         }
     }
     $this->_attributes['addOns'] = $addOnArray;
     $discountArray = array();
     if (isset($attributes['discounts'])) {
         foreach ($attributes['discounts'] as $discount) {
             $discountArray[] = Braintree_Discount::factory($discount);
         }
     }
     $this->_attributes['discounts'] = $discountArray;
     $planArray = array();
     if (isset($attributes['plans'])) {
         foreach ($attributes['plans'] as $plan) {
             $planArray[] = Braintree_Plan::factory($plan);
         }
     }
     $this->_attributes['plans'] = $planArray;
 }
Ejemplo n.º 3
0
 function testAll_returnsAllAddOns()
 {
     $newId = strval(rand());
     $addOnParams = array("amount" => "100.00", "description" => "some description", "id" => $newId, "kind" => "add_on", "name" => "php_add_on", "neverExpires" => "false", "numberOfBillingCycles" => "1");
     Braintree_Http::post("/modifications/create_modification_for_tests", array("modification" => $addOnParams));
     $addOns = Braintree_AddOn::all();
     foreach ($addOns as $addOn) {
         if ($addOn->id == $newId) {
             $actualAddOn = $addOn;
         }
     }
     $this->assertNotNull($actualAddOn);
     $this->assertEquals($addOnParams["amount"], $actualAddOn->amount);
     $this->assertEquals($addOnParams["description"], $actualAddOn->description);
     $this->assertEquals($addOnParams["id"], $actualAddOn->id);
     $this->assertEquals($addOnParams["kind"], $actualAddOn->kind);
     $this->assertEquals($addOnParams["name"], $actualAddOn->name);
     $this->assertFalse($actualAddOn->neverExpires);
     $this->assertEquals($addOnParams["numberOfBillingCycles"], $actualAddOn->numberOfBillingCycles);
 }
Ejemplo n.º 4
0
 /**
  * sets instance properties from an array of values
  *
  * @ignore
  * @access protected
  * @param array $transactionAttribs array of transaction data
  * @return none
  */
 protected function _initialize($transactionAttribs)
 {
     $this->_attributes = $transactionAttribs;
     if (isset($transactionAttribs['creditCard'])) {
         $this->_set('creditCardDetails', new Braintree_Transaction_CreditCardDetails($transactionAttribs['creditCard']));
     }
     if (isset($transactionAttribs['customer'])) {
         $this->_set('customerDetails', new Braintree_Transaction_CustomerDetails($transactionAttribs['customer']));
     }
     if (isset($transactionAttribs['billing'])) {
         $this->_set('billingDetails', new Braintree_Transaction_AddressDetails($transactionAttribs['billing']));
     }
     if (isset($transactionAttribs['shipping'])) {
         $this->_set('shippingDetails', new Braintree_Transaction_AddressDetails($transactionAttribs['shipping']));
     }
     if (isset($transactionAttribs['subscription'])) {
         $this->_set('subscriptionDetails', new Braintree_Transaction_SubscriptionDetails($transactionAttribs['subscription']));
     }
     if (isset($transactionAttribs['descriptor'])) {
         $this->_set('descriptor', new Braintree_Descriptor($transactionAttribs['descriptor']));
     }
     if (isset($transactionAttribs['disbursementDetails'])) {
         $this->_set('disbursementDetails', new Braintree_DisbursementDetails($transactionAttribs['disbursementDetails']));
     }
     $statusHistory = array();
     if (isset($transactionAttribs['statusHistory'])) {
         foreach ($transactionAttribs['statusHistory'] as $history) {
             $statusHistory[] = new Braintree_Transaction_StatusDetails($history);
         }
     }
     $this->_set('statusHistory', $statusHistory);
     $addOnArray = array();
     if (isset($transactionAttribs['addOns'])) {
         foreach ($transactionAttribs['addOns'] as $addOn) {
             $addOnArray[] = Braintree_AddOn::factory($addOn);
         }
     }
     $this->_set('addOns', $addOnArray);
     $discountArray = array();
     if (isset($transactionAttribs['discounts'])) {
         foreach ($transactionAttribs['discounts'] as $discount) {
             $discountArray[] = Braintree_Discount::factory($discount);
         }
     }
     $this->_set('discounts', $discountArray);
 }
Ejemplo n.º 5
0
 /**
  * sets instance properties from an array of values
  *
  * @ignore
  * @access protected
  * @param array $transactionAttribs array of transaction data
  * @return none
  */
 protected function _initialize($transactionAttribs)
 {
     $this->_attributes = $transactionAttribs;
     if (isset($transactionAttribs['applePay'])) {
         $this->_set('applePayCardDetails', new Braintree_Transaction_ApplePayCardDetails($transactionAttribs['applePay']));
     }
     if (isset($transactionAttribs['creditCard'])) {
         $this->_set('creditCardDetails', new Braintree_Transaction_CreditCardDetails($transactionAttribs['creditCard']));
     }
     if (isset($transactionAttribs['coinbaseAccount'])) {
         $this->_set('coinbaseDetails', new Braintree_Transaction_CoinbaseDetails($transactionAttribs['coinbaseAccount']));
     }
     if (isset($transactionAttribs['paypal'])) {
         $this->_set('paypalDetails', new Braintree_Transaction_PayPalDetails($transactionAttribs['paypal']));
     }
     if (isset($transactionAttribs['customer'])) {
         $this->_set('customerDetails', new Braintree_Transaction_CustomerDetails($transactionAttribs['customer']));
     }
     if (isset($transactionAttribs['billing'])) {
         $this->_set('billingDetails', new Braintree_Transaction_AddressDetails($transactionAttribs['billing']));
     }
     if (isset($transactionAttribs['shipping'])) {
         $this->_set('shippingDetails', new Braintree_Transaction_AddressDetails($transactionAttribs['shipping']));
     }
     if (isset($transactionAttribs['subscription'])) {
         $this->_set('subscriptionDetails', new Braintree_Transaction_SubscriptionDetails($transactionAttribs['subscription']));
     }
     if (isset($transactionAttribs['descriptor'])) {
         $this->_set('descriptor', new Braintree_Descriptor($transactionAttribs['descriptor']));
     }
     if (isset($transactionAttribs['disbursementDetails'])) {
         $this->_set('disbursementDetails', new Braintree_DisbursementDetails($transactionAttribs['disbursementDetails']));
     }
     $disputes = array();
     if (isset($transactionAttribs['disputes'])) {
         foreach ($transactionAttribs['disputes'] as $dispute) {
             $disputes[] = Braintree_Dispute::factory($dispute);
         }
     }
     $this->_set('disputes', $disputes);
     $statusHistory = array();
     if (isset($transactionAttribs['statusHistory'])) {
         foreach ($transactionAttribs['statusHistory'] as $history) {
             $statusHistory[] = new Braintree_Transaction_StatusDetails($history);
         }
     }
     $this->_set('statusHistory', $statusHistory);
     $addOnArray = array();
     if (isset($transactionAttribs['addOns'])) {
         foreach ($transactionAttribs['addOns'] as $addOn) {
             $addOnArray[] = Braintree_AddOn::factory($addOn);
         }
     }
     $this->_set('addOns', $addOnArray);
     $discountArray = array();
     if (isset($transactionAttribs['discounts'])) {
         foreach ($transactionAttribs['discounts'] as $discount) {
             $discountArray[] = Braintree_Discount::factory($discount);
         }
     }
     $this->_set('discounts', $discountArray);
     if (isset($transactionAttribs['riskData'])) {
         $this->_set('riskData', Braintree_RiskData::factory($transactionAttribs['riskData']));
     }
     if (isset($transactionAttribs['threeDSecureInfo'])) {
         $this->_set('threeDSecureInfo', Braintree_ThreeDSecureInfo::factory($transactionAttribs['threeDSecureInfo']));
     }
 }
Ejemplo n.º 6
0
 function testToString()
 {
     $addOnParams = array("amount" => "100.00", "description" => "some description", "id" => "1", "kind" => "add_on", "name" => "php_add_on", "neverExpires" => "false", "numberOfBillingCycles" => "1");
     $addOn = \Braintree_AddOn::factory($addOnParams);
     $this->assertEquals("Braintree_AddOn[amount=100.00, description=some description, id=1, kind=add_on, name=php_add_on, neverExpires=false, numberOfBillingCycles=1]", (string) $addOn);
 }
Ejemplo n.º 7
0
 public function testFactory()
 {
     $addOn = \Braintree_AddOn::factory(array());
     $this->assertType('Braintree_AddOn', $addOn);
 }