Пример #1
0
 /**
  * {@inheritDoc}
  */
 public function setField($name, $value)
 {
     // the _all_aim_fields is private so we cannot check that.
     try {
         parent::setField($name, $value);
     } catch (\AuthorizeNetException $e) {
         if ($this->ignore_not_x_fields) {
             return;
         }
         throw $e;
     }
 }
Пример #2
0
 public function testAuthCaptureLiveServerTestRequest()
 {
     if (MERCHANT_LIVE_API_LOGIN_ID) {
         $sale = new AuthorizeNetAIM(MERCHANT_LIVE_API_LOGIN_ID, MERCHANT_LIVE_TRANSACTION_KEY);
         $sale->setSandbox(false);
         $sale->setFields(array('amount' => rand(1, 1000), 'card_num' => '6011000000000012', 'exp_date' => '0415'));
         $sale->setField('test_request', 'TRUE');
         $response = $sale->authorizeAndCapture();
         $this->assertTrue($response->approved);
     }
 }
Пример #3
0
 public function external_hook($hook)
 {
     switch ($hook) {
         case 'pay':
             // result is retured via ajax and displayed on the page.
             $invoice_id = isset($_REQUEST['invoice_id']) ? $_REQUEST['invoice_id'] : false;
             $invoice_payment_id = isset($_REQUEST['invoice_payment_id']) ? $_REQUEST['invoice_payment_id'] : false;
             if ($invoice_id && $invoice_payment_id) {
                 $invoice_payment_data = module_invoice::get_invoice_payment($invoice_payment_id);
                 $invoice_data = module_invoice::get_invoice($invoice_id);
                 if ($invoice_payment_data && $invoice_data && $invoice_id == $invoice_data['invoice_id'] && $invoice_payment_data['invoice_id'] == $invoice_data['invoice_id']) {
                     $currency = module_config::get_currency($invoice_payment_data['currency_id']);
                     $currency_code = $currency['code'];
                     $description = _l('Payment for invoice %s', $invoice_data['name']);
                     require_once 'includes/plugin_paymethod_authorize/anet_php_1.1.8/AuthorizeNet.php';
                     $transaction = new AuthorizeNetAIM(module_config::c('payment_method_authorize_api_login_id', ''), module_config::c('payment_method_authorize_transaction_key', ''));
                     $transaction->setSandbox(module_config::c('payment_method_authorize_sandbox', 0));
                     $transaction->VERIFY_PEER = module_config::c('payment_method_authorize_ssl_verify', 1);
                     $transaction->amount = $invoice_payment_data['amount'];
                     // USD ONLY
                     foreach (array("address", "allow_partial_auth", "amount", "auth_code", "authentication_indicator", "bank_aba_code", "bank_acct_name", "bank_acct_num", "bank_acct_type", "bank_check_number", "bank_name", "card_code", "card_num", "cardholder_authentication_value", "city", "company", "country", "cust_id", "customer_ip", "delim_char", "delim_data", "description", "duplicate_window", "duty", "echeck_type", "email", "email_customer", "encap_char", "exp_date", "fax", "first_name", "footer_email_receipt", "freight", "header_email_receipt", "invoice_num", "last_name", "line_item", "login", "method", "phone", "po_num", "recurring_billing", "relay_response", "ship_to_address", "ship_to_city", "ship_to_company", "ship_to_country", "ship_to_first_name", "ship_to_last_name", "ship_to_state", "ship_to_zip", "split_tender_id", "state", "tax", "tax_exempt", "test_request", "tran_key", "trans_id", "type", "version", "zip") as $possible_value) {
                         if (isset($_POST[$possible_value])) {
                             $transaction->setField($possible_value, $_POST[$possible_value]);
                         }
                     }
                     $transaction->setField('card_num', isset($_POST['number']) ? $_POST['number'] : '');
                     $transaction->setField('exp_date', $_POST['month'] . '/' . $_POST['year']);
                     $transaction->setField('card_code', $_POST['cvv']);
                     //$transaction->card_num = isset($_POST['number']) ? $_POST['number'] : '';
                     //$transaction->exp_date = $_POST['month'].'/'.$_POST['year'];
                     //$transaction->card_code = $_POST['cvv'];
                     $response = $transaction->authorizeAndCapture();
                     if ($response->approved) {
                         //                          echo "<h1>Success! The test credit card has been charged!</h1>";
                         //                          echo "Transaction ID: " . $response->transaction_id;
                         update_insert("invoice_payment_id", $invoice_payment_id, "invoice_payment", array('date_paid' => date('Y-m-d')));
                         module_paymethod_stripe::add_payment_data($invoice_payment_id, 'log', "Successfully paid: " . var_export($response, true));
                         module_invoice::save_invoice($invoice_id, array());
                         // success!
                         // redirect to receipt page.
                         redirect_browser(module_invoice::link_receipt($invoice_payment_id));
                     } else {
                         echo isset($response->error_message) ? $response->error_message : (isset($response->response_reason_text) ? $response->response_reason_text : var_export($response, true));
                     }
                     exit;
                 }
             }
             echo 'Error paying via Authorize';
             exit;
     }
 }