【问题标题】:Fortumo reciept verificatonFortumo 收据验证
【发布时间】:2016-07-31 21:03:12
【问题描述】:

任何人都可以帮助配置它,现在就开始吧。

这将很有用:https://developers.fortumo.com/cross-platform-mobile-payments/

我有密钥并设置了小部件,我只需要将内容添加到我的数据库中,例如查询中的硬币 + 1,但插入成功支付位的代码不会运行。所以是时候重新开始了。

任何帮助将不胜感激。

<?php

  // check that the request comes from Fortumo server
  if(!in_array($_SERVER['REMOTE_ADDR'],
array('1.2.3.4', '2.3.4.5'))) {
header("HTTP/1.0 403 Forbidden");
die("Error: Unknown IP");
  }

  // check the signature
  $secret = ''; // insert your secret between ''
  if(empty($secret) || !check_signature($_GET, $secret)) {
header("HTTP/1.0 404 Not Found");
die("Error: Invalid signature");
      }

  $sender = $_GET['sender'];//phone num.
  $amount = $_GET['amount'];//credit
  $cuid = $_GET['cuid'];//resource i.e. user
  $payment_id = $_GET['payment_id'];//unique id
  $test = $_GET['test']; // this parameter is present only when the payment is a test payment, it's value is either 'ok' or 'fail'

  //hint: find or create payment by payment_id
  //additional parameters: operator, price, user_share, country

  if(preg_match("/completed/i", $_GET['status'])) {
// mark payment as successful
  } 

  // print out the reply
  if($test){
echo('TEST OK');
  }
  else {
echo('OK');
  }

  function check_signature($params_array, $secret) {
ksort($params_array);

$str = '';
foreach ($params_array as $k=>$v) {
  if($k != 'sig') {
    $str .= "$k=$v";
  }
}
$str .= $secret;
$signature = md5($str);

return ($params_array['sig'] == $signature);
  }
?>

【问题讨论】:

    标签: fortumo


    【解决方案1】:

    代码示例的第一行验证请求来自 Fortumo IP 地址,如果不是,则脚本终止。

    // check that the request comes from Fortumo server
    if(!in_array($_SERVER['REMOTE_ADDR'],
        array('1.2.3.4', '2.3.4.5'))) {
        header("HTTP/1.0 403 Forbidden");
        die("Error: Unknown IP");
    }
    

    写信给 support@fortumo.com 以获取最新的 IP 地址进行验证(并用它们替换示例值 1.2.3.4)。

    同时您可以注释掉 ip 检查并继续构建您的脚本。

    【讨论】:

    • 谢谢我已经这样做了,我还必须注释掉签名检查,因为这也会产生错误,我认为这就是为什么当我有一个完整的脚本时它不起作用
    猜你喜欢
    • 2012-01-24
    • 1970-01-01
    • 1970-01-01
    • 2012-07-14
    • 1970-01-01
    • 2018-06-16
    • 2016-06-24
    • 2011-11-23
    • 1970-01-01
    相关资源
    最近更新 更多