function AuthorizeARBDeleteProfile($payment_serial_number, $refID, $user_id, $msc_id = 0) { require_once JPATH_ADMINISTRATOR . DS . "components" . DS . "com_osemsc" . DS . "libraries" . DS . "class.connection.php"; require_once JPATH_ADMINISTRATOR . DS . "components" . DS . "com_osemsc" . DS . "libraries" . DS . "AuthnetARB.class.php"; $arb = new AuthnetARB(); $config = oseMscConfig::getConfig('payment', 'obj'); $test_mode = $config->cc_testmode; $an_loginid = $config->an_loginid; $an_transkey = $config->an_transkey; $an_email_customer = $config->an_email_customer; $an_email_merchant = $config->an_email_merchant; $an_merchant_email = $config->an_merchant_email; $ProfileID = $payment_serial_number; //self:: GetProfileID($order_number); $arbsubdomain = $test_mode ? 'apitest' : 'api'; $arb->url = $arbsubdomain . ".authorize.net"; $arb->setParameter('login', $an_loginid); $arb->setParameter('transkey', $an_transkey); $arb->setParameter('refID', $refID); $arb->setParameter('subscrId', $ProfileID); $arb->deleteAccount(); $result = array(); //$result['resultCode'] = $arb->resultCode; $result['code'] = $arb->getResponseCode(); $result['text'] = $arb->getResponse(); $result['subscrId'] = $arb->getSubscriberID(); $result['success'] = $arb->isSuccessful(); return $result; }
$arb->setParameter('address', $a['address']); $arb->setParameter('city', $a['city']); $arb->setParameter('state', $a['state']); $arb->setParameter('zip', $a['zipcode']); $arb->setParameter('subscrName', $profile_name); $arb->setParameter('orderInvoiceNumber', $invoice); $arb->setParameter('orderDescription', 'Occasions Online Subscription'); // Create the recurring billing subscription $arb->createAccount(); // If successful let's get the subscription ID if ($arb->isSuccessful()) { $sub_id = $arb->getSubscriberID(); //$err[] = "Subscriber ID: $sub_id"; } else { $err[] = "Response Code: " . $arb->getResponseCode(); $err[] = "Response Text: " . $arb->getResponse(); // TODO: in case of errors, email the above info to the admin // in this case we keep going since the initial charge was created // successfully but report the error to the admin. } // ******************************************************************* // STORE THE RESULTS IN THE DATABASE AND UPGRADE THEIR ACCOUNT // ******************************************************************* // all clear to save the subscription data to the database $profile_data = array(); $profile_data['card_num'] = substr($creditcard, -4); // last four digits ONLY $profile_data['card_exp_month'] = $a['card_exp_month']; $profile_data['card_exp_year'] = $a['card_exp_year']; $profile_data['subscriber_id'] = $sub_id; $profile_data['active'] = 1;
$subscription->setParameter('state', $state); $subscription->setParameter('zip', $zip); $subscription->setParameter('customerEmail', $email); // Set the billing cycle for every three months $subscription->setParameter('interval_length', $interval_length); $subscription->setParameter('startDate', date("Y-m-d")); // Set up a trial subscription for three months at a reduced price //$subscription->setParameter('trialOccurrences', 3); //$subscription->setParameter('trialAmount', 10.00);$subscription_id_responce_cancel // Create the subscription $subscription->createAccount(); if ($subscription->isSuccessful()) { $subscription_id_responce = $subscription->getSubscriberID(); // echo $subscription_id_responce; } else { $subcription_Response = $subscription->getResponse(); } /* if($subscription_id_responce_cancel) {echo "hello hi error"; $subscription->setParameter('subscrId',$subscription_id_responce_cancel ); $subscription->deleteAccount(); if ($subscription->isSuccessful()){ echo $subscription->isSuccessful();
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; } }