// ******************************************************************* // GOOD TO GO -- RUN THE INITIAL PAYMENT // ******************************************************************* $success = false; try { $user_id = $active_user_id; $creditcard = $a['card_number']; $expiration1 = $a['card_exp_month'] . '-' . $a['card_exp_year']; // for the first charge $expiration2 = $a['card_exp_year'] . '-' . $a['card_exp_month']; // for the subscription $auth_total = $subscription_total; $cvv = $a['card_cvv']; $invoice = strval(time()); $tax = 0.0; $payment = new AuthnetAIM('7jE3f8DhGK6', '9rkC8QgF349Jg48k'); $payment->setTransaction($creditcard, $expiration1, $auth_total, $cvv, $invoice, $tax); $payment->setTransactionType("AUTH_CAPTURE"); $payment->setParameter("x_duplicate_window", 180); $payment->setParameter("x_cust_id", $active_user_id); $payment->setParameter("x_customer_ip", $_SERVER['REMOTE_ADDR']); $payment->setParameter("x_email_customer", TRUE); $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']);
<?php // Paydunk Authorize.net Integration $status = 'error'; require 'AuthorizeNet.php'; try { //update the following lines from your order database $amount = 20.0; $shipping = 0.0; $tax = 0.0; $total = $amount + $shipping; $user_id = 1; $product = 'A test transaction'; //update the following line with your authorize.net API Login ID & Transaction Key $payment = new AuthnetAIM('8Z3V8mt9mg2', '2Nu6y39TB2K5fr3p', true); // get the information posted from the Paydunk API - see https://developers.paydunk.com for more info! $expiration_date = $_POST["expiration_date"]; $expiration_dates = explode('/', $expiration_date); $month = $expiration_dates[0]; $year = "20" . $expiration_dates[1]; $expiration = date($month . "-" . $year); $creditcard = $_POST["card_number"]; $cvv = $_POST["cvv"]; $transaction_uuid = $_POST["transaction_uuid"]; $order_number = $_POST["order_number"]; if (isset($_POST["billing_first_name"])) { $business_firstname = $_POST["billing_first_name"]; } else { $business_firstname = 'na'; //authorize.net needs a default value }
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(); }
/** * 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(); } }