You are here

function Braintree_CreditCardTest::testCredit_createsACreditUsingGivenToken in Commerce Braintree 7

File

braintree_php/tests/integration/CreditCardTest.php, line 468

Class

Braintree_CreditCardTest

Code

function testCredit_createsACreditUsingGivenToken() {
  $customer = Braintree_Customer::createNoValidate(array(
    'creditCard' => array(
      'number' => '5105105105105100',
      'expirationDate' => '05/12',
    ),
  ));
  $creditCard = $customer->creditCards[0];
  $result = Braintree_CreditCard::credit($creditCard->token, array(
    'amount' => '100.00',
  ));
  $this
    ->assertTrue($result->success);
  $this
    ->assertEquals('100.00', $result->transaction->amount);
  $this
    ->assertEquals(Braintree_Transaction::CREDIT, $result->transaction->type);
  $this
    ->assertEquals($customer->id, $result->transaction->customerDetails->id);
  $this
    ->assertEquals($creditCard->token, $result->transaction->creditCardDetails->token);
}