Exemplo n.º 1
0
 function AuthorizeARBUpdateProfile($orderInfo, $credit_info, $params = array())
 {
     ini_set('max_execution_time', '180');
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_osemsc' . DS . 'libraries' . DS . 'class.connection.php';
     // Now proceed the Recurring payment plan creation;
     $db = oseDB::instance();
     $result = array();
     $user_id = $orderInfo->user_id;
     $msc_id = $orderInfo->entry_id;
     $order_id = $orderInfo->order_id;
     $order_number = $orderInfo->order_number;
     $orderInfoParams = oseJson::decode($orderInfo->params);
     // Get User billing information;
     $desc = $this->generateDesc($order_id);
     $billingInfo = $this->getBillingInfo($orderInfo->user_id);
     $taxRate = isset($orderInfoParams->tax_rate) ? $orderInfoParams->tax_rate : 0;
     // Reference ID;
     $refID = substr($order_number, 0, 19) . "A";
     $invoice = substr($order_number, 0, 19) . "A";
     $name = "MEM{$msc_id}UID{$user_id}_" . date("Ymdhis");
     // Credit Card Informaiton;
     $creditcard = $credit_info["creditcard_number"];
     $cardCode = $credit_info["creditcard_cvv"];
     $expiration = $credit_info["creditcard_expirationdate"];
     $expiration = strval($expiration);
     // Recurring payment setting;
     $msc = oseRegistry::call('msc');
     $ext = $orderInfoParams;
     //msc->getExtInfo($msc_id, 'payment', 'obj');
     $mscRegRecurrence = $this->AuthorizeAPITransInterval($orderInfoParams->t3, $orderInfoParams->p3);
     $totalOccurrences = 9999;
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_osemsc' . DS . 'libraries' . DS . 'AuthnetARB.class.php';
     $config = oseMscConfig::getConfig('payment', 'obj');
     $test_mode = $config->cc_testmode;
     $arbsubdomain = $test_mode ? 'apitest' : 'api';
     $arb = new AuthnetARB();
     $arb->url = $arbsubdomain . ".authorize.net";
     $arb->setParameter('cardNumber', $creditcard);
     $arb->setParameter('expirationDate', $expiration);
     $arb->setParameter('cardCode', $cardCode);
     $arb->setParameter('firstName', substr($billingInfo->firstname, 0, 50));
     $arb->setParameter('lastName', substr($billingInfo->lastname, 0, 50));
     $arb->setParameter('address', substr($billingInfo->addr1, 0, 60));
     $arb->setParameter('city', substr($billingInfo->city, 0, 60));
     $arb->setParameter('state', substr($billingInfo->state, 0, 40));
     $arb->setParameter('zip', substr($billingInfo->postcode, 0, 20));
     $arb->setParameter('subscrName', $name);
     // Assgin login credentials
     $arb->setParameter('login', $config->an_loginid);
     $arb->setParameter('transkey', $config->an_transkey);
     $arb->setParameter('refID', $refID);
     $arb->setParameter('subscrId', $orderInfo->payment_serial_number);
     // Create the recurring billing subscription
     $arb->updateCreditCard();
     $return = array();
     if ($arb->getResponseCode() == 'I00001') {
         return array('success' => true);
     } else {
         return array('success' => false, 'content' => $arb->getResponse());
     }
 }