You are here

function Braintree_TransactionTest::testSale in Commerce Braintree 7

File

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

Class

Braintree_TransactionTest

Code

function testSale() {
  $result = Braintree_Transaction::sale(array(
    'amount' => '100.00',
    'creditCard' => array(
      'cardholderName' => 'The Cardholder',
      'number' => '5105105105105100',
      'expirationDate' => '05/12',
    ),
  ));
  $this
    ->assertTrue($result->success);
  $transaction = $result->transaction;
  $this
    ->assertEquals(Braintree_Transaction::AUTHORIZED, $transaction->status);
  $this
    ->assertEquals(Braintree_Transaction::SALE, $transaction->type);
  $this
    ->assertEquals('100.00', $transaction->amount);
  $this
    ->assertNotNull($transaction->processorAuthorizationCode);
  $this
    ->assertEquals('510510', $transaction->creditCardDetails->bin);
  $this
    ->assertEquals('5100', $transaction->creditCardDetails->last4);
  $this
    ->assertEquals('The Cardholder', $transaction->creditCardDetails->cardholderName);
}