Example #1
0
if (!isset($CustomerID)) {
    die('d4');
}
if (!isset($email)) {
    die('d5');
}
//
// DoExpressCheckoutPayment
//
// Add request-specific fields to the request string.
$nvpStr = PPAddNVPItem($itemName, $itemPrice, $custom);
$nvpStr .= "&TOKEN=" . $token;
$nvpStr .= "&PAYERID=" . $payerID;
$nvpStr .= "&PAYMENTACTION=" . "Sale";
//  Complete an Express Checkout transaction.
$httpParsedResponseAr = PPHttpPost('DoExpressCheckoutPayment', $nvpStr);
$ack = strtoupper($httpParsedResponseAr["ACK"]);
if ($ack != "SUCCESS" && $ack != "SUCCESSWITHWARNING") {
    exit('DoExpressCheckoutDetails failed: ' . urldecode(print_r($httpParsedResponseAr, true)));
}
//exit('Express Checkout Payment Completed Successfully: ' . urldecode(print_r($httpParsedResponseAr, true)));
//
// check if payment was successful
//
$PaymentStatus = urldecode($httpParsedResponseAr['PAYMENTINFO_0_PAYMENTSTATUS']);
if (strtoupper($PaymentStatus) != "COMPLETED") {
    echo "There was error in your payment: {$PaymentStatus}<br><br>";
    echo "Please include following information and e-mail it to support@thewarinc.com<br>";
    echo urldecode(print_r($httpParsedResponseAr, true));
    exit;
}
Example #2
0
    return $httpParsedResponseAr;
}
/**
 * This example assumes that this is the return URL in the SetExpressCheckout API call.
 * The PayPal website redirects the user to this page with a token.
 */
