Example #1
0
 /**
  * overrides default constructor
  * @ignore
  * @param array $response gateway response array
  */
 public function __construct($response)
 {
     $this->_attributes = $response;
     $this->_set('errors', new Braintree_Error_ErrorCollection($response['errors']));
     if (isset($response['verification'])) {
         $this->_set('creditCardVerification', new Braintree_Result_CreditCardVerification($response['verification']));
     } else {
         $this->_set('creditCardVerification', null);
     }
     if (isset($response['transaction'])) {
         $this->_set('transaction', Braintree_Transaction::factory($response['transaction']));
     } else {
         $this->_set('transaction', null);
     }
     if (isset($response['subscription'])) {
         $this->_set('subscription', Braintree_Subscription::factory($response['subscription']));
     } else {
         $this->_set('subscription', null);
     }
     if (isset($response['merchantAccount'])) {
         $this->_set('merchantAccount', Braintree_MerchantAccount::factory($response['merchantAccount']));
     } else {
         $this->_set('merchantAccount', null);
     }
 }
 protected function _initialize($attributes)
 {
     $this->_attributes = $attributes;
     if (isset($attributes['subject']['apiErrorResponse'])) {
         $wrapperNode = $attributes['subject']['apiErrorResponse'];
     } else {
         $wrapperNode = $attributes['subject'];
     }
     if (isset($wrapperNode['subscription'])) {
         $this->_set('subscription', Braintree_Subscription::factory($attributes['subject']['subscription']));
     }
     if (isset($wrapperNode['merchantAccount'])) {
         $this->_set('merchantAccount', Braintree_MerchantAccount::factory($wrapperNode['merchantAccount']));
     }
     if (isset($wrapperNode['transaction'])) {
         $this->_set('transaction', Braintree_Transaction::factory($wrapperNode['transaction']));
     }
     if (isset($wrapperNode['disbursement'])) {
         $this->_set('disbursement', Braintree_Disbursement::factory($wrapperNode['disbursement']));
     }
     if (isset($wrapperNode['partnerMerchant'])) {
         $this->_set('partnerMerchant', Braintree_PartnerMerchant::factory($wrapperNode['partnerMerchant']));
     }
     if (isset($wrapperNode['errors'])) {
         $this->_set('errors', new Braintree_Error_ValidationErrorCollection($wrapperNode['errors']));
         $this->_set('message', $wrapperNode['message']);
     }
 }
 protected function _initialize($attributes)
 {
     $this->_attributes = $attributes;
     if (isset($attributes['subject']) && isset($attributes['subject']['subscription'])) {
         $this->_set('subscription', Braintree_Subscription::factory($attributes['subject']['subscription']));
     }
 }
Example #4
0
 /**
  * sets instance properties from an array of values
  *
  * @access protected
  * @param array $paypalAccountAttribs array of paypalAccount data
  * @return none
  */
 protected function _initialize($paypalAccountAttribs)
 {
     // set the attributes
     $this->_attributes = $paypalAccountAttribs;
     $subscriptionArray = array();
     if (isset($paypalAccountAttribs['subscriptions'])) {
         foreach ($paypalAccountAttribs['subscriptions'] as $subscription) {
             $subscriptionArray[] = Braintree_Subscription::factory($subscription);
         }
     }
     $this->_set('subscriptions', $subscriptionArray);
 }
Example #5
0
 /**
  * sets instance properties from an array of values
  *
  * @access protected
  * @param array $applePayCardAttribs array of Apple Pay card properties
  * @return none
  */
 protected function _initialize($applePayCardAttribs)
 {
     // set the attributes
     $this->_attributes = $applePayCardAttribs;
     $subscriptionArray = array();
     if (isset($applePayCardAttribs['subscriptions'])) {
         foreach ($applePayCardAttribs['subscriptions'] as $subscription) {
             $subscriptionArray[] = Braintree_Subscription::factory($subscription);
         }
     }
     $this->_set('subscriptions', $subscriptionArray);
     $this->_set('expirationDate', $this->expirationMonth . '/' . $this->expirationYear);
 }
Example #6
0
 /**
  * sets instance properties from an array of values
  *
  * @access protected
  * @param array $creditCardAttribs array of creditcard data
  * @return none
  */
 protected function _initialize($creditCardAttribs)
 {
     // set the attributes
     $this->_attributes = $creditCardAttribs;
     // map each address into its own object
     $billingAddress = isset($creditCardAttribs['billingAddress']) ? Braintree_Address::factory($creditCardAttribs['billingAddress']) : null;
     $subscriptionArray = array();
     if (isset($creditCardAttribs['subscriptions'])) {
         foreach ($creditCardAttribs['subscriptions'] as $subscription) {
             $subscriptionArray[] = Braintree_Subscription::factory($subscription);
         }
     }
     $this->_set('subscriptions', $subscriptionArray);
     $this->_set('billingAddress', $billingAddress);
     $this->_set('expirationDate', $this->expirationMonth . '/' . $this->expirationYear);
     $this->_set('maskedNumber', $this->bin . '******' . $this->last4);
 }
 /**
  * @ignore
  */
 private function _verifyGatewayResponse($response)
 {
     if (isset($response['subscription'])) {
         return new Braintree_Result_Successful(Braintree_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']));
         } else {
             if (isset($response['apiErrorResponse'])) {
                 return new Braintree_Result_Error($response['apiErrorResponse']);
             } else {
                 throw new Braintree_Exception_Unexpected("Expected subscription, transaction, or apiErrorResponse");
             }
         }
     }
 }