예제 #1
0
 function AuthorizeARBCheckStatus($orderId)
 {
     $db =& JFactory::getDBO();
     $query = " SELECT `order_number` FROM `#__osemsc_order` " . " WHERE `order-id`= '{$orderId}'";
     $db->setQuery($query);
     $ProfileID = $db->loadResult();
     if (!empty($ProfileID)) {
         require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_osemsc' . DS . 'libraries' . DS . 'AuthnetARB.class.php';
         $arb = new AuthnetARB();
         $arb->setParameter('subscrId', $ProfileID);
         $arb->getSubscriptionStatus();
         return $arb->status;
     }
 }
    /* if($subscription_id_responce_cancel)

       {echo "hello hi error";

       	$subscription->setParameter('subscrId',$subscription_id_responce_cancel );

       	$subscription->deleteAccount();

       	if ($subscription->isSuccessful()){

           

          echo $subscription->isSuccessful();

       }

       else{

       	

     				 echo $subscription->getResponse();

     				

       }

       }*/
} catch (AuthnetARBException $e) {
    $subscription = new AuthnetARB('8FVwN499xm', '2Tc8f298B76jG9yX');
    if ($subscription_id_responce_cancel) {
        $subscription->setParameter('subscrId', $subscription_id_responce_cancel);
 public function purchase_direct($id)
 {
     $subscriptions = $this->subscriptions;
     $subscription = $subscriptions[$id];
     if (empty($subscription)) {
         return;
     }
     $sandbox = $this->anetarb_settings['mode'] == 'sandbox' ? true : false;
     $payment = new AuthnetAIM($sandbox);
     $creditcard = $_POST['cc_number'];
     $expiration = $_POST['cc_expmonth'] . $_POST['cc_expyear'];
     $cvv = $_POST['cc_cvc'];
     $total = $subscription['init_amount'];
     $invoice = null;
     $tax = null;
     $first_name = $_POST['first_name'];
     $last_name = $_POST['last_name'];
     $email = $_POST['email'];
     $payment->transaction($creditcard, $expiration, $total, $cvv, $invoice, $tax);
     $login = $this->anetarb_settings['acct.api_login_id'];
     $key = $this->anetarb_settings['acct.transaction_key'];
     $payment->setParameter("x_login", $login);
     $payment->setParameter("x_tran_key", $key);
     $payment->setParameter("x_first_name", $first_name);
     $payment->setParameter("x_last_name", $last_name);
     $payment->setParameter("x_email", $email);
     $subscription_name = $subscription['name'];
     $payment->process();
     if ($payment->isApproved()) {
         // Instanciate our ARB class
         $arb = new AuthnetARB($sandbox, $login, $key);
         // Set recurring billing variables
         // Set recurring billing parameters
         $arb->setParameter('amount', $total);
         $arb->setParameter('cardNumber', $creditcard);
         $arb->setParameter('expirationDate', $expiration);
         $arb->setParameter('firstName', $first_name);
         $arb->setParameter('lastName', $last_name);
         //$arb->setParameter('address', $address);
         //$arb->setParameter('city', $city);
         //$arb->setParameter('state', $state);
         //$arb->setParameter('zip', $zip);
         $arb->setParameter('customerEmail', $email);
         $arb->setParameter('subscrName', $subscription_name);
         // Create the recurring billing subscription
         $arb->createAccount();
         // If successful let's get the subscription ID
         if ($arb->isSuccessful()) {
             $arb_id = $arb->getSubscriberID();
             $status = array('status' => 'active', 'id' => $arb_id);
         } else {
             //var_dump('Fail:' . $arb->getResponse());
         }
     } else {
         //var_dump($payment->getResultResponseFull());
     }
     $_POST['lastname'] = $last_name;
     $_POST['firstname'] = $first_name;
     $_POST['action'] = 'wpm_register';
     $_POST['wpm_id'] = $subscription['sku'];
     $_POST['username'] = $email;
     $_POST['email'] = $email;
     $_POST['sctxnid'] = $status['id'];
     $_POST['password1'] = $_POST['password2'] = $this->wlm->PassGen();
     $this->wlm->ShoppingCartRegistration();
 }
 // not saved at this time
 $cvv_result = $payment->getCVVResponse();
 // not saved at this time
 $transaction_id = $payment->getTransactionID();
 // Do stuff with this.
 //$err[] = "Amount: $auth_total";
 //$err[] = "Invoice #: $invoice";
 //$err[] = "Auth Code: $approval_code";
 //$err[] = "AVS Result: $avs_result";
 //$err[] = "CVV Result: $cvv_result";
 //$err[] = "Transaction ID: $transaction_id";
 // TODO: in case of errors, email the above info to the admin
 // *******************************************************************
 // NOW WE CAN SET UP THE RECURRING BILLING SUBSCRIPTION
 // *******************************************************************
 $arb = new AuthnetARB();
 // Set recurring billing variables
 $arb->setParameter('interval_length', $subscription_length);
 $arb->setParameter('interval_unit', $subscription_unit);
 $arb->setParameter('totalOccurrences', 9999);
 $arb->setParameter('startDate', $start_date);
 // Set recurring billing parameters
 $arb->setParameter('amount', $subscription_total);
 $arb->setParameter('cardNumber', $creditcard);
 $arb->setParameter('expirationDate', $expiration2);
 $arb->setParameter('firstName', $a['card_name_first']);
 $arb->setParameter('lastName', $a['card_name_last']);
 $arb->setParameter('address', $a['address']);
 $arb->setParameter('city', $a['city']);
 $arb->setParameter('state', $a['state']);
 $arb->setParameter('zip', $a['zipcode']);
예제 #5
0
 protected function apiCheck($oItem)
 {
     $result = array();
     $db = oseDB::instance();
     static $arb;
     $oseMscConfig = oseMscConfig::getConfig('payment', 'obj');
     // Authorize setting
     if (!defined('AUTHORIZENET_API_LOGIN_ID')) {
         define("AUTHORIZENET_API_LOGIN_ID", oseObject::getValue($oseMscConfig, 'an_loginid'));
     }
     if (!defined('AUTHORIZENET_TRANSACTION_KEY')) {
         define("AUTHORIZENET_TRANSACTION_KEY", oseObject::getValue($oseMscConfig, 'an_transkey'));
     }
     if (!$arb instanceof AuthnetARB) {
         $arb = new AuthnetARB();
         $pConfig = oseMscConfig::getConfig('payment', 'obj');
         $test_mode = $pConfig->cc_testmode;
         if ($test_mode) {
             $arb->apitest = "api.authorize.net";
         } else {
             $arb->url = "api.authorize.net";
         }
         $arb->login = AUTHORIZENET_API_LOGIN_ID;
         $arb->transkey = AUTHORIZENET_TRANSACTION_KEY;
     }
     // End
     // init Beanstream
     // End
     //oseExit($oItem->payment_method);
     $oParams = oseJson::decode($oItem->params);
     if ($oItem->payment_method == 'authorize') {
         if (empty($oItem->payment_serial_number)) {
             $result['success'] = false;
             $result['title'] = JText::_('ERROR');
             $result['content'] = JText::_('ERROR');
             oseExit(oseJson::encode($result));
         }
         if ($oItem->payment_mode == 'm') {
             $vals = array();
             // update expired date
             $vals['id'] = $obj->id;
             //$vals['status'] = 0;
             $vals['virtual_status'] = 0;
             $vals['eternal'] = 0;
             //$vals['expired_date'] = oseHtml::getDateTime();
             oseDB::update('#__osemsc_member', 'id', $vals);
         } else {
             $arb->setParameter('subscrId', $oItem->payment_serial_number);
             $arb->getSubscriptionStatus();
             //oseExit($arb);
             $response = $arb->status;
             $vals = array();
             if (strtolower($response) == 'active' && $arb->getResponseCode() == 'I00001' && $arb->isSuccessful()) {
                 $recurrence_num = oseObject::getValue($oParams, 'p3');
                 $recurrence_unit = oseObject::getValue($oParams, 't3');
                 if ($obj->expired_date == '0000-00-00 00:00:00') {
                     $expired_date = " DATE_ADD(`start_date` ,INTERVAL {$recurrence_num} {$recurrence_unit}) ";
                 } else {
                     $expired_date = " DATE_ADD(`expired_date` ,INTERVAL {$recurrence_num} {$recurrence_unit}) ";
                 }
                 $query = " UPDATE `#__osemsc_member` " . " SET  `status` = 1 ,`eternal`=0, `expired_date` = {$expired_date}" . " WHERE `id` = '{$oItem->member_id}' AND `expired_date` < DATE_ADD(NOW(),INTERVAL 2 DAY)";
                 $db->setQuery($query);
                 $updated = oseDB::query();
                 $result['finish'] = false;
                 $result['success'] = true;
                 $result['title'] = JText::_('SUCCESS');
                 $result['content'] = JText::_('SUCCESS');
             } elseif (substr($arb->getResponseCode(), 0, 1) == 'E') {
                 $vals['id'] = $oItem->member_id;
                 $vals['virtual_status'] = 0;
                 //$vals['status'] = 0;
                 $vals['eternal'] = 0;
                 //$vals['expired_date'] = oseHtml::getDateTime();
                 //oseDB::update('#__osemsc_member','id',$vals);
                 /*$ofVals = array();
                 		$ofVals['id'] = $oItem->fix_id;
                 		$ofVals['status'] = 'fixed';
                 		oseDB::update("#__osemsc_order_fix",'id',$ofVals);*/
                 $result['finish'] = true;
                 $result['success'] = false;
                 $result['title'] = JText::_('ERROR');
                 $result['content'] = $arb->getResponse();
             } else {
                 // update expired date
                 $vals['id'] = $oItem->member_id;
                 $vals['virtual_status'] = 0;
                 //$vals['status'] = 0;
                 $vals['eternal'] = 0;
                 //$vals['expired_date'] = oseHtml::getDateTime();
                 oseDB::update('#__osemsc_member', 'id', $vals);
                 /*$ofVals = array();
                 		$ofVals['id'] = $oItem->fix_id;
                 		$ofVals['status'] = 'fixed';
                 		oseDB::update("#__osemsc_order_fix",'id',$ofVals);*/
                 $result['finish'] = true;
                 $result['success'] = true;
                 $result['title'] = JText::_('SUCCESS');
                 $result['content'] = JText::_('SUCCESS');
             }
             return $result;
         }
         // if find expired date, updated it
     } else {
         $result['success'] = false;
         $result['title'] = JText::_('ERROR');
         $result['content'] = JText::_('Only Support Authorize');
         return $result;
     }
 }