365 votes
0 answers
php - post transaction api in shopify
I am trying to update a transaction and mark it as complete by changing to paid status.
I am using shopify api POST/admin/orders/#{id}/transactions.json
. so i want to know that in this post is used to update or create new
This api is not working with passing values in post
$transaction =
array(
'kind' => 'capture'
);
//baseurl is defines properly
$ch = curl_init($baseUrl.'orders/#3055189382/transactions.json'); //set the url
$data_string = json_encode(array('transaction'=>$transaction)); //encode the product as json
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); //specify this as a POST
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); //set the POST string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //specify return value as string
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$server_output = curl_exec ($ch);
Undefined asked
Source
Didn't find the answer?
Our community is visited by hundreds of Shopify development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.