You are here

function Braintree_TransactionTest::testSale_withExistingCustomer in Commerce Braintree 7

File

braintree_php/tests/integration/TransactionTest.php, line 466

Class

Braintree_TransactionTest

Code

function testSale_withExistingCustomer() {
  $customer = 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',
  ))->customer;
  $transaction = Braintree_Transaction::sale(array(
    'amount' => '100.00',
    'customerId' => $customer->id,
    'creditCard' => array(
      'cardholderName' => 'The Cardholder',
      'number' => Braintree_Test_CreditCardNumbers::$visa,
      'expirationDate' => '05/12',
    ),
  ))->transaction;
  $this
    ->assertEquals($transaction->creditCardDetails->maskedNumber, '401288******1881');
  $this
    ->assertNull($transaction
    ->vaultCreditCard());
}