コード例 #1
0
 function testData_doesNotClobberDefaultTimezone()
 {
     $originalZone = date_default_timezone_get();
     date_default_timezone_set('Europe/London');
     $trData = Braintree_TransparentRedirect::createCustomerData(array('redirectUrl' => 'http://www.example.com'));
     $zoneAfterCall = date_default_timezone_get();
     date_default_timezone_set($originalZone);
     $this->assertEquals('Europe/London', $zoneAfterCall);
 }
コード例 #2
0
 function testCreateCustomerFromTransparentRedirect()
 {
     $params = array('customer' => array('first_name' => 'Second'));
     $trParams = array('customer' => array('lastName' => 'Penultimate'));
     $trData = Braintree_TransparentRedirect::createCustomerData(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);
     $customer = $result->customer;
     $this->assertequals('Second', $customer->firstName);
     $this->assertequals('Penultimate', $customer->lastName);
 }
コード例 #3
0
 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)));
     }
 }
コード例 #4
0
ファイル: braintree.php プロジェクト: alexanderTsig/arabic
 function createForm()
 {
     $form = $this->plugin->createForm(Am_Form_CreditCard::PAYFORM, $this->invoice);
     $form->addHidden(Am_Controller::ACTION_KEY)->setValue($this->_request->getActionName());
     $form->addHidden('cc_id')->setValue($this->getFiltered('cc_id'));
     $user = $this->invoice->getUser();
     $form->setDataSources(array($this->_request, new HTML_QuickForm2_DataSource_Array($form->getDefaultValues($user))));
     $form->addHidden('tr_data')->setValue(Braintree_TransparentRedirect::createCustomerData(array('redirectUrl' => $this->plugin->getPluginUrl(Am_Paysystem_Braintree::ACTION_CC) . "?cc_id=" . $this->getFiltered('cc_id'), 'customer' => array('firstName' => $this->invoice->getUser()->name_f, 'lastName' => $this->invoice->getUser()->name_l, 'email' => $this->invoice->getUser()->email, 'phone' => $this->invoice->getUser()->phone))));
     return $form;
 }
コード例 #5
0
 function createCustomerViaTr($regularParams, $trParams)
 {
     Braintree_TestHelper::suppressDeprecationWarnings();
     $trData = Braintree_TransparentRedirect::createCustomerData(array_merge($trParams, array("redirectUrl" => "http://www.example.com")));
     return Braintree_TestHelper::submitTrRequest(Braintree_Customer::createCustomerUrl(), $regularParams, $trData);
 }
コード例 #6
0
<?php

$trData = Braintree_TransparentRedirect::createCustomerData(array('redirectUrl' => 'http://localhost:8080/braintree'));
?>

<html>
  <head>
    <style type='text/css'>label {display: block;} input {margin-bottom: 10px;}</style>
  </head>
  <body>
    <h1>Braintree Credit Card Transaction Form</h1>
    <form id='payment-form' action='<?php 
echo Braintree_TransparentRedirect::url();
?>
' method='POST'>
      <input type='hidden' name='tr_data' value='<?php 
echo htmlentities($trData);
?>
' />
      <div>
        <h2>Customer Information</h2>
        <label for='customer_first_name'>First Name</label>
        <input type='text' name='customer[first_name]' id='customer_first_name'></input>
        <label for='customer_last_name'>Last Name</label>
        <input type='text' name='customer[last_name]' id='customer_last_name'></input>
        <label for='customer_email'>Email</label>
        <input type='text' name='customer[email]' id='customer_email'></input>
        <h2>Billing Address</h2>
        <label for='billing_street_address'>Street Address</label>
        <input type='text' name='customer[credit_card][billing_address][street_address]' id='billing_street_address'></input>
        <label for='billing_extended_address'>Extended Address</label>