我試圖使用此腳本獲取有關付款狀態(成功,失敗,已取消)的消息。Instamojo - 如何控制重定向頁面消息
$status = $_POST['status'];
if $status == "success" (
?> CONGRATS! <? AND SO ON
但我沒有成功。 這是我第一次與instamojo,所以我會請你們幫助我。
感謝&問候
Bhaamb
我試圖使用此腳本獲取有關付款狀態(成功,失敗,已取消)的消息。Instamojo - 如何控制重定向頁面消息
$status = $_POST['status'];
if $status == "success" (
?> CONGRATS! <? AND SO ON
但我沒有成功。 這是我第一次與instamojo,所以我會請你們幫助我。
感謝&問候
Bhaamb
考慮你使用PHP,那麼你應該使用$_GET
不$_POST
得到的查詢參數的值。
目前我們返回與重定向URL兩個查詢參數:payment_id
和status
。
這裏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": "[email protected]",
"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
,但不要混淆實際付款狀態。
檢查,如果在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並從那裏獲得狀態。 –