public function testCreate_allowsPassingABillingAddressIdOutsideOfTheNonce()
 {
     $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' => ['validate' => false]]]);
     $address = Braintree\Address::create(['customerId' => $customer->id, 'firstName' => 'Bobby', 'lastName' => 'Tables'])->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'));
     $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);
 }
Esempio n. 2
0
 public function testFind()
 {
     $customer = Braintree\Customer::createNoValidate();
     $result = Braintree\Address::create(['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);
 }
Esempio n. 3
0
 public function testUpdate_withNewCreditCardAndExistingBillingAddress()
 {
     $customer = Braintree\Customer::create()->customer;
     $address = Braintree\Address::create(['customerId' => $customer->id, 'firstName' => 'Dan'])->address;
     $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);
 }
Esempio n. 4
0
 public function saveAddress()
 {
     $sendArray = $this->options['billing'];
     if (isset($this->options['customerId'])) {
         $sendArray['customerId'] = $this->options['customerId'];
     }
     $result = Address::create($sendArray);
     if ($result->success) {
         return ['status' => true, 'result' => $result];
     } else {
         return ['status' => false, 'result' => $result];
     }
 }
 public function testSale_withBillingAddressId()
 {
     $customer = Braintree\Customer::create(['firstName' => 'Mike', 'creditCard' => ['cardholderName' => 'The Cardholder', 'number' => Braintree\Test\CreditCardNumbers::$visa, 'expirationDate' => '05/12']])->customer;
     $address = Braintree\Address::create(['customerId' => $customer->id, 'streetAddress' => '123 Fake St.'])->address;
     $result = Braintree\Transaction::sale(['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);
 }