function bill_checkout($amount, $invoice, $currency_iso, $acct_fields, $total_recurring = false, $recurr_bill_arr = false) { # Validate currency if (!$this->validate_currency($currency_iso)) { return false; } $ret = false; if (!$this->validate_card_details($ret)) { return false; } $tran = new umTransaction(); $tran->key = $this->cfg['key']; $tran->testmode = $this->cfg['mode']; $tran->ip = USER_IP; $tran->card = $this->billing["cc_no"]; $tran->exp = $this->billing["exp_month"] . $this->billing["exp_year"]; $tran->amount = $amount; $tran->invoice = $invoice; $tran->cardholder = $this->account["first_name"] . ' ' . $this->account["last_name"]; $tran->street = $this->account["address1"] . ' ' . $this->account["address2"]; $tran->zip = $this->account["zip"]; $tran->description = "Invoice {$invoice}"; $tran->cvv2 = $this->billing["ccv"]; if ($tran->Process()) { $ret['status'] = 1; $ret['avs'] = $tran->avs; $ret['msg'] = $tran->authcode . ' ' . $tran->cvv2; } else { $ret['status'] = 0; $ret['msg'] = "Card Declined (" . $tran->result . ")"; $ret['msg'] .= " " . $tran->error; if ($tran->curlerror) { echo "<b>Curl Error:</b> " . $tran->curlerror . "<br>"; exit; } } if ($ret['status'] == 1) { return $ret; } else { global $VAR; @($VAR['msg'] = $ret["msg"]); return false; } }
function USAePayCreateProfile($orderInfo, $creditInfo, $params = array()) { require_once OSEMSC_B_LIB . DS . 'usaepay.php'; $tran = new umTransaction(); $pConfig = oseMscConfig::getConfig('payment', 'obj'); $source_key = $pConfig->usaepay_source_key; $testmode = $pConfig->usaepay_testmode; $sendReceipt = empty($pConfig->usaepay_sendReceipt) ? 'no' : 'yes'; $payment = oseRegistry::call('payment'); $paymentOrder = $payment->getInstance('Order'); $billinginfo = $paymentOrder->getBillingInfo($orderInfo->user_id); $orderInfoParams = oseJson::decode($orderInfo->params); $redirectUrl = urldecode($orderInfoParams->returnUrl); $redirectUrl = $redirectUrl ? $redirectUrl : JURI::base() . "index.php?option=com_osemsc&view=member"; $tran->key = $source_key; $tran->testmode = $testmode; $tran->usesandbox = $pConfig->usaepay_usesandbox; $tran->custreceipt = $sendReceipt; //Credit Card Info $tran->cardholder = $creditInfo['creditcard_name']; $tran->card = $creditInfo['creditcard_number']; $tran->cvv2 = $creditInfo['creditcard_cvv']; $tran->exp = $creditInfo['creditcard_month'] . substr($creditInfo['creditcard_year'], 2, 2); $tran->street = $billinginfo->addr1 . ' ' . $billinginfo->addr2; $tran->zip = $billinginfo->postcode; //Item Info $tran->currency = $this->transCurrency($orderInfo->payment_currency); // international currency, full list of codes: http://wiki.usaepay.com/developer/currencycode if (empty($tran->currency)) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = 'Currency Error'; return $result; } $tran->amount = $orderInfo->payment_price; $tran->billamount = $orderInfoParams->next_total; $tran->invoice = $orderInfo->order_number; $tran->description = self::generateDesc($orderInfo->order_id); $tran->command = 'sale'; $tran->addcustomer = 'yes'; $tran->schedule = $this->transUnit($orderInfoParams->t3); //billing Info $tran->billfname = $billinginfo->firstname; $tran->billlname = $billinginfo->lastname; $tran->billcompany = $billinginfo->company; $tran->billstreet = $billinginfo->addr1; $tran->billstreet2 = $billinginfo->addr2; $tran->billcity = $billinginfo->city; $tran->billstate = $billinginfo->state; $tran->billzip = $billinginfo->postcode; $tran->billcountry = $billinginfo->country; $tran->billphone = $billinginfo->telephone; $tran->email = $billinginfo->email; $result = array(); if ($tran->Process()) { $paymentOrder->confirmOrder($orderInfo->order_id, array()); $result['success'] = true; $result['title'] = JText::_('SUCCESSFUL_ACTIVATION'); $result['content'] = JText::_('MEMBERSHIP_ACTIVATED_CONTINUE'); $result['returnUrl'] = $redirectUrl; } else { $result['success'] = false; $result['title'] = $tran->result; $result['content'] = $tran->error; $result['returnUrl'] = JURI::base() . "index.php?option=com_osemsc&view=register"; } return $result; }
// charge amount in dollars $tran->invoice = $_POST['transaction_uuid']; // invoice number. must be unique. $tran->cardholder = $_POST['billing_name']; // name of card holder $tran->street = $_POST['billing_address_1'] . ', ' . $_POST['billing_address_2']; // street address $tran->zip = $_POST['billing_zip']; // zip code $tran->description = "Via Paydunk"; // description of charge $tran->cvv2 = $_POST['cvv']; // cvv2 code echo "<h1>Please wait one moment while we process your card...<br>\n"; flush(); if ($tran->Process()) { echo "<b>Card Approved</b><br>"; echo "<b>Authcode:</b> " . $tran->authcode . "<br>"; echo "<b>RefNum:</b> " . $tran->refnum . "<br>"; echo "<b>AVS Result:</b> " . $tran->avs_result . "<br>"; echo "<b>Cvv2 Result:</b> " . $tran->cvv2_result . "<br>"; $status = 'success'; } else { echo "<b>Card Declined</b> (" . $tran->result . ")<br>"; echo "<b>Reason:</b> " . $tran->error . "<br>"; if (@$tran->curlerror) { echo "<b>Curl Error:</b> " . $tran->curlerror . "<br>"; } $status = 'error'; } //set data for PUT request
/** * The run() function is called from Web Store to run the process. * @return array */ public function run() { require_once "usaepay.php"; $DEBUGGING = 1; # Display additional information to track down problems $TESTING = 1; # Set the testing flag so that transactions are not live $ERROR_RETRIES = 2; # Number of transactions to post if soft errors occur $source_key = $this->config['source_key']; $source_key_pin = isset($this->config['source_key_pin']) ? $this->config['source_key_pin'] : false; $tran = new umTransaction(); $tran->key = $source_key; if ($source_key_pin) { $tran->pin = $source_key_pin; } $tran->ip = $_SERVER['REMOTE_ADDR']; // This allows fraud blocking on the customers ip address if ($this->config['live'] == 'test') { $tran->testmode = 1; } else { $tran->testmode = 0; } $tran->card = _xls_number_only($this->CheckoutForm->cardNumber); // card number, no dashes, no spaces $tran->exp = $this->CheckoutForm->cardExpiryMonth . substr($this->CheckoutForm->cardExpiryYear, 2, 2); // expiration date 4 digits no / $tran->amount = $this->objCart->total; // charge amount in dollars $tran->invoice = $this->objCart->id_str; // invoice number. must be unique. $tran->cardholder = $this->CheckoutForm->cardNameOnCard; // name of card holder $tran->street = $this->CheckoutForm->billingAddress1 . " " . $this->CheckoutForm->billingAddress2; // street address $tran->zip = str_replace(" ", "", $this->CheckoutForm->billingPostal); // zip code $tran->description = _xls_get_conf('STORE_NAME') . " " . $this->objCart->id_str; // description of charge $tran->cvv2 = $this->CheckoutForm->cardCVV; // cvv2 code $tran->billfname = $this->CheckoutForm->contactFirstName; $tran->billlname = $this->CheckoutForm->contactLastName; $tran->billstreet = $this->CheckoutForm->billingAddress1; $tran->billstreet2 = $this->CheckoutForm->billingAddress2; $tran->billcity = $this->CheckoutForm->billingCity; $tran->billstate = $this->CheckoutForm->billingStateCode; $tran->billzip = $this->CheckoutForm->billingPostal; $tran->billcountry = $this->CheckoutForm->billingCountryCode; $tran->billphone = $this->CheckoutForm->contactPhone; $tran->email = $this->CheckoutForm->contactEmail; $tran->shipfname = $this->CheckoutForm->shippingFirstName; $tran->shiplname = $this->CheckoutForm->shippingLastName; $tran->shipstreet = $this->CheckoutForm->shippingAddress1; $tran->shipstreet2 = $this->CheckoutForm->shippingAddress2; $tran->shipcity = $this->CheckoutForm->shippingCity; $tran->shipstate = $this->CheckoutForm->shippingStateCode; $tran->shipzip = $this->CheckoutForm->shippingPostal; $tran->shipcountry = $this->CheckoutForm->shippingCountryCode; $tran->custid = Yii::app()->user->id; $tranTemp = clone $tran; Yii::log(sprintf("%s sending %s for amt %s\nRequest %s", __CLASS__, $this->objCart->id_str, $this->objCart->total, print_r($this->obfuscateRequestArray($tranTemp), true)), $this->logLevel, 'application.' . __CLASS__ . "." . __FUNCTION__); if ($tran->Process()) { //We have success $arrReturn['success'] = true; $arrReturn['amount_paid'] = $this->objCart->total; $arrReturn['result'] = $tran->refnum; } else { $arrReturn['success'] = false; $arrReturn['amount_paid'] = 0; $errortext = Yii::t('global', $tran->error); $arrReturn['result'] = Yii::t('global', $errortext); Yii::log("Declined: " . $errortext, 'error', 'application.' . __CLASS__ . "." . __FUNCTION__); } unset($tran->card); unset($tran->exp); unset($tran->key); unset($tran->pin); Yii::log(sprintf("%s receiving %s", __CLASS__, print_r($tran, true)), $this->logLevel, 'application.' . __CLASS__ . "." . __FUNCTION__); return $arrReturn; }
function before_process() { global $HTTP_POST_VARS, $order; require DIR_FS_CATALOG_MODULES . "payment/usaepay/usaepay.php"; $tran = new umTransaction(); $tran->key = MODULE_PAYMENT_INTENSEPAY_KEY; $tran->testmode = MODULE_PAYMENT_INTENSEPAY_TEST == 'True'; $tran->card = $_POST['intensepay_cc_num']; // card number, no dashes, no spaces $tran->exp = $_POST['intensepay_cc_exp_mon'] . $_POST['intensepay_cc_exp_year']; // expiration date 4 digits no / $tran->amount = $order->info['total']; // charge amount in dollars (no international support yet) $tran->invoice = "1234"; // invoice number. must be unique. $tran->cardholder = $_POST['intensepay_cc_name']; // name of card holder $tran->street = $order->billing['address1']; // street address $tran->zip = $order->billing['postcode']; // zip code $tran->description = "Online Order - @ " . STORE_NAME; // description of charge $tran->cvv2 = $_POST['intensepay_cvv2']; // cvv2 code if ($tran->Process()) { return true; echo "<b>Card approved</b><br>"; echo "<b>Authcode:</b> " . $tran->authcode . "<br>"; echo "<b>AVS Result:</b> " . $tran->avs_result . "<br>"; echo "<b>Cvv2 Result:</b> " . $tran->cvv2_result . "<br>"; } else { echo "<b>Card Declined</b> (" . $tran->result . ")<br>"; echo "<b>Reason:</b> " . $tran->error . "<br>"; if ($tran->curlerror) { echo "<b>Curl Error:</b> " . $tran->curlerror . "<br>"; } } }