function test_multipleValueNode_creditCardType()
 {
     $result = Braintree_Customer::create(array('creditCard' => array('cardholderName' => "Joe Smith", 'number' => "4000111111111115", 'expirationDate' => "12/2016", 'options' => array('verifyCard' => true))));
     $creditCardVerification = $result->creditCardVerification;
     $collection = Braintree_CreditCardVerification::search(array(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))));
     $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)));
     $this->assertEquals(0, $collection->maximumCount());
 }
 /**
  * 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);
     if (isset($creditCardAttribs['verifications']) && count($creditCardAttribs['verifications']) > 0) {
         $verifications = $creditCardAttribs['verifications'];
         usort($verifications, array($this, '_compareCreatedAtOnVerifications'));
         $this->_set('verification', Braintree_CreditCardVerification::factory($verifications[0]));
     }
 }
 function test_multipleValueNode_status()
 {
     $result = Braintree_Customer::create(array('creditCard' => array('cardholderName' => 'Joe Smith', 'number' => '4000111111111115', 'expirationDate' => '12/2016', 'options' => array('verifyCard' => true))));
     $creditCardVerification = $result->creditCardVerification;
     $collection = Braintree_CreditCardVerification::search(array(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))));
     $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)));
     $this->assertEquals(0, $collection->maximumCount());
 }
 public function a()
 {
     $result = Braintree_PaymentMethod::create(['customerId' => '28', 'paymentMethodNonce' => \Braintree\Test\Nonces::$transactable]);
     pr($result);
     die;
     $updateResult = Braintree_PaymentMethod::update('5ngfy6', ['paymentMethodNonce' => \Braintree\Test\Nonces::$transactable, 'options' => ['makeDefault' => true, 'verificationAmount' => '100000']]);
     pr($updateResult);
     $paymentMethod = Braintree_PaymentMethod::find('5ngfy6');
     pr($paymentMethod);
     die;
     //
     $result = Braintree_PaymentMethod::create(['customerId' => $id_user, 'paymentMethodNonce' => 'fake-valid-visa-nonce', 'options' => ['verificationMerchantAccountId' => 'm5ph2g77wgfzdyy2', 'verificationAmount' => '100000']]);
     pr($result);
     die;
     $result = Braintree_Transaction::sale(['amount' => '100.00', 'orderId' => 'order id', 'merchantAccountId' => 'm5ph2g77wgfzdyy2', 'paymentMethodNonce' => nonceFromTheClient, 'customer' => ['firstName' => 'Drew', 'lastName' => 'Smith', 'company' => 'Braintree', 'phone' => '312-555-1234', 'fax' => '312-555-1235', 'website' => 'http://www.example.com', 'email' => '*****@*****.**'], 'billing' => ['firstName' => 'Paul', 'lastName' => 'Smith', 'company' => 'Braintree', 'streetAddress' => '1 E Main St', 'extendedAddress' => 'Suite 403', 'locality' => 'Chicago', 'region' => 'IL', 'postalCode' => '60622', 'countryCodeAlpha2' => 'US'], 'shipping' => ['firstName' => 'Jen', 'lastName' => 'Smith', 'company' => 'Braintree', 'streetAddress' => '1 E 1st St', 'extendedAddress' => 'Suite 403', 'locality' => 'Bartlett', 'region' => 'IL', 'postalCode' => '60103', 'countryCodeAlpha2' => 'US'], 'options' => ['submitForSettlement' => true]]);
     pr($result);
     die;
     $result = Braintree_PaymentMethod::create(['customerId' => $id_user, 'paymentMethodNonce' => nonceFromTheClient, 'options' => ['makeDefault' => true]]);
     //        $result->paymentMethod->isDefault();
     pr($result);
     die;
     $collection = Braintree_CreditCardVerification::search([Braintree_CreditCardVerificationSearch::customerId()->is($id_user)]);
     pr($collection);
 }