gpt4 book ai didi

php - 如何使用 Razorpay PHP API 获取付款详情?

转载 作者:行者123 更新时间:2023-12-02 17:20:58 27 4
gpt4 key购买 nike

我正在尝试集成用于获取付款详细信息的代码。

billno: This value will be taken from the URL.

我当前的代码:

include 'razorpay/Razorpay.php';
use Razorpay\Api\Api;

$api = new Api('Secret ID', 'Secret Key');

$payment = $api->payment->fetch($_REQUEST['billno']);
$text = json_encode($payment->toArray());
$obj = json_decode($text);
$shopping_id = $obj->{'notes'}->{'shopping_id'};

$rzp_amount = $obj->{'amount'};//xheck
$real_amount = $rzp_amount/100;
$rzp_key = $obj->{'id'};
$rzp_status = $obj->{'status'}; //Authorised cgecj
$rzp_descp = $obj->{'description'};
$rzp_mail = $obj->{'email'};
$rzp_phone = $obj->{'contact'};
$rzp_address = $obj->{'notes'}->{'address'};
$rzp_timestamp = $obj->{'created_at'};
$rzp_method = $obj->{'method'};

使用代码提取 billno 将为我们提供上述 $rzp 变量。

最佳答案

payment->fetch 调用返回一个支付实体,并具有可直接访问的所有数据成员。您不必自己解码 JSON,这由 SDK 负责:

include 'razorpay/Razorpay.php';
use Razorpay\Api\Api;

$api = new Api('Secret ID', 'Secret Key');

$payment = $api->payment->fetch($_REQUEST['billno']);

echo $payment->amount;
print_r($payment->notes);

免责声明:我为 Razorpay 工作

关于php - 如何使用 Razorpay PHP API 获取付款详情?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42751639/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com