function Braintree_CustomerTest::testCreate_withCreditCardAndBillingAddress in Commerce Braintree 7
File
- braintree_php/
tests/ integration/ CustomerTest.php, line 225
Class
Code
function testCreate_withCreditCardAndBillingAddress() {
$result = Braintree_Customer::create(array(
'firstName' => 'Mike',
'lastName' => 'Jones',
'company' => 'Jones Co.',
'email' => 'mike.jones@example.com',
'phone' => '419.555.1234',
'fax' => '419.555.1235',
'website' => 'http://example.com',
'creditCard' => array(
'number' => '5105105105105100',
'expirationDate' => '05/12',
'cvv' => '123',
'cardholderName' => 'Mike Jones',
'billingAddress' => array(
'firstName' => 'Drew',
'lastName' => 'Smith',
'company' => 'Smith Co.',
'streetAddress' => '1 E Main St',
'extendedAddress' => 'Suite 101',
'locality' => 'Chicago',
'region' => 'IL',
'postalCode' => '60622',
'countryName' => 'United States of America',
),
),
));
Braintree_TestHelper::assertPrintable($result);
$this
->assertEquals(true, $result->success);
$customer = $result->customer;
$this
->assertEquals('Mike', $customer->firstName);
$this
->assertEquals('Jones', $customer->lastName);
$this
->assertEquals('Jones Co.', $customer->company);
$this
->assertEquals('mike.jones@example.com', $customer->email);
$this
->assertEquals('419.555.1234', $customer->phone);
$this
->assertEquals('419.555.1235', $customer->fax);
$this
->assertEquals('http://example.com', $customer->website);
$creditCard = $customer->creditCards[0];
$this
->assertEquals('510510', $creditCard->bin);
$this
->assertEquals('5100', $creditCard->last4);
$this
->assertEquals('Mike Jones', $creditCard->cardholderName);
$this
->assertEquals('05/2012', $creditCard->expirationDate);
$this
->assertEquals('05', $creditCard->expirationMonth);
$this
->assertEquals('2012', $creditCard->expirationYear);
$address = $customer->addresses[0];
$this
->assertEquals($address, $creditCard->billingAddress);
$this
->assertEquals('Drew', $address->firstName);
$this
->assertEquals('Smith', $address->lastName);
$this
->assertEquals('Smith Co.', $address->company);
$this
->assertEquals('1 E Main St', $address->streetAddress);
$this
->assertEquals('Suite 101', $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);
}