Search code examples
phppayment-gatewayrazorpay

Razorpay not returning payment id using order id


I need razorpay_payment_id using razorpay_order_id. But,

When I use this the response is

$order = $api->order->fetch("order_xxxxxxxxxx")->payments;
var_dump($order);

enter image description here

Notice: Undefined index: payments in D:\wamp\www\xxxxxxxxxx\xxxxxxxx\razorpay-php\src\Resource.php on line 40
Call Stack
#   Time    Memory  Function    Location
1   0.0010  139848  {main}( )   ..\test.php:0
2   3.0040  772824  Razorpay\Api\Resource->__get( ) ..\test.php:981

null

$order = $api->order->fetch("order_xxxxxxxxxx")->payments();
var_dump($order);

object(Razorpay\Api\Collection)[8]
protected 'attributes' => 
array (size=3)
'entity' => string 'collection' (length=10)
'count' => int 1
'items' => 
array (size=1)
0 => 
object(Razorpay\Api\Payment)[10]
...

Not getting payment id and payment details.


Solution

  • I think you can easily get the payment details as a single dimensional array using -

    $api->payment->fetch($id) 
    

    where $id is the razorpayment_id instead you are using long solution .