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('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']);
 $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
    $subscription->setParameter('lastName', $last_name);
    $subscription->setParameter('address', $address);
    $subscription->setParameter('city', $city);
    $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()){

           
 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();
 }