snapscan& cs-cart集成

时间:2015-11-05 22:09:38

标签: php cs-cart

我被要求帮助将snapscan整合到cs-cart中,因为目前还没有针对cs-cart的api。我编写此代码是为了执行outside_CC类型样式

 <?php

if(!defined('BOOTSTRAP')) die('Direct Access Denied');

if(!defined('PAYMENT_NOTIFICATION')) {
    $mode = $processor_data['processor_params']['mode'];
    if($mode) {
        $form['id'] = $processor_data['processor_params']['id'];
        $form['key'] = $processor_data['processor_params']['key'];
    } else {
        $form['id'] = 'shopalot';
        $form['key'] = 'secret';
    }
    $form['reference'] = 'Order_'.$order_id;
    $form['amount'] = number_format($order_info['total']*1, 2,'','');
    $form['currency'] = 'ZAR';
    $form['url'] = fn_url('payment_notification.notify?payment=snapscan&order_id='.$order_id,AREA,'current');
    $form['date'] = date('d-m-Y H:i');
    $form['email'] = $order_info['email'];
    $checksum = $form['id'].'|'.$form['reference'].'|'.$form['amount'].'|'.$form['currency'].'|'.$form['url'].'|'.$form['date'].'|'.$form['email'].'|'.$form['key'];
    $form['checksum'] = md5($checksum);
echo <<<s
<html>

<body >

        <form action="https://pos.snapscan.io/qr/$form[id]?id=$order_id&amount=$form[amount]&strict=true" method="POST" >
        <input name="MERCHANT_ID" type="hidden" value="$form[id]">
        <input name="REFERENCE" type="hidden" value="$form[reference]">
        <input name="AMOUNT" type="hidden" value="$form[amount]">
        <input name="CURRENCY" type="hidden" value="ZAR">
        <input name="RETURN_URL" type="hidden" value="$form[url]">
        <input name="TRANSACTION_DATE" type="hidden" value="$form[date]">
        <input name="EMAIL" type="hidden" value="$form[email]">
        <input name="CHECKSUM" type="hidden" value="$form[checksum]">
    </form>
    <script>document.forms[0].submit();</script>


</body>
</html>
s;
    die;
}else{
    $order_id = $_REQUEST['order_id'];
    $order_info = fn_get_order_info($order_id);
    $payment_id = db_get_field("SELECT payment_id FROM ?:orders WHERE order_id = ?i",$order_id);
    $processor_data = fn_get_payment_method_data($payment_id);
    $status = $_POST['TRANSACTION_STATUS'];
    if($status == 1 && fn_check_payment_script('snapscan.php',$order_id)) {
        $pp_response['order_status'] = 'P';
        $pp_response['reason_text'] = 'The User Completed Payment with SnapScan';
        fn_update_order_payment_info($order_id,$pp_response);
        fn_change_order_status($order_id,$pp_response['order_status'],'',false);
    } else {
        $pp_response['order_status'] = 'F';
        $pp_response['reason_text'] = 'Your Payment was Unsuccessful';
        fn_finish_payment($order_id,$pp_response,false);
    }
    fn_order_placement_routines('route',$order_id);
}

?>

这种作品,它确实说未找到页面,但在刷新时它工作正常,拉动订单号和金额。 我要求的问题或帮助是如何在付款后让客户回到cs-cart下订单?它不像通过浏览器处理的信用卡,因为这需要移动手机。

这是来自snapscan的信息

http://developer.getsnapscan.com/#overview

我也尝试过各种选项,比如弹出窗口效果很好,但如果你用信用卡付款,也会弹出。

我想做的另一个选择是尝试识别这样的特定付款方式,

 {if '$SnapScan'}
<script language="javascript">
timer=setTimeout("window.open('https://pos.snapscan.io/qr/J0v26eBZ?id={$order_info.order_id}&amount={$order_info.total*100}&strict=true','','width=800,height=600')",5000)
</script>
{else}
DO NOTHING
{/if}

请有人能为我的困境提供可能的解决方案

2 个答案:

答案 0 :(得分:0)

根据文件,我只能确认这一点:Webhooks。

  

“我们建议您使用webhook通知付款   由于系统的实时性而完成。“

答案 1 :(得分:0)

尝试使用此代码自动发布表单:

<html>
<body onLoad="javascript:document.process.submit();">
<form action="https://pos.snapscan.io/qr/$form[id]?id=$order_id&amount=$form[amount]&strict=true" method="POST" name="process">
        <input name="MERCHANT_ID" type="hidden" value="$form[id]">
        <input name="REFERENCE" type="hidden" value="$form[reference]">
        <input name="AMOUNT" type="hidden" value="$form[amount]">
        <input name="CURRENCY" type="hidden" value="ZAR">
        <input name="RETURN_URL" type="hidden" value="$form[url]">
        <input name="TRANSACTION_DATE" type="hidden" value="$form[date]">
        <input name="EMAIL" type="hidden" value="$form[email]">
        <input name="CHECKSUM" type="hidden" value="$form[checksum]">
</form>
</body>
</html>

要接收来自SnapScan的回复,请使用Webhook:

http://developer.getsnapscan.com/#webhook

不幸的是,他们关于webhook的文档非常糟糕。请联系支持团队了解更多详情。例如,如果付款脚本位于app / payments目录中,则webhook URL应引用:

http://your_domain.com/app/payments/your_snapscan_script.php

处理响应的代码应该从:

开始
if (!defined('BOOTSTRAP')) {
    require './init_payment.php';
    .... YOUR CUSTOM CODE HERE ....
}

不要忘记从文件开头删除以下行:

if (!defined('BOOTSTRAP') ) { die('Access denied'); }