You are here

function Braintree_TransactionTest::testSale_withAllAttributes in Commerce Braintree 7

File

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

Class

Braintree_TransactionTest

Code

function testSale_withAllAttributes() {
  $result = Braintree_Transaction::sale(array(
    'amount' => '100.00',
    'orderId' => '123',
    'creditCard' => array(
      'cardholderName' => 'The Cardholder',
      'number' => '5105105105105100',
      'expirationDate' => '05/2011',
      'cvv' => '123',
    ),
    'customer' => array(
      'firstName' => 'Dan',
      'lastName' => 'Smith',
      'company' => 'Braintree Payment Solutions',
      'email' => 'dan@example.com',
      'phone' => '419-555-1234',
      'fax' => '419-555-1235',
      'website' => 'http://braintreepayments.com',
    ),
    'billing' => array(
      'firstName' => 'Carl',
      'lastName' => 'Jones',
      'company' => 'Braintree',
      'streetAddress' => '123 E Main St',
      'extendedAddress' => 'Suite 403',
      'locality' => 'Chicago',
      'region' => 'IL',
      'postalCode' => '60622',
      'countryName' => 'United States of America',
      'countryCodeAlpha2' => 'US',
      'countryCodeAlpha3' => 'USA',
      'countryCodeNumeric' => '840',
    ),
    'shipping' => array(
      'firstName' => 'Andrew',
      'lastName' => 'Mason',
      'company' => 'Braintree',
      'streetAddress' => '456 W Main St',
      'extendedAddress' => 'Apt 2F',
      'locality' => 'Bartlett',
      'region' => 'IL',
      'postalCode' => '60103',
      'countryName' => 'United States of America',
      'countryCodeAlpha2' => 'US',
      'countryCodeAlpha3' => 'USA',
      'countryCodeNumeric' => '840',
    ),
  ));
  Braintree_TestHelper::assertPrintable($result);
  $this
    ->assertTrue($result->success);
  $transaction = $result->transaction;
  $this
    ->assertNotNull($transaction->id);
  $this
    ->assertNotNull($transaction->createdAt);
  $this
    ->assertNotNull($transaction->updatedAt);
  $this
    ->assertNull($transaction->refundId);
  $this
    ->assertEquals(Braintree_TestHelper::defaultMerchantAccountId(), $transaction->merchantAccountId);
  $this
    ->assertEquals(Braintree_Transaction::AUTHORIZED, $transaction->status);
  $this
    ->assertEquals(Braintree_Transaction::SALE, $transaction->type);
  $this
    ->assertEquals('100.00', $transaction->amount);
  $this
    ->assertEquals('USD', $transaction->currencyIsoCode);
  $this
    ->assertEquals('123', $transaction->orderId);
  $this
    ->assertEquals('MasterCard', $transaction->creditCardDetails->cardType);
  $this
    ->assertEquals('1000', $transaction->processorResponseCode);
  $this
    ->assertEquals('Approved', $transaction->processorResponseText);
  $this
    ->assertFalse($transaction->taxExempt);
  $this
    ->assertEquals('M', $transaction->avsPostalCodeResponseCode);
  $this
    ->assertEquals('M', $transaction->avsStreetAddressResponseCode);
  $this
    ->assertEquals('M', $transaction->cvvResponseCode);
  $this
    ->assertEquals('Dan', $transaction->customerDetails->firstName);
  $this
    ->assertEquals('Smith', $transaction->customerDetails->lastName);
  $this
    ->assertEquals('Braintree Payment Solutions', $transaction->customerDetails->company);
  $this
    ->assertEquals('dan@example.com', $transaction->customerDetails->email);
  $this
    ->assertEquals('419-555-1234', $transaction->customerDetails->phone);
  $this
    ->assertEquals('419-555-1235', $transaction->customerDetails->fax);
  $this
    ->assertEquals('http://braintreepayments.com', $transaction->customerDetails->website);
  $this
    ->assertEquals('Carl', $transaction->billingDetails->firstName);
  $this
    ->assertEquals('Jones', $transaction->billingDetails->lastName);
  $this
    ->assertEquals('Braintree', $transaction->billingDetails->company);
  $this
    ->assertEquals('123 E Main St', $transaction->billingDetails->streetAddress);
  $this
    ->assertEquals('Suite 403', $transaction->billingDetails->extendedAddress);
  $this
    ->assertEquals('Chicago', $transaction->billingDetails->locality);
  $this
    ->assertEquals('IL', $transaction->billingDetails->region);
  $this
    ->assertEquals('60622', $transaction->billingDetails->postalCode);
  $this
    ->assertEquals('United States of America', $transaction->billingDetails->countryName);
  $this
    ->assertEquals('US', $transaction->billingDetails->countryCodeAlpha2);
  $this
    ->assertEquals('USA', $transaction->billingDetails->countryCodeAlpha3);
  $this
    ->assertEquals('840', $transaction->billingDetails->countryCodeNumeric);
  $this
    ->assertEquals('Andrew', $transaction->shippingDetails->firstName);
  $this
    ->assertEquals('Mason', $transaction->shippingDetails->lastName);
  $this
    ->assertEquals('Braintree', $transaction->shippingDetails->company);
  $this
    ->assertEquals('456 W Main St', $transaction->shippingDetails->streetAddress);
  $this
    ->assertEquals('Apt 2F', $transaction->shippingDetails->extendedAddress);
  $this
    ->assertEquals('Bartlett', $transaction->shippingDetails->locality);
  $this
    ->assertEquals('IL', $transaction->shippingDetails->region);
  $this
    ->assertEquals('60103', $transaction->shippingDetails->postalCode);
  $this
    ->assertEquals('United States of America', $transaction->shippingDetails->countryName);
  $this
    ->assertEquals('US', $transaction->shippingDetails->countryCodeAlpha2);
  $this
    ->assertEquals('USA', $transaction->shippingDetails->countryCodeAlpha3);
  $this
    ->assertEquals('840', $transaction->shippingDetails->countryCodeNumeric);
  $this
    ->assertNotNull($transaction->processorAuthorizationCode);
  $this
    ->assertEquals('510510', $transaction->creditCardDetails->bin);
  $this
    ->assertEquals('5100', $transaction->creditCardDetails->last4);
  $this
    ->assertEquals('510510******5100', $transaction->creditCardDetails->maskedNumber);
  $this
    ->assertEquals('The Cardholder', $transaction->creditCardDetails->cardholderName);
  $this
    ->assertEquals('05', $transaction->creditCardDetails->expirationMonth);
  $this
    ->assertEquals('2011', $transaction->creditCardDetails->expirationYear);
}