$data['data_phone'] = $phone;
    $data[$custom_field] = $order_id;
    $ver = explode('.', phpversion());
    $major = (int) $ver[0];
    $minor = (int) $ver[1];
    instamojo_error_logger("{$api_key} | {$auth_token} | {$private_salt} | {$payment_url}");
    instamojo_error_logger("Data before sorting: " . print_r($data, true));
    if ($major >= 5 and $minor >= 4) {
        ksort($data, SORT_STRING | SORT_FLAG_CASE);
    } else {
        uksort($data, 'strcasecmp');
    }
    instamojo_error_logger("Data after sorting: " . print_r($data, true));
    $str = hash_hmac("sha1", implode("|", $data), $private_salt);
    instamojo_error_logger("Signature is: {$str}");
    $link = url_handler($payment_url) . "intent=buy&emded=form&";
    $link .= "data_readonly=data_email&data_readonly=data_amount&data_readonly=data_phone&data_readonly=data_name&data_readonly={$custom_field}&data_hidden={$custom_field}";
    $link .= "&data_amount={$amount}&data_name={$name}&data_email={$email}&data_phone={$phone}&{$custom_field}={$order_id}&data_sign={$str}";
    instamojo_error_logger("Marking Order: {$order_id} as open before redirecting to Instamojo for payment.");
    fn_change_order_status($order_id, 'O');
    Redirect($link);
    exit;
}
function check_instamojo_payment_status($api_key, $auth_token, $payment_id)
{
    instamojo_error_logger("Calling Instamojo for Payment ID: {$payment_id} with API: {$api_key} and AUTH: {$auth_token}");
    $cUrl = 'https://www.instamojo.com/api/1.1/payments/' . $payment_id . '/';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $cUrl);
    curl_setopt($ch, CURLOPT_HEADER, FALSE);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
Esempio n. 2
0
<?php

define('API_RUN', true);
require 'engine.php';
if (!isset($_SERVER['HTTP_REFERER']) && !isset($_GET['apikey'])) {
    header('HTTP/1.1 403 Forbidden');
    exit('API cannot be direct accessed!');
}
if (isset($_GET['gettoken']) && $_GET['gettoken'] == 'file') {
    $result = get_token('file');
} else {
    if (isset($_GET['gettoken']) && $_GET['gettoken'] == 'url') {
        $result = get_token('url');
    } else {
        if (isset($_GET['type']) && $_GET['type'] == 'url') {
            $result = url_handler();
        } else {
            if (isset($_GET['type']) && $_GET['type'] == 'file') {
                $result = array_pop(file_handler());
            } else {
                header('HTTP/1.1 400 Bad Request');
                exit('You must set "type" in the query string.');
            }
        }
    }
}
header('Content-Type: application/json');
echo json_encode($result);
Esempio n. 3
0
 /**
  * Process the payment and return the result
  **/
 function process_payment($order_id)
 {
     global $woocommerce;
     $order = new WC_Order($order_id);
     $amount = $woocommerce->cart->total;
     $billing_email = substr($order->billing_email, 0, 75);
     $delivery_name = substr(trim($order->billing_first_name . " " . $order->billing_last_name), 0, 20);
     $billing_tel = substr($order->billing_phone, 0, 20);
     $data_arr = array();
     $data_arr["data_amount"] = $amount;
     $data_arr["data_name"] = $delivery_name;
     $data_arr["data_phone"] = $billing_tel;
     $data_arr["data_email"] = $billing_email;
     $custom_field = "data_" . $this->custom_field;
     $custom_field1 = strtolower($custom_field);
     $data_arr[$custom_field1] = $order_id;
     $ver = explode('.', phpversion());
     $major = (int) $ver[0];
     $minor = (int) $ver[1];
     if ($major >= 5 and $minor >= 4) {
         ksort($data_arr, SORT_STRING | SORT_FLAG_CASE);
     } else {
         uksort($data_arr, 'strcasecmp');
     }
     $str = hash_hmac("sha1", implode("|", $data_arr), $this->private_salt);
     $encoded_number = urlencode($billing_tel);
     $link = url_handler($this->payment_link) . "intent=buy&";
     $link .= "data_readonly=data_email&data_readonly=data_amount&data_readonly=data_phone&data_readonly=data_name&data_readonly={$custom_field}&data_hidden={$custom_field}";
     $link .= "&data_amount={$amount}&data_name={$delivery_name}&data_email={$billing_email}&data_phone={$encoded_number}&{$custom_field}={$order_id}&data_sign={$str}";
     $_SESSION["order_id"] = $order_id;
     return array('result' => 'success', 'redirect' => $link);
 }