2016-08-19 37 views
0

我正在php中創建一個網站。我需要與Intsamojo支付網關的簡單集成。 我正在使用的php庫是https://github.com/Instamojo/instamojo-php/ 我可以像這個例子一樣產生付款請求。Instamojo付款重定向

 try { 
    $response = $api->paymentRequestCreate(array(
     "purpose" => "FIFA 16", 
     "amount" => "3499", 
     "send_email" => true, 
     "email" => "[email protected]", 
     "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] => [email protected] 
    [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後調用它。 一個簡單的標題重定向是好的?哪個是安全的方法?

回答

0

在「redirect_url」中提供您想要在付款後重定向的鏈接。例如像這樣的「https://www.google.co.in/」。

-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']); 
+0

問題是什麼? – roni

+0

您能否提供更多細節爲什麼這是針對給定問題的解決方案? –

+0

因爲instamojo不給用戶直接訪問Instamojo的作品是發送電子郵件給用戶的鏈接。所以,我可以使用這個。我認爲這是更好的方法。 –

0

試試這個代碼,它應該是對您有所幫助

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