I want to add a payment to an unpaid order, but unfortunately the documentation does not match the behavior of the API. When I want to create a payment for the order, it asks me for a parent_id, which is not mandatory according to the documentation, and I don’t know where to get it from. I basically just want to create a payment for the order and mark the order as paid, but it doesn’t work.
Can someone please help me or explain my error?
Here is the code (PHP Curl)
$transactionData = [
‘transaction’ => [
“currency”=>“USD”,
“amount”=>“10.00”,
“kind”=>“capture”,
“test”=>true
]
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url . "/orders/$payItem[OrderId]/transactions.json");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($transactionData));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"X-Shopify-Access-Token: $access_token",
"Content-Type: application/json"
]);
$response = curl_exec($ch);
$httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);