【问题标题】:Instamojo - How to control redirect page messageInstamojo - 如何控制重定向页面消息
【发布时间】:2016-01-08 13:03:43
【问题描述】:

我正在尝试使用此脚本获取有关付款状态(成功、失败、取消)的消息。

$status = $_POST['status'];

if $status == "success" (
?> CONGRATS! <? AND SO ON

但我没有成功。 这是我第一次使用 instamojo,所以我想请你们帮助我。

感谢和问候
班布

【问题讨论】:

    标签: instamojo


    【解决方案1】:

    考虑到您使用的是 PHP,那么您应该使用 $_GET 而不是 $_POST 来获取查询参数的值。


    目前我们返回两个带有重定向 URL 的查询参数:payment_idstatus

    这里的status 参数只是为了向后兼容,您不应该依赖它的值来标记支付成功,因为任何人都可以修改它的值。

    正确的方法是使用payment_id并查询我们的API得到payment details.

    示例响应可能如下所示:

    {
        "payment": {
            "payment_id": "MOJO3815000J72853518",
            "quantity": 1,
            "status": "Credit",                <---- Payment status
            "link_slug": "hello-api-inr-link",
            "link_title": "Hello API INR Link",
            "buyer_name": "A Gehani",
            "buyer_phone": "+9100000000",
            "buyer_email": "akash@instamojo.com",
            "currency": "INR",
            "unit_price": "9.00",
            "amount": "9.00",
            "fees": "0.45",
            "shipping_address": null,
            "shipping_city": null,
            "shipping_state": null,
            "shipping_zip": null,
            "shipping_country": null,
            "discount_code": null,
            "discount_amount_off": null,
            "variants": [],
            "custom_fields": null,
            "affiliate_id": "hiway",
            "affiliate_commission": "3.00",
            "created_at": "2014-12-16T13:17:27.943Z"
        },
        "success": true
    }
    

    这里如果payment->status的值为"Credit"则支付成功,否则不成功。

    同样,如果您使用的是 PHP,那么您可能想要使用我们的 API 包装器:Get Details of a Payment using Payment ID


    请注意,API 也返回"success": true,但不要将其与实际支付状态混淆。

    【讨论】:

      【解决方案2】:

      检查url中的状态是否存在

      if(isset($_GET['status']))
         $status =$_GET['status'];
      

      现在检查状态是失败还是成功

      if($status != 'failure')
      {
         "redirect to success url"
      }
      else{
         "redirect to failure url"
      }
      

      【讨论】:

      • 不建议依赖status查询参数:status参数只是为了向后兼容,你不应该依赖它的值来标记支付成功,因为任何人都可以修改它价值。如果您的某人最终使用此方法进行验证和付款,那么这不是正确的方法,请使用 payment_id 查询 API 并从那里获取状态。
      猜你喜欢
      • 2012-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-28
      • 2012-08-12
      • 1970-01-01
      • 2012-01-24
      相关资源
      最近更新 更多