You are here

function Braintree_TransparentRedirectTest::testCreateCreditCardFromTransparentRedirect in Commerce Braintree 7

File

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

Class

Braintree_TransparentRedirectTest

Code

function testCreateCreditCardFromTransparentRedirect() {
  $customer = Braintree_Customer::create(array(
    'firstName' => 'Mike',
    'lastName' => 'Jonez',
  ))->customer;
  $params = array(
    'credit_card' => array(
      'number' => Braintree_Test_CreditCardNumbers::$visa,
    ),
  );
  $trParams = array(
    'creditCard' => array(
      'customerId' => $customer->id,
      'expirationMonth' => '01',
      'expirationYear' => '10',
    ),
  );
  $trData = Braintree_TransparentRedirect::createCreditCardData(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);
  $creditCard = $result->creditCard;
  $this
    ->assertequals('401288', $creditCard->bin);
  $this
    ->assertequals('1881', $creditCard->last4);
  $this
    ->assertequals('01/2010', $creditCard->expirationDate);
}