2

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

billno:此值将从 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 变量。

4

1 回答 1

4

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 工作

于 2017-03-14T12:44:16.343 回答