Instamojo付款重定向

时间:2016-08-19 15:11:12

标签: php instamojo

我正在用php创建一个网站。我需要与Intsamojo支付网关的简单集成。 我正在使用的php库是https://github.com/Instamojo/instamojo-php/ 我可以像这个例子一样生成付款请求。

     try {
     $response = $api->paymentRequestCreate(array(
        "purpose" => "FIFA 16",
        "amount" => "3499",
        "send_email" => true,
        "email" => "foo@example.com",
        "redirect_url" => "http://www.example.com/handle_redirect.php"
        ));
      print_r($response);
}
    catch (Exception $e) {
    print('Error: ' . $e->getMessage());
}

$response变量对请求的付款具有唯一的付款响应。

Array
(
    [id] => a78ab73df2bb4e78bc06a32a264ae59a
    [phone] => +919898989898
    [email] => ba@gmail.com
    [buyer_name] => mool
    [amount] => 105.75
    [purpose] => Jeans Mens #100
    [status] => Pending
    [send_sms] => 
    [send_email] => 1
    [sms_status] => 
    [email_status] => Pending
    [shorturl] => 
    [longurl] => https://test.instamojo.com/@instamojousername/a78ab73df2bb4e78bc06a32a264ae59a
    [redirect_url] => http://demo.test.com/instamojo/thankyou.php
    [webhook] => http://demo.test.com/instamojo/webhook.php
    [created_at] => 2016-08-19T14:44:10.679557Z
    [modified_at] => 2016-08-19T14:44:10.679582Z
    [allow_repeated_payments] => 
)

现在,在此步骤之后,我希望将用户重定向到为付款而生成的此链接。

https://test.instamojo.com/@instamojousername/a78ab73df2bb4e78bc06a32a264ae59a

第一次paymentRequestCreate电话后如何实现。{p> 一个简单的标题重定向是好的吗?哪种方法安全?

3 个答案:

答案 0 :(得分:0)

在" redirect_url"提供付款后要重定向的链接。例如" https://www.google.co.in/"像这样。

答案 1 :(得分:0)

试试这段代码应该对你有所帮助

 try {
 $response = $api->paymentRequestCreate(array(
    "purpose" => "FIFA 16",
    "amount" => "3499",
    "send_email" => true,
    "email" => "foo@example.com",
    "redirect_url" => "http://www.example.com/handle_redirect.php"
    ));
    header('location:'.response['longurl']);
}
catch (Exception $e) {
print('Error: ' . $e->getMessage());
}

答案 2 :(得分:-2)

            $response = $api->paymentRequestCreate(array(
                "purpose" => "Add Branch",
                "amount" => "2250",
                "send_email" => false,
                "email" => "",
                "redirect_url" => base_url()."coordinator/new_branch_response"
                ));

            header('Location: https://www.instamojo.com/your_unique_number/'.$response['id']);