You are here

function Braintree_TransparentRedirectTest::testCreateTransactionFromTransparentRedirect in Commerce Braintree 7

File

braintree_php/tests/integration/TransparentRedirectTest.php, line 58

Class

Braintree_TransparentRedirectTest

Code

function testCreateTransactionFromTransparentRedirect() {
  $params = array(
    'transaction' => array(
      'customer' => array(
        'first_name' => 'First',
      ),
      'credit_card' => array(
        'number' => '5105105105105100',
        'expiration_date' => '05/12',
      ),
    ),
  );
  $trParams = array(
    'transaction' => array(
      'type' => Braintree_Transaction::SALE,
      'amount' => '100.00',
    ),
  );
  $trData = Braintree_TransparentRedirect::transactionData(array_merge($trParams, array(
    "redirectUrl" => "http://www.example.com",
  )));
  $queryString = Braintree_TestHelper::submitTrRequest(Braintree_TransparentRedirect::url(), $params, $trData);
  $result = Braintree_TransparentRedirect::confirm($queryString);
  $this
    ->assertTrue($result->success);
  $this
    ->assertEquals('100.00', $result->transaction->amount);
  $this
    ->assertEquals(Braintree_Transaction::SALE, $result->transaction->type);
  $this
    ->assertEquals(Braintree_Transaction::AUTHORIZED, $result->transaction->status);
  $creditCard = $result->transaction->creditCardDetails;
  $this
    ->assertEquals('510510', $creditCard->bin);
  $this
    ->assertEquals('5100', $creditCard->last4);
  $this
    ->assertEquals('US', $creditCard->customerLocation);
  $this
    ->assertEquals('MasterCard', $creditCard->cardType);
  $this
    ->assertEquals('05/2012', $creditCard->expirationDate);
  $this
    ->assertEquals('510510******5100', $creditCard->maskedNumber);
  $customer = $result->transaction->customerDetails;
  $this
    ->assertequals('First', $customer->firstName);
}