function buildTrData($redirectUrl) { $customer = Mage::getSingleton('customer/session')->getCustomer(); if ($this->braintree->exists($customer->getId())) { return Braintree_TransparentRedirect::createCreditCardData(array('redirectUrl' => $redirectUrl, 'creditCard' => array('customerId' => $customer->getId()))); } else { $credit_card_billing = array(); $billing = $customer->getDefaultBilling(); if ($billing) { $address = Mage::getModel('customer/address')->load($billing); $credit_card_billing['billingAddress'] = $this->braintree->toBraintreeAddress($address); } return Braintree_TransparentRedirect::createCustomerData(array('redirectUrl' => $redirectUrl, 'customer' => array('id' => $customer->getId(), 'firstName' => $customer->getFirstname(), 'lastName' => $customer->getLastname(), 'company' => $customer->getCompany(), 'phone' => $customer->getTelephone(), 'fax' => $customer->getFax(), 'email' => $customer->getEmail(), 'creditCard' => $credit_card_billing))); } }
function createCreditCardViaTr($regularParams, $trParams) { $trData = Braintree_TransparentRedirect::createCreditCardData(array_merge($trParams, array("redirectUrl" => "http://www.example.com"))); return Braintree_TestHelper::submitTrRequest(Braintree_CreditCard::createCreditCardUrl(), $regularParams, $trData); }
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); }
public function createCreditCardData($params) { return Braintree_TransparentRedirect::createCreditCardData($params); }