// Obtain the token from PayPal.
if (!array_key_exists('token', $_REQUEST)) {
    exit('Token is not received.');
}
// Set request-specific fields.
$token = urlencode(htmlspecialchars($_REQUEST['token']));
// Add request-specific fields to the request string.
$nvpStr = "&TOKEN={$token}";
// Execute the API operation; see the PPHttpPost function above.
$httpParsedResponseAr = PPHttpPost('GetExpressCheckoutDetails', $nvpStr);
if ("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) {
    // Extract the response details.
    $payerID = $httpParsedResponseAr['PAYERID'];
    $street1 = $httpParsedResponseAr["SHIPTOSTREET"];
    if (array_key_exists("SHIPTOSTREET2", $httpParsedResponseAr)) {
        $street2 = $httpParsedResponseAr["SHIPTOSTREET2"];
    }
    $city_name = $httpParsedResponseAr["SHIPTOCITY"];
    $state_province = $httpParsedResponseAr["SHIPTOSTATE"];
    $postal_code = $httpParsedResponseAr["SHIPTOZIP"];
    $country_code = $httpParsedResponseAr["SHIPTOCOUNTRYCODE"];
    exit('Get Express Checkout Details Completed Successfully: ' . print_r($httpParsedResponseAr, true));
} else {
    exit('GetExpressCheckoutDetails failed: ' . print_r($httpParsedResponseAr, true));
}
$emailSubject = urlencode($vEmailSubject);
$receiverType = urlencode('EmailAddress');
$currency = urlencode('USD');
// or other currency ('GBP', 'EUR', 'JPY', 'CAD', 'AUD')
// Receivers
// Use '0' for a single receiver. In order to add new ones: (0, 1, 2, 3...)
// Here you can modify to obtain array data from database.
$receivers = array(0 => array('receiverEmail' => "*****@*****.**", 'amount' => "1.00", 'uniqueID' => "id_001", 'note' => " payment of commissions"));
// space again at beginning.
$receiversLenght = count($receivers);
// Add request-specific fields to the request string.
$nvpStr = "&EMAILSUBJECT={$emailSubject}&RECEIVERTYPE={$receiverType}&CURRENCYCODE={$currency}";
$receiversArray = array();
for ($i = 0; $i < $receiversLenght; $i++) {
    $receiversArray[$i] = $receivers[$i];
}
foreach ($receiversArray as $i => $receiverData) {
    $receiverEmail = urlencode($receiverData['receiverEmail']);
    $amount = urlencode($receiverData['amount']);
    $uniqueID = urlencode($receiverData['uniqueID']);
    $note = urlencode($receiverData['note']);
    $nvpStr .= "&L_EMAIL{$i}={$receiverEmail}&L_Amt{$i}={$amount}&L_UNIQUEID{$i}={$uniqueID}&L_NOTE{$i}={$note}";
}
// Execute the API operation; see the PPHttpPost function above.
$httpParsedResponseAr = PPHttpPost('MassPay', $nvpStr);
if ("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) {
    print $httpParsedResponseAr['ACK'];
    exit('MassPay Completed Successfully: ' . print_r($httpParsedResponseAr, true));
} else {
    exit('MassPay failed: ' . print_r($httpParsedResponseAr, true));
}
$shipping_cost = 0;
$totaltaxrate = number_format($_SESSION["TAX_TOTAL"], 2, ".", "");
//shipping cost
$shipping_cost = number_format($_SESSION['SHIPPING_TOTAL'], 2, ".", "");
$paymentMethod = "CC";
$gift_coupon_flag = 0;
$currencyCode = getSettingsValue("admin_currency");
$currencyID = urlencode($currencyCode);
$paymentsuccessful = false;
$paymenterror = "";
// Keep this as Authorization always
$paymentType = urlencode('Authorization');
// or 'Sale'
$nvpStr = "&PAYMENTACTION={$paymentType}&AMT={$totaltopay}&CREDITCARDTYPE={$txtCardType}&ACCT={$txtCardNumber}" . "&EXPDATE={$padDateMonth}{$txtExpYear}&CVV2={$txtCVV}&FIRSTNAME={$txtFirstName}&LASTNAME={$txtLastName}" . "&STREET={$txtAddress1}&CITY={$txtCity}&STATE={$txtState}&ZIP={$txtZIP}&COUNTRYCODE={$txtCountry}&CURRENCYCODE={$currencyID}";
// Execute the API operation; see the PPHttpPost function above.
$httpParsedResponseAr = PPHttpPost('DoDirectPayment', $nvpStr);
if ("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) {
    //exit('Direct Payment Completed Successfully: <br>'.print_r($httpParsedResponseAr, true));
    $paymentsuccessful = true;
    if (isset($_SESSION['couponCode_det']) && $_SESSION['couponCode_det'] != '') {
        $nameCouponCode = ",couponCode,couponCodeDiscount";
        $valueCouponCode = ',"' . $_SESSION['couponCode_det']['ccCode'] . '",' . $_SESSION['couponCode_det']['ccDiscount'];
        echo $sql_updatecouponCode = "UPDATE  " . $tableprefix . "couponCode SET subscriptionStatus='N' WHERE ccID =" . $_SESSION['couponCode_det']['ccID'];
        mysql_query($sql_updatecouponCode);
        unset($_SESSION['couponCode_det']);
    }
    if ($paymentsuccessful) {
        // check if credit card payment is success
        $amountpaid = number_format($_SESSION['amount_paid'], 2, ".", "");
        $sql = "INSERT INTO  " . $tableprefix . "orders (\n\t\t\t\tuser_id,\n\t\t\t\tbilling_first_name,\n\t\t\t\tbilling_last_name,\n\t\t\t\tbilling_address1,\n\t\t\t\tbilling_address2,\n\t\t\t\tbilling_city,\n\t\t\t\tbilling_state,\n\t\t\t\tbilling_country,\n\t\t\t\tbilling_zip,\n\t\t\t\tbilling_fax,\n\t\t\t\tbilling_email,\n\t\t\t\tbilling_phone,\n\t\t\t\tshipping_first_name,\n\t\t\t\tshipping_last_name,\n\t\t\t\tshipping_address1,\n\t\t\t\tshipping_address2,\n\t\t\t\tshipping_city,\n\t\t\t\tshipping_state,\n\t\t\t\tshipping_country,\n\t\t\t\tshipping_zip,\n\t\t\t\tshipping_fax,\n\t\t\t\tshipping_email,\n\t\t\t\tshipping_phone,\n\t\t\t\tprefered_shippin_method,\n\t\t\t\torder_date,\n\t\t\t\torder_total_price,\n\t\t\t\ttaxrate,\n\t\t\t\torder_status,\n\t\t\t\ttransaction_id,\n\t\t\t\tvorder_currency" . $nameCouponCode . ",\n\t\t\t\tnamount_paid,\n                                buyer_comments,\n                                vpayment_status\n\t\t\t\t) VALUES(\n\t\t\t\t'" . addslashes($_SESSION["sess_userid"]) . "',\n\t\t\t\t'" . addslashes($_SESSION["sessBillingFirstName"]) . "',\n\t\t\t\t'" . addslashes($_SESSION["sessBillingLastName"]) . "',\n\t\t\t\t'" . addslashes($_SESSION["sessBillingAddress1"]) . "',\n\t\t\t\t'" . addslashes($_SESSION["sessBillingAddress2"]) . "',\n\t\t\t\t'" . addslashes($_SESSION["sessBillingCity"]) . "',\n\t\t\t\t'" . addslashes($_SESSION["sessBillingState"]) . "',\n\t\t\t\t'" . addslashes($_SESSION["sessBillingCountry"]) . "',\n\t\t\t\t'" . addslashes($_SESSION["sessBillingZIP"]) . "',\n\t\t\t\t'" . addslashes($_SESSION["sessBillingFAX"]) . "',\n\t\t\t\t'" . addslashes($_SESSION["sessBillingEmail"]) . "',\n\t\t\t\t'" . addslashes($_SESSION["sessBillingPhone"]) . "',\n\t\t\t\t'" . addslashes($_SESSION["sessShippingFirstName"]) . "',\n\t\t\t\t'" . addslashes($_SESSION["sessShippingLastName"]) . "',\n\t\t\t\t'" . addslashes($_SESSION["sessShippingAddress1"]) . "',\n\t\t\t\t'" . addslashes($_SESSION["sessShippingAddress2"]) . "',\n\t\t\t\t'" . addslashes($_SESSION["sessShippingCity"]) . "',\n\t\t\t\t'" . addslashes($_SESSION["sessShippingState"]) . "',\n\t\t\t\t'" . addslashes($_SESSION["sessShippingCountry"]) . "',\n\t\t\t\t'" . addslashes($_SESSION["sessShippingZIP"]) . "',\n\t\t\t\t'" . addslashes($_SESSION["sessShippingFAX"]) . "',\n\t\t\t\t'" . addslashes($_SESSION["sessShippingEmail"]) . "',\n\t\t\t\t'" . addslashes($_SESSION["sessShippingPhone"]) . "',\n\t\t\t\t'" . addslashes($_SESSION["sessShippingDisplayName"]) . "',\n\t\t\t\tnow(),\n\t\t\t\t'" . addslashes($totaltopay) . "',\n\t\t\t\t'" . addslashes($totaltaxrate) . "',\n\t\t\t\t'1',\n\t\t\t\t'" . addslashes($tx_token) . "',\n\t\t\t\t'" . $currency_attributes[2] . "'" . $valueCouponCode . ",\n\t\t\t\t'" . addslashes($amountpaid) . "',\n                                '" . addslashes($_SESSION["SESS_BUYER_COMMENTS"]) . "',\n                                'C'\n\t\t\t\t)";
        mysql_query($sql);
$DESC = urlencode("Some Text");
$creditCardType = urlencode("Visa");
$creditCardAccount = urlencode("4647878288359292");
//$creditCardAccount = urlencode("4779297617944965");
$cardExpireDate = urlencode("102017");
$cardCvv2 = urlencode("111");
$PAYERSTATUS = urlencode("verified");
$STREET = urlencode("Stockholm");
$CITY = urlencode("Stockholm");
$STATE = urlencode("CA");
$COUNTRYCODE = urlencode("US");
$ZIP = urlencode("95131");
$FIRSTNAME = urlencode("Test");
$LASTNAME = urlencode("TAHER");
$EMAIL = urlencode("*****@*****.**");
$INITAMT = urlencode("20.00");
$FAILEDINITAMTACTION = urlencode("ContinueOnFailure");
$MAXFAILEDPAYMENTS = urlencode("10");
$ITEMCATEGORY0 = urlencode("Digital");
$ITEMNAME0 = urlencode("Item Name");
$ITEMAMT0 = urlencode("10");
$ITEMQTY0 = urlencode("1");
$nvpStr = "&AMT={$paymentAmount}&CURRENCYCODE={$currencyID}&PROFILESTARTDATE={$startDate}";
$nvpStr .= "&BILLINGPERIOD={$billingPeriod}&BILLINGFREQUENCY={$billingFreq}&DESC={$DESC}&CREDITCARDTYPE={$creditCardType}&ACCT={$creditCardAccount}&EXPDATE={$cardExpireDate}&CVV2={$cardCvv2}&PAYERSTATUS={$PAYERSTATUS}&STREET={$STREET}\n&CITY={$CITY}&COUNTRYCODE={$COUNTRYCODE}&ZIP={$ZIP}&FIRSTNAME={$FIRSTNAME}&LASTNAME={$LASTNAME}\n&INITAMT={$INITAMT}&FAILEDINITAMTACTION={$FAILEDINITAMTACTION}&MAXFAILEDPAYMENTS={$MAXFAILEDPAYMENTS}\n&L_PAYMENTREQUEST_0_ITEMCATEGORY0={$ITEMCATEGORY0}&L_PAYMENTREQUEST_0_NAME0={$ITEMNAME0}\n&L_PAYMENTREQUEST_0_AMT0={$ITEMAMT0}&L_PAYMENTREQUEST_0_QTY0={$ITEMQTY0}";
$httpParsedResponseAr = PPHttpPost('CreateRecurringPaymentsProfile', $nvpStr);
if ("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) {
    echo $httpParsedResponseAr['TRANSACTIONID'];
    exit('CreateRecurringPaymentsProfile Completed Successfully: ' . print_r($httpParsedResponseAr, true));
} else {
    exit('CreateRecurringPaymentsProfile failed: ' . print_r($httpParsedResponseAr, true));
}
Example #6
0
 function process_order()
 {
     //post from shipping info form
     if (isset($_SESSION['cart'])) {
         //validation
         $this->load->helper('email');
         $error = '';
         $name = $this->input->post('name', true);
         if (!$name || $name == '' || strlen($name) < 4) {
             $error .= "<div class='error'>*Name should be no less than 4 letters.</div>";
         }
         $email = $this->input->post('email', true);
         if ($email == '' || !valid_email($email)) {
             $error .= "<div class='error'>*Please check email address.</div>";
         }
         //$phone = $this->input->post('phone', true);
         //if ($phone == '' || strlen($phone) < 10) $error .= "<div class='error'>*Invalid phone, include area code.</div>";
         $street = $this->input->post('street', true);
         if ($street == '' || strlen($street) < 7) {
             $error .= "<div class='error'>*Invalid street address</div>";
         }
         $city = $this->input->post('city', true);
         if ($city == '' || strlen($city) < 2) {
             $error .= "<div class='error'>*Enter a city</div>";
         }
         $state = $this->input->post('state', true);
         if ($state == '..' || strlen($state) < 2) {
             $error .= "<div class='error'>*Select a state</div>";
         }
         $zip = $this->input->post('zip', true);
         if ($zip == '' || strlen($zip) < 5 || !is_numeric($zip)) {
             $error .= "<div class='error'>*Enter a valid zip code.</div>";
         }
         $comment = $this->input->post('comment', true);
         $_SESSION['comment'] = $comment;
         //last minute check to see if items in cart are still in stock
         $stock = $this->in_stock($_SESSION['cart']);
         if (!$stock['all_available']) {
             //Not all items are in stock
             $depleted = '';
             //$items_to_unset = array();
             //get the Names of the items that are depleted
             foreach ($stock['results'] as $array => $item) {
                 if ($item['quantity'] < 0) {
                     $depleted .= ucwords($item['title']) . " is out of stock.<br />";
                     //delete items that have been depleted from the inventory while the user was shopping
                     $this->cart_model->delete_from_cart($item['id']);
                 }
             }
             $error .= "<div class='error'>" . $depleted . "</div>";
         }
         if ($error) {
             $this->session->set_flashdata('error', $error);
             redirect('cart/confirm_order');
         }
         //END validation
         //overwrite in case user corrects the form values at the confirm order page
         $_SESSION['name'] = $name;
         $_SESSION['email'] = $email;
         $_SESSION['street'] = $street;
         $_SESSION['city'] = $city;
         $_SESSION['state'] = $state;
         $_SESSION['zip'] = $zip;
         $data['view'] = "success_view";
         $title = "Thank You For Your Order";
         //if they left the 'send me updates' checked, insert them into the subscribers table
         if ($this->input->post('optin', true)) {
             $this->db->insert('subscribers', array('email' => $email, 'name' => $name));
         }
         //if order is from florida, this later
         if ($state == 'FL') {
             $_SESSION['fl'] = 'y';
         } else {
             $_SESSION['fl'] = 'n';
         }
         // save the order
         $shipping_id = $this->cart_model->save_shipping();
         $order_id = $this->cart_model->save_order($shipping_id);
         //diminish item quantities from inventory
         if ($order_id > 0) {
             $items = array();
             foreach ($_SESSION['cart'] as $id => $item) {
                 array_push($items, array('id' => $id, 'quantity' => $item['quantity']));
             }
             $updated = $this->cart_model->update_inventory($items);
         }
         if ($updated > 0) {
             //if update successful
             //Do Express PayPal Checkout
             $payerID = urlencode($_SESSION['payer_id']);
             $token = urlencode($_SESSION['token']);
             $paymentType = urlencode("Sale");
             // or 'Sale' or 'Order'
             $paymentAmount = urlencode(number_format($_SESSION['total_price'], 2, '.', ''));
             $currencyID = urlencode("USD");
             // or other currency code ('GBP', 'EUR', 'JPY', 'CAD', 'AUD')
             // Add request-specific fields to the request string.
             $this->nvpStr .= "&TOKEN={$token}&PAYERID={$payerID}&PAYMENTACTION={$paymentType}&AMT={$paymentAmount}&CURRENCYCODE={$currencyID}";
             //die($nvpStr);
             // Execute the API operation; see the PPHttpPost function above.
             $httpParsedResponseAr = PPHttpPost('DoExpressCheckoutPayment', $this->nvpStr);
             if ("Success" == $httpParsedResponseAr["ACK"]) {
                 //put the cart variables in a temporary variable
                 $data['view_data']['final_array'] = $_SESSION;
                 //finally, destroy the cart and user info
                 $_SESSION = array();
                 session_destroy();
                 //exit('Express Checkout Payment Completed Successfully: <pre>'.print_r($httpParsedResponseAr, true));
             } else {
                 $this->paypal_error($httpParsedResponseAr);
             }
         } else {
             $this->test("Failed to update inventory <br />Items: ", $items);
         }
         $data['view'] = "success_view";
         $this->load_headers($title, $data);
         $this->load->view('main_view', $this->data);
     } else {
         redirect('cart/view');
     }
 }
Example #7
0
function sendCCPayment($domain, $databaseName, $fname, $lname, $company, $ref_ids, $email, $phone, $street, $city, $state, $zip, $country, $card_type, $card_number, $cvv, $exp_date, $total, $sub_amt, $can_contact, $ip, $lm_type, $lm_description, $lm_user_id)
{
    //collect confirmed payees and run paypal transaction
    // Set request-specific fields.
    $currency = 'USD';
    // or other currency ('GBP', 'EUR', 'JPY', 'CAD', 'AUD')
    //build nvp string
    $nvp = '';
    $nvp .= '&PAYMENTACTION=Sale';
    $nvp .= '&IPADDRESS=' . urlencode($ip);
    $nvp .= '&AMT=' . urlencode($total);
    $nvp .= '&CURRENCYCODE=' . urlencode($currency);
    $nvp .= '&CREDITCARDTYPE=' . urlencode($card_type);
    $nvp .= '&ACCT=' . urlencode($card_number);
    $nvp .= '&EXPDATE=' . urlencode($exp_date);
    $nvp .= '&CVV2=' . urlencode($cvv);
    $nvp .= '&FIRSTNAME=' . urlencode($fname);
    $nvp .= '&LASTNAME=' . urlencode($lname);
    $nvp .= '&STREET=' . urlencode($street);
    $nvp .= '&CITY=' . urlencode($city);
    $nvp .= '&STATE=' . urlencode($state);
    $nvp .= '&ZIP=' . urlencode($zip);
    $nvp .= '&COUNTRYCODE=' . urlencode($country);
    // store customer data if required, return customer_id for payment
    $cust = storeCustomerData($domain, $fname, $lname, $company, $ref_ids, $email, $phone, $street, $city, $state, $zip, $country, $can_contact);
    if (isset($cust["error"])) {
        return array('error' => "Buyer", 'errorMsg' => "Error in Buyer Creation: " . $cust["error"]);
    } else {
        $cust = $cust['customer_id'];
    }
    $buyer = storeBuyerData($cust, $fname, $lname, $company, $email, $phone, $street, $city, $state, $zip, $country);
    if (isset($ret["error"])) {
        return array('error' => "Buyer", 'errorMsg' => "Error in Buyer Creation: " . $ret["error"]);
    }
    $buyer_id = $buyer["buyer_id"];
    //  $instance = getInstanceNameFromDomain($domain);
    $instance = $databaseName;
    if ($instance == "") {
        return array('error' => "Invalid domain", 'errorMsg' => "Invalid domain: " . $domain);
    }
    $ret = changeCampaignStatus($ref_ids, "R", $instance);
    if (isset($ret["error"])) {
        return array('error' => "Recognition", 'errorMsg' => "Error in Recognition Period Update (R): " . $ret["error"]);
    }
    // Execute the API operation; see the PPHttpPost function in the paypal-functions.php file.
    $PPResponseAr = PPHttpPost('DoDirectPayment', $nvp);
    $warningMsg = "";
    if (isset($PPResponseAr["ACK"])) {
        $transactionID = "";
        if (isset($PPResponseAr["TRANSACTIONID"])) {
            $transactionID = $PPResponseAr["TRANSACTIONID"];
        }
        $longMessage = "";
        if (isset($PPResponseAr["L_LONGMESSAGE0"])) {
            $longMessage = urldecode($PPResponseAr["L_LONGMESSAGE0"]);
        }
        $save = storePaymentData($cust, $card_type, $PPResponseAr["ACK"], $total, $sub_amt, $transactionID, $ip, $lm_type, $domain, $ref_ids, $lm_description, $lm_user_id, $buyer_id, $longMessage);
        if (isset($save['error'])) {
            $payment = -1;
            $warningMsg .= '<p>Warning: ' . $save['error'] . "</p>";
        } else {
            $payment = $save['payment_id'];
        }
    }
    if (isset($PPResponseAr["ACK"]) && ("SUCCESS" == strtoupper($PPResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($PPResponseAr["ACK"]))) {
        $ret = changeCampaignStatus($ref_ids, "Y", $instance);
        if (isset($ret["error"])) {
            $warningMsg .= "<p>Warning: Error in Recognition Period Update (Y), " . $ret["error"] . "</p>";
        }
        $invoice = 1000000 + intval($payment);
        $invoice = $cust . '' . $invoice;
        //payment posted
        /**
         *   $PPResponseAr["TIMESTAMP"] 
         *   $PPResponseAr["CORRELATIONID"]
         *   $PPResponseAr["ACK"]
         *   $PPResponseAr["VERSION"] 
         *   $PPResponseAr["BUILD"]
         *   $PPResponseAr["AMT"]
         *   $PPResponseAr["CURRENCYCODE"] 
         *   $PPResponseAr["AVSCODE"] //X 
         *   $PPResponseAr["CVV2MATCH"]  //M
         *   $PPResponseAr["TRANSACTIONID"]
         */
        $name = $fname . ' ' . $lname;
        success_notify($name, $email, $company, $street, $city, $state, $zip, $country, $phone, $lm_description, $total, $invoice, $PPResponseAr["TRANSACTIONID"]);
        $messJournal = "A payment has been made for a Recognition Period!";
        if ("SUCCESSWITHWARNING" == strtoupper($PPResponseAr["ACK"])) {
            $messJournal .= " Warning in Paypal transaction.";
        }
        // Make a notice in journal
        $data = array('user' => JOURNAL_API_USER, 'pwd' => sha1(JOURNAL_API_PWD), 'message' => $messJournal);
        ob_start();
        $res = CURLHandler::Post(JOURNAL_API_URL, $data);
        ob_end_clean();
        $ret = array('success' => strtoupper($PPResponseAr["ACK"]), 'transactionID' => $PPResponseAr["TRANSACTIONID"], 'warning' => $warningMsg);
    } else {
        // We are not in an asynchronous process so put back the campaign in card
        $ret = changeCampaignStatus($ref_ids, "C", $instance);
        if (isset($ret["error"])) {
            $warningMsg .= "<p>Warning: Error in Recognition Period Update (N), " . $ret["error"] . "</p>";
        }
        if (isset($PPResponseAr["L_SEVERITYCODE0"])) {
            $errorMsg = $PPResponseAr["ACK"] . ", " . $PPResponseAr["L_SEVERITYCODE0"] . ': ' . urldecode($PPResponseAr["L_SHORTMESSAGE0"]) . ' (' . $PPResponseAr["L_ERRORCODE0"] . ') - ' . urldecode($PPResponseAr["L_LONGMESSAGE0"]) . $warningMsg;
        } else {
            $errorMsg = $PPResponseAr["ACK"] . ", " . $PPResponseAr["errorMsg"] . $warningMsg;
        }
        fail_notify($fname . ' ' . $lname, $email, $company, $street, $city, $state, $zip, $country, $phone, $lm_description, $total, $errorMsg);
        if (isset($PPResponseAr["L_SEVERITYCODE0"])) {
            $ret = array('error' => $PPResponseAr["L_ERRORCODE0"], 'errorMsg' => $errorMsg);
        } else {
            $ret = array('error' => $PPResponseAr["ACK"], 'errorMsg' => $errorMsg);
        }
    }
    return $ret;
}
        $tmpAr = explode("=", $value);
        if (sizeof($tmpAr) > 1) {
            $httpParsedResponseAr[$tmpAr[0]] = $tmpAr[1];
        }
    }
    if (0 == sizeof($httpParsedResponseAr) || !array_key_exists('ACK', $httpParsedResponseAr)) {
        exit("Invalid HTTP Response for POST request({$nvpreq}) to {$API_Endpoint}.");
    }
    return $httpParsedResponseAr;
}
// Set request-specific fields.
$PROFILEID = urlencode('I-VBFVA5NB8XJD');
// Add request-specific fields to the request string.
$nvpStr = "&PROFILEID={$PROFILEID}";
// Execute the API operation; see the PPHttpPost function above.
$recurringPaymentProfileDetails = PPHttpPost('GetRecurringPaymentsProfileDetails', $nvpStr);
echo "Current date: " . date("H:i:s");
if ("SUCCESS" == strtoupper($recurringPaymentProfileDetails["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($recurringPaymentProfileDetails["ACK"])) {
    $data_org_billing_success['next_scheduled_billing_date'] = str_replace('%2d', '-', $recurringPaymentProfileDetails['NEXTBILLINGDATE']);
    $data_org_billing_success['next_scheduled_billing_date'] = str_replace('%3a', ':', $data_org_billing_success['next_scheduled_billing_date']);
    $data_org_billing_success['no_of_billing_cycle_completed'] = "no_of_billing_cycle_completed+1";
    $data_org_billing_success['no_of_billing_cycle_remaining'] = "total_billing_cycle-no_of_billing_cycle_completed";
    $data_org_billing_success['current_outstanding_balance'] = str_replace('%2e', '.', $recurringPaymentProfileDetails['OUTSTANDINGBALANCE']);
    $data_org_billing_success['amount_of_last_successful_payment'] = str_replace('%2e', '.', $recurringPaymentProfileDetails['LASTPAYMENTAMT']);
    $data_org_billing_success['total_paid_amount'] = "total_paid_amount+" . $data_org_billing_success['amount_of_last_successful_payment'];
    $data_org_billing_success['date_of_last_successful_payment'] = str_replace('%2d', '-', $recurringPaymentProfileDetails['LASTPAYMENTDATE']);
    $data_org_billing_success['date_of_last_successful_payment'] = str_replace('%3a', ':', $data_org_billing_success['date_of_last_successful_payment']);
    print_r($data_org_billing_success);
    exit;
    exit('GetTransactionDetails Completed Successfully: ' . print_r($recurringPaymentProfileDetails, true));
} else {
        }
    }
    if (0 == sizeof($httpParsedResponseAr) || !array_key_exists('ACK', $httpParsedResponseAr)) {
        exit("Invalid HTTP Response for POST request({$nvpreq}) to {$API_Endpoint}.");
    }
    return $httpParsedResponseAr;
}
// Set request-specific fields.
$paymentAmount = urlencode('example_payment_amuont');
$currencyID = urlencode('USD');
// or other currency code ('GBP', 'EUR', 'JPY', 'CAD', 'AUD')
$paymentType = urlencode('Authorization');
// or 'Sale' or 'Order'
$returnURL = urlencode("my_return_url");
$cancelURL = urlencode('my_cancel_url');
// Add request-specific fields to the request string.
$nvpStr = "&Amt={$paymentAmount}&ReturnUrl={$returnURL}&CANCELURL={$cancelURL}&PAYMENTACTION={$paymentType}&CURRENCYCODE={$currencyID}";
// Execute the API operation; see the PPHttpPost function above.
$httpParsedResponseAr = PPHttpPost('SetExpressCheckout', $nvpStr);
if ("Success" == $httpParsedResponseAr["ACK"]) {
    // Redirect to paypal.com.
    $token = urldecode($httpParsedResponseAr["TOKEN"]);
    $payPalURL = "https://www.paypal.com/webscr&cmd=_express-checkout&token={$token}";
    if ("sandbox" === $environment || "beta-sandbox" === $environment) {
        $payPalURL = "https://www.{$environment}.paypal.com/webscr&cmd=_express-checkout&token={$token}";
    }
    header("Location: {$payPalURL}");
    exit;
} else {
    exit('SetExpressCheckout failed: ' . print_r($httpParsedResponseAr, true));
}
Example #10
-1
 /**
  * New Customer Registration Form:Step4 and it's final step
  *
  *@access public
  *@return Confirmation or Error Message
  */
 function added_customer_step4($start = 0)
 {
     $to_date = date("Y-m-d H:i:s");
     $this->load->library('form_validation');
     $data_organization['organization_data'] = $this->input->post("organization_data");
     $data_admin_user['admin_user_data'] = $this->input->post("admin_user_data");
     $data['category_name'] = $this->input->post("data_category");
     if (sizeof($data_organization['organization_data']) <= 1 || sizeof($data_admin_user['admin_user_data']) <= 1) {
         redirect("main/add_customer");
     }
     $card_info['credit_card_no'] = $this->input->post("credit_card_no");
     $card_info['credit_card_type'] = $this->input->post("credit_card_type");
     $card_info['credit_card_verification_code'] = $this->input->post("credit_card_verification_code");
     $card_info['card_expire_date_month'] = $this->input->post("card_expire_date_month");
     $card_info['card_expire_date_year'] = $this->input->post("card_expire_date_year");
     $billing_data = $this->input->post("admin_user_data");
     $form_data_billing = array('billing_terms_condition' => "", 'bill_first_name' => $billing_data["first_name"], 'bill_last_name' => $billing_data["last_name"], 'bill_phone_no' => $billing_data["phone_no"], 'bill_email' => $billing_data["email"], 'bill_primary_address' => $billing_data["primary_address"], 'bill_optional_address' => $billing_data["optional_address"], 'bill_zip' => $billing_data["zip"], 'bill_city' => $billing_data["city"], 'bill_country' => $billing_data["country"], 'bill_state' => $billing_data["state"], 'add_date' => $to_date);
     $this->lang->load('customer', $this->session->userdata('lang_file'));
     $this->data['mainTab'] = 'customer';
     $this->data['activeTab'] = 'customer';
     $form_data_step4 = array('payment_method' => $this->input->post("payment_method"), 'bill_first_name' => $this->input->post("bill_first_name"), 'bill_last_name' => $this->input->post("bill_last_name"), 'bill_phone_no' => $this->input->post("bill_phone_no"), 'bill_email' => $this->input->post("bill_email"), 'bill_primary_address' => $this->input->post("bill_primary_address"), 'bill_optional_address' => $this->input->post("bill_optional_address"), 'bill_zip' => $this->input->post("bill_zip"), 'bill_city' => $this->input->post("bill_city"), 'bill_country' => $this->input->post("bill_country"), 'bill_state' => $this->input->post("bill_state"), 'billing_terms_condition' => $this->input->post("billing_terms_condition"), 'credit_card_no' => $this->input->post("credit_card_no"), 'credit_card_type' => $this->input->post("credit_card_type"), 'credit_card_verification_code' => $this->input->post("credit_card_verification_code"), 'credit_card_expire_month' => $this->input->post("card_expire_date_month"), 'credit_card_expire_year' => $this->input->post("card_expire_date_year"), 'name_on_credit_card' => $this->input->post("name_on_credit_card"), 'add_date' => $to_date);
     //Start Validate Credit Card Info
     $cardErrorNo = -1;
     //NO card error, card is valid
     $payment_method = $this->input->post("payment_method");
     if ($payment_method == "creditcard") {
         $this->form_validation->set_rules('name_on_credit_card', $this->lang->line('label_name_on_card'), 'trim|required');
         if (checkCreditCard($card_info, $errornumber, $errortext)) {
             //$errortext = 'This card has a valid format';
             //echo 'card OK';
         } else {
             $cardErrorNo = $errornumber;
         }
     }
     //End Validate Credit Card Info
     $data_billing_address['billing_address_data'] = $form_data_step4;
     $this->load->vars($form_data_step4);
     $this->load->vars($data_admin_user);
     $this->load->vars($data_organization);
     $this->form_validation->set_rules('bill_first_name', $this->lang->line('label_first_name'), 'trim|required');
     $this->form_validation->set_rules('bill_last_name', $this->lang->line('label_last_name'), 'trim|required');
     $this->form_validation->set_rules('bill_phone_no', $this->lang->line('label_phone'), 'trim|required');
     $this->form_validation->set_rules('bill_email', $this->lang->line('label_email'), 'trim|required|valid_email|xss_clean|callback_email_check');
     $this->form_validation->set_rules('bill_primary_address', $this->lang->line('label_address_line_one'), 'trim|required|xss_clean');
     $this->form_validation->set_rules('bill_zip', $this->lang->line('label_zip'), 'trim|required|xss_clean');
     $this->form_validation->set_rules('bill_city', $this->lang->line('label_city'), 'trim|required|xss_clean');
     $this->form_validation->set_rules('bill_country', $this->lang->line('label_country'), 'trim|required|xss_clean');
     $this->form_validation->set_rules('bill_state', $this->lang->line('label_state'), 'trim|required|xss_clean');
     //$this->form_validation->set_message('required', $this->lang->line('label_billing_terms_condition'));
     $this->form_validation->set_rules('billing_terms_condition', $this->lang->line('label_billing_terms_condition'), 'trim|xss_clean|callback_billing_terms_condition_check');
     if ($this->form_validation->run() == FALSE || $cardErrorNo != -1) {
         $error_credit_card = array();
         $error_credit_card['credit_card_type_unknown_error'] = "";
         $error_credit_card['credit_card_no_error'] = "";
         $error_credit_card['credit_card_cvv2_wrong_error'] = "";
         $error_credit_card['credit_card_expired_error'] = "";
         switch ($cardErrorNo) {
             case 0:
                 $error_credit_card['credit_card_type_unknown_error'] = $this->lang->line('credit_card_type_unknown_error');
                 break;
             case 1:
                 $error_credit_card['credit_card_no_error'] = $this->lang->line('credit_card_empty_error');
                 break;
             case 2:
                 $error_credit_card['credit_card_no_error'] = $this->lang->line('credit_card_no_format_invalid_error');
                 break;
             case 3:
                 $error_credit_card['credit_card_no_error'] = $this->lang->line('credit_card_no_invalid_error');
                 break;
             case 4:
                 $error_credit_card['credit_card_no_error'] = $this->lang->line('credit_card_no_length_wrong_error');
                 break;
             case 5:
                 $error_credit_card['credit_card_cvv2_wrong_error'] = $this->lang->line('credit_card_cvv2_wrong_error');
                 break;
             case 6:
                 $error_credit_card['credit_card_expired_error'] = $this->lang->line('credit_card_expired_error');
                 break;
         }
         $this->data['payment_method'] = $payment_method;
         $this->load->vars($data);
         $this->load->vars($error_credit_card);
         $this->load->vars($form_data_billing);
         $this->data['dynamicView'] = 'pages/member/new_customer/entry_step3';
         $this->_commonPageLayout('frontend_viewer');
     } else {
         ///Organization Registration Final Step
         $first_name = $data_admin_user['admin_user_data']['first_name'];
         $rand_no = mt_rand(1000000000, 2000000000);
         $first_name = substr($first_name, 0, 2);
         $password = $first_name . $rand_no;
         $password2 = $this->encrypt($password, 'vaccitvassit');
         $data_admin_user['admin_user_data']['password'] = $password2;
         $data_admin_user['admin_user_data']['admin_user'] = 1;
         //$rand_pass = base64_encode($c);
         $data_global_settings['global_settings_data'] = $this->info_model->get_global_settings();
         // print_r($data['global_settings_data']);
         if ($data_global_settings['global_settings_data']) {
             foreach ($data_global_settings['global_settings_data'] as $rows) {
                 $data_organization['organization_data']['org_allowed_sms_per_month'] = $rows->allowed_sms_per_month;
                 $data_organization['organization_data']['org_allowed_letter_per_month'] = $rows->allowed_letter_per_month;
                 $per_invoice_cost = $rows->per_invoice_cost;
             }
         }
         if ($data['category_name'] != "") {
             $data_val['category_name'] = $data['category_name'];
             $cat_id = $this->info_model->org_category_insert($data_val);
             $data_organization['organization_data']['org_category'] = $cat_id;
         }
         $last_insert_ids = $this->info_model->register_organisation($data_organization['organization_data'], $data_admin_user['admin_user_data'], $form_data_step4);
         //$this->load->vars($form_data_step3);
         if (sizeof($last_insert_ids) > 0) {
             $package_id = $data_organization['organization_data']['package_name'];
             $data['package_info'] = $this->info_model->get_package($package_id);
             if ($data['package_info']) {
                 foreach ($data['package_info'] as $rows) {
                     $currency_info = $this->info_model->get_currency($rows->currency_id);
                 }
                 $package_name = $rows->package_name;
                 $no_of_member = $rows->no_of_member;
                 $amount = $rows->amount;
                 $duration = $rows->duration;
                 $sms_cost = $rows->sms_cost;
                 $letter_cost = $rows->letter_cost;
                 if ($currency_info) {
                     foreach ($currency_info as $currency) {
                         $currency_name = $currency->currency_name;
                     }
                     $package_details = "Package: " . $package_name . "_" . $package_id;
                 }
             }
             ////////////////// Payment Method: Start ////////////
             if ($payment_method == "creditcard") {
                 //$token = urlencode("token_from_setExpressCheckout");
                 $TOTALBILLINGCYCLES = urlencode($duration);
                 if ($duration > 12) {
                     $TOTALBILLINGCYCLES = urlencode("12");
                 }
                 // combination of this and billingPeriod must be at most a year
                 $bill_start_date_mins = date("i");
                 $bill_start_date = date("Y-m-d") . "T" . date("H") . ":" . $bill_start_date_mins . ":" . date("s");
                 $payment_per_cycle = $amount;
                 $paymentAmount = urlencode($payment_per_cycle);
                 $currencyID = urlencode($currency_name);
                 // or other currency code ('GBP', 'EUR', 'JPY', 'CAD', 'AUD')
                 $startDate = str_replace("%3A", ":", urlencode($bill_start_date));
                 $billingPeriod = urlencode("Month");
                 // or "Day", "Week", "SemiMonth", "Year"
                 $billingFreq = urlencode("1");
                 // combination of this and billingPeriod must be at most a year
                 //$TOTALBILLINGCYCLES = urlencode($duration);						// combination of this and billingPeriod must be at most a year
                 //$TOTALBILLINGCYCLES = urlencode("12");						// combination of this and billingPeriod must be at most a year
                 $DESC = urlencode($package_details);
                 $creditCardType = urlencode($card_info['credit_card_type']);
                 $creditCardAccount = urlencode(str_replace(' ', '', $card_info['credit_card_no']));
                 //$creditCardAccount = urlencode("4779297617944965");
                 $cardExpireDate = urlencode($card_info['card_expire_date_month'] . $card_info['card_expire_date_year']);
                 $cardCvv2 = urlencode($card_info['credit_card_verification_code']);
                 $PAYERSTATUS = urlencode("verified");
                 $STREET = urlencode($form_data_step4['bill_primary_address']);
                 $CITY = urlencode($form_data_step4['bill_city']);
                 $STATE = urlencode($form_data_step4['bill_state']);
                 $COUNTRYCODE = urlencode($form_data_step4['bill_country']);
                 $ZIP = urlencode($form_data_step4['bill_zip']);
                 $FIRSTNAME = urlencode($form_data_step4['bill_first_name']);
                 $LASTNAME = urlencode($form_data_step4['bill_last_name']);
                 $EMAIL = urlencode($form_data_step4['bill_email']);
                 $INITAMT = urlencode("0.00");
                 $FAILEDINITAMTACTION = urlencode("ContinueOnFailure");
                 $MAXFAILEDPAYMENTS = urlencode("10");
                 $ITEMCATEGORY0 = urlencode("Digital");
                 $ITEMNAME0 = urlencode($package_details);
                 $ITEMAMT0 = urlencode($amount);
                 $ITEMQTY0 = urlencode("1");
                 $AUTOBILLOUTAMT = urlencode("AddToNextBilling");
                 $TAXAMT = $amount * (25 / 100);
                 /// Tax_rate = 25%
                 $EMAIL = $form_data_step4['bill_email'];
                 $nvpStr = "&AMT={$paymentAmount}&CURRENCYCODE={$currencyID}&PROFILESTARTDATE={$startDate}";
                 $nvpStr .= "&BILLINGPERIOD={$billingPeriod}&BILLINGFREQUENCY={$billingFreq}&TOTALBILLINGCYCLES={$TOTALBILLINGCYCLES}&DESC={$DESC}&CREDITCARDTYPE={$creditCardType}&ACCT={$creditCardAccount}&EXPDATE={$cardExpireDate}&CVV2={$cardCvv2}&PAYERSTATUS={$PAYERSTATUS}&STREET={$STREET}\n                        &CITY={$CITY}&COUNTRYCODE={$COUNTRYCODE}&ZIP={$ZIP}&FIRSTNAME={$FIRSTNAME}&LASTNAME={$LASTNAME}&EMAIL={$EMAIL}\n                        &INITAMT={$INITAMT}&TAXAMT={$TAXAMT}&FAILEDINITAMTACTION={$FAILEDINITAMTACTION}&MAXFAILEDPAYMENTS={$MAXFAILEDPAYMENTS}\n                        &L_PAYMENTREQUEST_0_ITEMCATEGORY0={$ITEMCATEGORY0}&L_PAYMENTREQUEST_0_NAME0={$ITEMNAME0}\n                        &L_PAYMENTREQUEST_0_AMT0={$ITEMAMT0}&L_PAYMENTREQUEST_0_QTY0={$ITEMQTY0}&AUTOBILLOUTAMT={$AUTOBILLOUTAMT}";
                 $httpParsedResponseAr = PPHttpPost('CreateRecurringPaymentsProfile', $nvpStr);
                 if ("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) {
                     //$data_payment_success['org_id'] = $last_insert_ids['org_id'];
                     //$data_payment_success['org_billing_info_id'] = $last_insert_ids['org_billing_info_id'];
                     $data_payment_success['profileid'] = str_replace('%2d', '-', $httpParsedResponseAr['PROFILEID']);
                     $data_payment_success['profilestatus'] = $httpParsedResponseAr['PROFILESTATUS'];
                     //$data_payment_success['transactionid'] = $httpParsedResponseAr['TRANSACTIONID'];
                     $data_payment_success['timestamp'] = str_replace('%2d', '-', $httpParsedResponseAr['TIMESTAMP']);
                     $data_payment_success['timestamp'] = str_replace('%3a', ':', $data_payment_success['timestamp']);
                     $data_payment_success['correlationid'] = $httpParsedResponseAr['CORRELATIONID'];
                     $data_payment_success['ack'] = $httpParsedResponseAr['ACK'];
                     $data_payment_success['total_billing_cycle'] = $TOTALBILLINGCYCLES;
                     $data_payment_success['add_date'] = $to_date;
                     //Start : Update Organization Info Based on Successful Payment
                     $nvpStr = "&PROFILEID=" . $data_payment_success['profileid'];
                     $recurringPaymentProfileDetails = getRecurringPaymentProfileDetails('GetRecurringPaymentsProfileDetails', $nvpStr);
                     if ("SUCCESS" == strtoupper($recurringPaymentProfileDetails["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($recurringPaymentProfileDetails["ACK"])) {
                         $org_billing_success_insert_id = $this->info_model->org_billing_success_insert($data_payment_success);
                         if ($org_billing_success_insert_id) {
                             $data_org_billing_info['bill_profileid'] = $data_payment_success['profileid'];
                             $payment_method = "creditcard";
                             $org_id = $last_insert_ids['org_id'];
                             $success = $this->info_model->update_org_billing_info($data_org_billing_info, $payment_method, $org_id);
                         }
                         if ($recurringPaymentProfileDetails['NUMCYCLESCOMPLETED'] > 0) {
                             $data_org_billing_success['next_scheduled_billing_date'] = str_replace('%2d', '-', $recurringPaymentProfileDetails['NEXTBILLINGDATE']);
                             $data_org_billing_success['next_scheduled_billing_date'] = str_replace('%3a', ':', $data_org_billing_success['next_scheduled_billing_date']);
                             $data_org_billing_success['no_of_billing_cycle_completed'] = 1;
                             $data_org_billing_success['no_of_billing_cycle_remaining'] = $TOTALBILLINGCYCLES - 1;
                             $data_org_billing_success['current_outstanding_balance'] = str_replace('%2e', '.', $recurringPaymentProfileDetails['OUTSTANDINGBALANCE']);
                             $data_org_billing_success['amount_of_last_successful_payment'] = str_replace('%2e', '.', $recurringPaymentProfileDetails['LASTPAYMENTAMT']);
                             $data_org_billing_success['total_paid_amount'] = "total_paid_amount+" . $data_org_billing_success['amount_of_last_successful_payment'];
                             $data_org_billing_success['date_of_last_successful_payment'] = str_replace('%2d', '-', $recurringPaymentProfileDetails['LASTPAYMENTDATE']);
                             $data_org_billing_success['date_of_last_successful_payment'] = str_replace('%3a', ':', $data_org_billing_success['date_of_last_successful_payment']);
                             $success = $this->info_model->update_org_billing_success($data_org_billing_success, $org_billing_success_insert_id);
                             $total_days = $duration * 30;
                             $expire_date = time() + $total_days * 24 * 60 * 60;
                             $data_update = array('approval_status' => 1, 'payment_status' => 1, 'activation_date' => time(), 'expire_date' => $expire_date);
                             $success = $this->info_model->update_org_approve($data_update, $last_insert_ids['org_id']);
                             if ($success) {
                                 $data['first_name'] = $data_admin_user['admin_user_data']['first_name'];
                                 $data['username'] = $data_admin_user['admin_user_data']['username'];
                                 $data['email'] = $data_admin_user['admin_user_data']['email'];
                                 $data['org_number'] = $data_organization['organization_data']['org_number'];
                                 $data['org_name'] = $data_organization['organization_data']['org_name'];
                                 $data['org_phone'] = $data_organization['organization_data']['org_phone'];
                                 $data['password'] = $password;
                                 if ($data_admin_user['admin_user_data']['password_receive_by_email']) {
                                     $this->send_password_by_email($data);
                                 }
                                 if ($data_admin_user['admin_user_data']['password_receive_by_sms']) {
                                     $this->send_password_by_sms($data);
                                 }
                             }
                             ///////
                         } else {
                             $data_org_billing_success['no_of_billing_cycle_remaining'] = $TOTALBILLINGCYCLES;
                             $success = $this->info_model->update_org_billing_success($data_org_billing_success, $org_billing_success_insert_id);
                         }
                         //exit('GetTransactionDetails Completed Successfully: '.print_r($recurringPaymentProfileDetails, true));
                     } else {
                         //exit('GetTransactionDetails failed: ' . print_r($recurringPaymentProfileDetails, true));
                     }
                     //End : Update Organization Info Based on Successful Payment
                     //exit('CreateRecurringPaymentsProfile Completed Successfully: '.print_r($httpParsedResponseAr, true));
                 } else {
                     $data_payment_failure['org_id'] = $last_insert_ids['org_id'];
                     $data_payment_failure['org_billing_info_id'] = $last_insert_ids['org_billing_info_id'];
                     $data_payment_failure['l_errodcode0'] = $httpParsedResponseAr['L_ERRORCODE0'];
                     $data_payment_failure['l_shortmessage0'] = str_replace('%20', ' ', $httpParsedResponseAr['L_SHORTMESSAGE0']);
                     $data_payment_failure['l_longmessage0'] = str_replace('%20', ' ', $httpParsedResponseAr['L_LONGMESSAGE0']);
                     $data_payment_failure['l_severitycode0'] = $httpParsedResponseAr['L_SEVERITYCODE0'];
                     $data_payment_failure['timestamp'] = str_replace('%2d', '-', $httpParsedResponseAr['TIMESTAMP']);
                     $data_payment_failure['timestamp'] = str_replace('%3a', ':', $data_payment_failure['timestamp']);
                     $data_payment_failure['correlationid'] = $httpParsedResponseAr['CORRELATIONID'];
                     $data_payment_failure['ack'] = $httpParsedResponseAr['ACK'];
                     $data_payment_failure['add_date'] = $to_date;
                     $success = $this->info_model->org_billing_failure_insert($data_payment_failure);
                     //exit('CreateRecurringPaymentsProfile failed: ' . print_r($httpParsedResponseAr, true));
                 }
             } elseif ($payment_method == "invoice") {
                 //$fak_expire_date = time() + ($total_days * 24 * 60 * 60);
                 $data_faktura['bill_country'] = $form_data_step4['bill_country'];
                 if ($data_faktura['bill_country'] == "DEU") {
                     $data_faktura['bill_country'] = "GERMAN";
                 }
                 if ($data_faktura['bill_country'] == "NOR") {
                     $data_faktura['bill_country'] = "NORWAY";
                 }
                 if ($data_faktura['bill_country'] == "DNK") {
                     $data_faktura['bill_country'] = "DENMARK";
                 }
                 if ($data_faktura['bill_country'] == "FIN") {
                     $data_faktura['bill_country'] = "FINLAND";
                 }
                 if ($data_faktura['bill_country'] == "GBR") {
                     $data_faktura['bill_country'] = "UK";
                 }
                 if ($data_faktura['bill_country'] == "SWE") {
                     $data_faktura['bill_country'] = "SWEDEN";
                 }
                 $data_faktura['org_id'] = $last_insert_ids['org_id'];
                 $data_faktura['package_id'] = $package_id;
                 $data_faktura['fak_active_date'] = time();
                 $data_faktura['fak_expire_date'] = time() + 10 * 24 * 60 * 60;
                 $data_faktura['org_name'] = $data_organization['organization_data']['org_name'];
                 $data_faktura['org_number'] = $data_organization['organization_data']['org_number'];
                 $data_faktura['bill_primary_address'] = $form_data_step4['bill_primary_address'];
                 $data_faktura['bill_zip'] = $form_data_step4['bill_zip'];
                 $data_faktura['bill_city'] = $form_data_step4['bill_city'];
                 $data_faktura['bill_state'] = $form_data_step4['bill_state'];
                 $data_faktura['bill_phone'] = $form_data_step4['bill_phone_no'];
                 $data_faktura['fak_reference_name'] = $data_admin_user['admin_user_data']['first_name'] . " " . $data_admin_user['admin_user_data']['last_name'];
                 $data_faktura['fak_description'] = $package_details;
                 $data_faktura['fak_quantity'] = 1;
                 $data_faktura['fak_unit_price'] = $amount;
                 $data_faktura['fak_invoice_cost'] = $per_invoice_cost;
                 $data_faktura['fak_invoice_cost_applied'] = 0.0;
                 $data_faktura['sms_unit_price'] = $sms_cost;
                 $data_faktura['letter_unit_price'] = $letter_cost;
                 $data_faktura['fak_price_exclusive_vat'] = $data_faktura['fak_quantity'] * $data_faktura['fak_unit_price'];
                 $data_faktura['fak_vat_rate'] = 25;
                 //////// Calculating Total Cost of this faktura //////
                 $pris_exclusive_vat_one = $data_faktura['fak_price_exclusive_vat'];
                 $pris_exclusive_vat_two = $data_faktura['fak_invoice_cost_applied'];
                 $price_total_exclusive_vat = $pris_exclusive_vat_one + $pris_exclusive_vat_two;
                 $data_faktura['fak_vat_price'] = $data_faktura['fak_vat_rate'] / 100 * $price_total_exclusive_vat;
                 $fak_total_price = $price_total_exclusive_vat + $data_faktura['fak_vat_price'];
                 //////// Calculating Total Cost of this faktura //////
                 //$fak_total_price =$data_faktura['fak_price_exclusive_vat']+$data_faktura['fak_vat_price'];
                 $data_faktura['fak_total_price'] = round($fak_total_price);
                 $data_faktura['fak_rounding_price'] = $data_faktura['fak_total_price'] - $fak_total_price;
                 $data_faktura['fak_currency'] = $currency_name;
                 $data_faktura['add_date'] = $to_date;
                 $fak_insert_id = $this->info_model->bill_faktura_insert($data_faktura);
                 $data_faktura['price_total_exclusive_vat'] = $price_total_exclusive_vat;
                 if ($fak_insert_id) {
                     $data['first_name'] = $data_admin_user['admin_user_data']['first_name'];
                     $data['username'] = $data_admin_user['admin_user_data']['username'];
                     $data['email'] = $data_admin_user['admin_user_data']['email'];
                     $data['org_number'] = $data_organization['organization_data']['org_number'];
                     $data['org_name'] = $data_organization['organization_data']['org_name'];
                     $data['org_phone'] = $data_organization['organization_data']['org_phone'];
                     $data['password'] = $password;
                     $this->make_invoice_pdf($data_faktura, $fak_insert_id, $data);
                 }
             }
             //////////////// Payment Method: End /////
             $this->session->set_flashdata('message', '<div id="message1">' . $this->lang->line('org_registration_member_success') . '</div>');
             redirect('main/org_registration_success');
             //$this->data['dynamicView'] = 'pages/admin/new_customer/org_registration_success';
         } else {
             $this->data['dynamicView'] = 'pages/member/new_customer/entry_step3';
         }
         $this->_commonPageLayout('frontend_viewer');
     }
 }