App reviews, troubleshooting, and recommendations
Hi team,
I'm creating the order refund request on rest API using curl in PHP. and getting an error
This is my order refund function
function orderRefund($shopify, $order_id, $reason) {
$refundcalarray = array(
"currency" => "INR",
"shipping" => array("full_refund")
);
$datarefundcal = array("refund"=>$refundcalarray);
$datarefundcal = $shopify->rest_api('/admin/api/2024-01/orders/'.$order_id .'/refunds/calculate.json', $datarefundcal, 'POST');
$apioutputrefundcal = json_decode($datarefundcal['body'],true);
$transactiondata = $apioutputrefundcal['refund']['transactions'];
$refundtransactionarray = array();
$refundtransactionarray['parent_id'] = $transactiondata[0]['parent_id'];
$refundtransactionarray['amount'] = (float)$transactiondata[0]['maximum_refundable'];
$refundtransactionarray['kind'] = 'refund';
$refundtransactionarray['gateway'] = $transactiondata[0]['gateway'];
$refundarray = array(
"currency" => "INR",
"notify" => true,
"note" => (string)$reason,
"shipping" => array("full_refund" => true),
"transactions" => array($refundtransactionarray)
);
$datarefund = array("refund"=>$refundarray);
echo json_encode($datarefund, JSON_PRETTY_PRINT); echo "\n";
$refund = $shopify->rest_api('/admin/api/2024-01/orders/'.$order_id .'/refunds.json', $datarefund, 'POST');
$refund = json_decode($refund['body'], true);
echo json_encode($refund, JSON_PRETTY_PRINT); echo "\n";
return $response = array( "message" => $refund['refund'] );
}
This is my $datarefund Responce in json
{
"refund": {
"currency": "INR",
"notify": true,
"note": "test",
"shipping": {
"full_refund": true
},
"transactions": [
{
"parent_id": 7050521444583,
"amount": 474.05,
"kind": "refund",
"gateway": "Gokwik UPI"
}
]
}
}
And this is the $response Error
{
"errors": {
"transactions": "expected Hash to be a Array"
}
}
Where i'm doing mistakes?
By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024