You are here

function Braintree_TransactionTest::testSale_storeInVault in Commerce Braintree 7

File

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

Class

Braintree_TransactionTest

Code

function testSale_storeInVault() {
  $transaction = Braintree_Transaction::saleNoValidate(array(
    'amount' => '100.00',
    'creditCard' => array(
      'cardholderName' => 'Card Holder',
      'number' => '5105105105105100',
      'expirationDate' => '05/12',
    ),
    'customer' => array(
      'firstName' => 'Dan',
      'lastName' => 'Smith',
      'company' => 'Braintree Payment Solutions',
      'email' => 'dan@example.com',
      'phone' => '419-555-1234',
      'fax' => '419-555-1235',
      'website' => 'http://getbraintree.com',
    ),
    'options' => array(
      'storeInVault' => true,
    ),
  ));
  $this
    ->assertNotNull($transaction->creditCardDetails->token);
  $creditCard = $transaction
    ->vaultCreditCard();
  $this
    ->assertEquals('510510', $creditCard->bin);
  $this
    ->assertEquals('5100', $creditCard->last4);
  $this
    ->assertEquals('05/2012', $creditCard->expirationDate);
  $this
    ->assertEquals('Card Holder', $creditCard->cardholderName);
  $customer = $transaction
    ->vaultCustomer();
  $this
    ->assertEquals('Dan', $customer->firstName);
  $this
    ->assertEquals('Smith', $customer->lastName);
  $this
    ->assertEquals('Braintree Payment Solutions', $customer->company);
  $this
    ->assertEquals('dan@example.com', $customer->email);
  $this
    ->assertEquals('419-555-1234', $customer->phone);
  $this
    ->assertEquals('419-555-1235', $customer->fax);
  $this
    ->assertEquals('http://getbraintree.com', $customer->website);
}