Пример #1
0
 public static function isPaymentValid($oplataSettings, $response)
 {
     if ($oplataSettings['merchant'] != $response['merchant_id']) {
         return 'An error has occurred during payment. Merchant data is incorrect.';
     }
     $responseSignature = $response['signature'];
     if (isset($response['response_signature_string'])) {
         unset($response['response_signature_string']);
     }
     if (isset($response['signature'])) {
         unset($response['signature']);
     }
     if (fondycsl::getSignature($response, $oplataSettings['secretkey']) != $responseSignature) {
         return 'An error has occurred during payment. Signature is not valid.';
     }
     return true;
 }
Пример #2
0
 public function after_process()
 {
     global $config;
     if (empty($_POST)) {
         $fap = json_decode(file_get_contents("php://input"));
         $_POST = array();
         foreach ($fap as $key => $val) {
             $_POST[$key] = $val;
         }
     }
     list($order_id, ) = explode(fondycsl::ORDER_SEPARATOR, $_POST['order_id']);
     $payment_method = $this->PaymentMethod->find('first', array('conditions' => array('alias' => $this->module_name)));
     $order_data = $this->Order->find('first', array('conditions' => array('Order.id' => $order_id)));
     //print_r ($order_data);die;
     $fondy_merchant_id = $this->PaymentMethod->PaymentMethodValue->find('first', array('conditions' => array('key' => 'fondy_merchant_id')));
     $merchant_id = $fondy_merchant_id['PaymentMethodValue']['value'];
     $fondy_secret_key = $this->PaymentMethod->PaymentMethodValue->find('first', array('conditions' => array('key' => 'fondy_secret_key')));
     $secret_key = $fondy_secret_key['PaymentMethodValue']['value'];
     $options = array('merchant' => $merchant_id, 'secretkey' => $secret_key);
     $paymentInfo = fondycsl::isPaymentValid($options, $_POST);
     if ($order_data) {
         if ($paymentInfo === true && $_POST['order_status'] == fondycsl::ORDER_APPROVED) {
             // print_r ($paymentInfo); die;
             $order_data['Order']['order_status_id'] = $payment_method['PaymentMethod']['order_status_id'];
             $this->Order->save($order_data);
             //$this->Session->setFlash($_POST[order_status]);
         } else {
             //print_r($_POST);die;
             $_SESSION['fondy_id'] = $_POST[order_id];
             $_SESSION['fondy_desc'] = $_POST[response_description];
             $_SESSION['fondy_error'] = $_POST[response_code];
             $this->redirect('/page/Fondy' . $config['URL_EXTENSION']);
             die;
         }
     }
 }
