示例#1
0
 function testFind()
 {
     $customer = Braintree_Customer::createNoValidate();
     $result = Braintree_Address::create(array('customerId' => $customer->id, 'firstName' => 'Dan', 'lastName' => 'Smith', 'company' => 'Braintree', 'streetAddress' => '1 E Main St', 'extendedAddress' => 'Apt 1F', 'locality' => 'Chicago', 'region' => 'IL', 'postalCode' => '60622', 'countryName' => 'United States of America'));
     $this->assertTrue($result->success);
     $address = Braintree_Address::find($customer->id, $result->address->id);
     $this->assertEquals('Dan', $address->firstName);
     $this->assertEquals('Smith', $address->lastName);
     $this->assertEquals('Braintree', $address->company);
     $this->assertEquals('1 E Main St', $address->streetAddress);
     $this->assertEquals('Apt 1F', $address->extendedAddress);
     $this->assertEquals('Chicago', $address->locality);
     $this->assertEquals('IL', $address->region);
     $this->assertEquals('60622', $address->postalCode);
     $this->assertEquals('United States of America', $address->countryName);
 }
示例#2
0
 function testUpdate_withNewCreditCardAndExistingBillingAddress()
 {
     $customer = Braintree_Customer::create()->customer;
     $address = Braintree_Address::create(array('customerId' => $customer->id, 'firstName' => 'Dan'))->address;
     $result = Braintree_Customer::update($customer->id, array('creditCard' => array('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 testSale_withBillingAddressId()
 {
     $customer = Braintree_Customer::create(array('firstName' => 'Mike', 'creditCard' => array('cardholderName' => 'The Cardholder', 'number' => Braintree_Test_CreditCardNumbers::$visa, 'expirationDate' => '05/12')))->customer;
     $address = Braintree_Address::create(array('customerId' => $customer->id, 'streetAddress' => '123 Fake St.'))->address;
     $result = Braintree_Transaction::sale(array('amount' => '100.00', 'customerId' => $customer->id, 'billingAddressId' => $address->id));
     $this->assertTrue($result->success);
     $transaction = $result->transaction;
     $this->assertEquals('123 Fake St.', $transaction->billingDetails->streetAddress);
     $this->assertEquals($address->id, $transaction->billingDetails->id);
 }
 function testCreate_allowsPassingABillingAddressIdOutsideOfTheNonce()
 {
     $customer = Braintree_Customer::createNoValidate();
     $nonce = Braintree_HttpClientApi::nonce_for_new_card(array('credit_card' => array('number' => '4111111111111111', 'expirationMonth' => '12', 'expirationYear' => '2020', 'options' => array('validate' => false))));
     $address = Braintree_Address::create(array('customerId' => $customer->id, 'firstName' => 'Bobby', 'lastName' => 'Tables'))->address;
     $result = Braintree_PaymentMethod::create(array('paymentMethodNonce' => $nonce, 'customerId' => $customer->id, 'billingAddressId' => $address->id));
     $this->assertTrue($result->success);
     $this->assertTrue(is_a($result->paymentMethod, 'Braintree_CreditCard'));
     $token = $result->paymentMethod->token;
     $foundCreditCard = Braintree_CreditCard::find($token);
     $this->assertTrue(NULL != $foundCreditCard);
     $this->assertEquals('Bobby', $foundCreditCard->billingAddress->firstName);
     $this->assertEquals('Tables', $foundCreditCard->billingAddress->lastName);
 }
示例#5
0
 public function saveAddress()
 {
     $send_array = $this->options['billing'];
     if (isset($this->options['customerId'])) {
         $send_array['customerId'] = $this->options['customerId'];
     }
     $result = \Braintree_Address::create($send_array);
     if ($result->success) {
         return ['status' => true, 'result' => $result];
     } else {
         return ['status' => false, 'result' => $result];
     }
 }