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();
 }
 $payment->setParameter("x_first_name", $a['card_name_first']);
 $payment->setParameter("x_last_name", $a['card_name_last']);
 $payment->setParameter("x_address", $a['address']);
 $payment->setParameter("x_city", $a['city']);
 $payment->setParameter("x_state", $a['state']);
 $payment->setParameter("x_zip", $a['zipcode']);
 $payment->setParameter("x_ship_to_first_name", $a['card_name_first']);
 $payment->setParameter("x_ship_to_last_name", $a['card_name_last']);
 $payment->setParameter("x_ship_to_address", $a['address']);
 $payment->setParameter("x_ship_to_city", $a['city']);
 $payment->setParameter("x_ship_to_state", $a['state']);
 $payment->setParameter("x_ship_to_zip", $a['zipcode']);
 $payment->setParameter("x_description", 'Occasions Initial Authorization');
 //$payment->setParameter("x_test_request", TRUE);
 $payment->process();
 if ($payment->isApproved()) {
     // Get info from Authnet to store in the database
     $authorization_code = $payment->getAuthCode();
     $avs_result = $payment->getAVSResponse();
     // 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
/**
 * Authorize and Prosses order using the AuthnetAIM.class.php class.
 * Fill object of the class ($payment), then send to process order,
 * this order then gives a echo for the payment error or recieved.
 * Tutorial: http://www.johnconde.net/blog/tutorial-integrating-the-authorizenet-aim-api-with-php/
 * @param  object $ccInfo Object containing info for the Authorize.NET API.
 * @return void
 */
function wc_AuthorizeCard($ccInfo)
{
    require 'AuthnetAIM.class.php';
    $payment = new AuthnetAIM("52H4eeYq", "7RD64g4h993VE6rp", true);
    $payment->setTransaction($ccInfo->getCreditCard(), $ccInfo->getExpiration(), $ccInfo->getTotal());
    $payment->setParameter("x_description", $ccInfo->getProduct());
    $payment->setParameter("x_email", $ccInfo->getEmail());
    $payment->setParameter("x_first_name", $ccInfo->getName());
    $payment->process();
    if ($payment->isApproved()) {
        echo "Payment Received/Approved";
    }
    if ($payment->isError()) {
        $error_number = $payment->getResponseSubcode();
        $error_message = $payment->getResponseText();
        echo $payment->getResponseMessage();
    }
}