Пример #3
0
                    echo 'error';
                }
            }
        }
    } else {
        echo 'Order status already updated';
    }
} else {
    // echo 2;
    list($order_id, ) = explode(fondycsl::ORDER_SEPARATOR, $_POST['order_id']);
    $order = $simpla->orders->get_order(intval($order_id));
    $payment_method = $simpla->payment->get_payment_method($order->payment_method_id);
    $payment_currency = $simpla->money->get_currency(intval($payment_method->currency_id));
    $settings = $simpla->payment->get_payment_settings($payment_method->id);
    $options = array('merchant' => $settings['fondy_merchantid'], 'secretkey' => $settings['fondy_secret']);
    $paymentInfo = fondycsl::isPaymentValid($options, $_POST);
    if (!$order->paid) {
        if ($_POST['amount'] / 100 >= round($simpla->money->convert($order->total_price, $payment_method->currency_id, false), 2)) {
            if ($paymentInfo === true) {
                if ($_POST['order_status'] == fondycsl::ORDER_APPROVED) {
                    // Установим статус оплачен
                    $simpla->orders->update_order(intval($order->id), array('paid' => 1));
                    // Отправим уведомление на email
                    $simpla->notify->email_order_user(intval($order->id));
                    $simpla->notify->email_order_admin(intval($order->id));
                    // Спишем товары
                    $simpla->orders->close(intval($order->id));
                    $invoice['status'] = $_POST[order_status];
                    $invoice['transaction'] = $_POST['order_id'];
                    $invoice['system'] = 'fondy';
                    $invoice['amount'] = $_POST['amount'] / 100 . " " . $_POST['actual_currency'];
Пример #4
0
    public function checkout_form($order_id, $button_text = null)
    {
        if (empty($button_text)) {
            $button_text = 'Перейти к оплате';
        }
        $order = $this->orders->get_order((int) $order_id);
        $payment_method = $this->payment->get_payment_method($order->payment_method_id);
        $payment_currency = $this->money->get_currency(intval($payment_method->currency_id));
        $settings = $this->payment->get_payment_settings($payment_method->id);
        $price = round($this->money->convert($order->total_price, $payment_method->currency_id, false), 2);
        // описание заказа
        // order description
        $desc = 'Order:' . $order->id;
        // Способ оплаты
        $paymode = $settings['fondy_paymode'];
        $success_url = $this->config->root_url . '/order/';
        $result_url = $this->config->root_url . '/payment/fondy/callback.php';
        // print_r($settings);
        $currency = $payment_currency->code;
        if ($currency == 'RUR') {
            $currency = 'RUB';
        }
        if ($settings[lang] == '') {
            $settings[lang] = 'ru';
        }
        $oplata_args = array('order_id' => $order_id . fondycsl::ORDER_SEPARATOR . time(), 'merchant_id' => $settings['fondy_merchantid'], 'order_desc' => $desc, 'amount' => $price, 'currency' => $currency, 'server_callback_url' => $result_url, 'response_url' => $result_url, 'lang' => $settings['lang'], 'sender_email' => $order->email);
        $oplata_args['signature'] = fondycsl::getSignature($oplata_args, $settings[fondy_secret]);
        return '    <script src="https://api.fondy.eu/static_common/v1/checkout/ipsp.js"></script>
                    <script src="https://rawgit.com/dimsemenov/Magnific-Popup/master/dist/jquery.magnific-popup.js"></script>
                    <link href="https://rawgit.com/dimsemenov/Magnific-Popup/master/dist/magnific-popup.css" type="text/css" rel="stylesheet" media="screen">
                    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">

<style>
#checkout_wrapper a{
    font-size: 20px;
    top: 30px;
    padding: 20px;
    position: relative;
}
#checkout_wrapper {
    text-align: left;
    position: relative;
    background: #FFF;
    /* padding: 30px; */
    padding-left: 15px;
    padding-right: 15px;
    padding-bottom: 30px;
    width: auto;
    max-width: 2000px;
    margin: 9px auto;
}
</style>
<div id="checkout">
<div id="checkout_wrapper">
</div>
</div>
<script>
function callmag(){
$.magnificPopup.open({
showCloseBtn:false,
        items: {
            src: $("#checkout_wrapper"),
            type: "inline"
        }
    });
}
$(document).ready(function() {
 $.magnificPopup.open({
 showCloseBtn:false,
        items: {
            src: $("#checkout_wrapper"),
            type: "inline"
        }
    });
    })
</script>
<script>
function checkoutInit(url, val) {
	$ipsp("checkout").scope(function() {
		this.setCheckoutWrapper("#checkout_wrapper");
		this.addCallback(__DEFAULTCALLBACK__);
		this.action("show", function(data) {
           $("#checkout_loader").remove();
            $("#checkout").show();
        });
		this.action("hide", function(data) {
            $("#checkout").hide();
        });
        if(val){
        this.width(val);
        this.action("resize", function(data) {
        $("#checkout_wrapper").width(val).height(data.height);
            });
        }else{
         this.action("resize", function(data) {
        $("#checkout_wrapper").width(480).height(data.height);
            });
        }
		this.loadUrl(url);
	});
    };
    var button = $ipsp.get("button");
    button.setMerchantId(' . $oplata_args[merchant_id] . ');
    button.setAmount(' . $oplata_args[amount] . ', "' . $oplata_args[currency] . '", true);
    button.setHost("api.fondy.eu");
    button.addParam("order_desc","' . $oplata_args[order_desc] . '");
    button.addParam("order_id","' . $oplata_args[order_id] . '");
	button.addParam("signature","' . $oplata_args[signature] . '");
    button.addParam("lang","' . $oplata_args[lang] . '");//button.addParam("delayed","N");
    button.addParam("server_callback_url","' . $oplata_args[server_callback_url] . '");
    button.addParam("sender_email","' . $oplata_args[sender_email] . '");
    button.setResponseUrl("' . $oplata_args[response_url] . '");
    checkoutInit(button.getUrl());
    </script>
    <input type="button" onclick="callmag();" class="checkout_button" value="' . $button_text . '">
    ';
    }