Reputation: 143
I am integrating shopify into one of the websites i manage, a shipping website. I am using the API to create an order with items from our database. \
When an order is issued, a transaction is made based on what gateway is selected from our website(Cash, cheque or credit). This order with the transaction is sent to our shop and can be seen on the POS app.
Problem is that i cannot access the refund or receipt buttons in the POS app. I can refund using the shopify back end but not on the POS. This is vexing and is the only thing left before i can implement this feature into our website.
Below is the order code being sent
$order = array( 'fulfillment_status' => 'fulfilled', 'send_receipt' => 'true', 'send_fulfillment_receipt' => 'true', ); // Second part of order with items and customer if($ShippingQuantity !== 0.00){ $order2 = array('line_items' => array( array('title' => 'Shipping', 'price' => '10', 'quantity' => $ShippingQuantity, ) ) ); } if($HandlingQuantity !== 0.00){ $order3 =array('title' => 'Handling', 'price' => '5', 'quantity' => $HandlingQuantity, ); $order2['line_items'][] = $order3; } if($DutyQuantity !== 0.00){ $order4 =array('title' => 'Duty', 'price' => '0.01', 'quantity' => $DutyQuantity, ); $order2['line_items'][] = $order4; } if($ConsolidationQuantity !== 0.00){ $order5 =array('title' => 'Consolidation', 'price' => '10', 'quantity' => $ConsolidationQuantity, ); $order2['line_items'][] = $order5; } if($DeliveryQuantity !== 0.00){ $order6 =array('title' => 'Delivery', 'price' => '20', 'quantity' => $DeliveryQuantity, ); $order2['line_items'][] = $order6; } $customerandtrans = array('customer' => array( 'id' => $currentcustID, ),'note' =>'purchase made at '.$pickup.'', 'transactions' => array( array('amount' => $Total, 'gateway' => $gateway, ) ) ); $final = array_merge($order,$order2,$customerandtrans); $finaljson = json_encode($final); } } $ch = curl_init($baseUrl.'orders.json'); //set the url $data_string = json_encode(array('order'=>$final)); //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_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($data_string)) ); //specify that this is a JSON call $server_output = curl_exec ($ch); //get server output if you wish to error handle / debug curl_close ($ch); //close the connection //var_dump($data_string); //var_dump($server_output); $decoded = json_decode($server_output,true); //var_dump($decoded); $reg_id = $decoded['order']['id']; $amount = $decoded['order']['total_price']; if($reg_id){ echo "An order has been created with ID $reg_id
";
This is the transaction code
$order_target2="orders/".$reg_id."/transactions.json"; $trans = array('kind' => 'sale', 'receipt' => array( 'testcase' => 'true', 'authorization' => '123456',),); $ch = curl_init($baseUrl.$order_target2); //set the url $data_string = json_encode(array('transaction'=>$trans)); //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_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($data_string)) ); //specify that this is a JSON call $server_output = curl_exec ($ch); //get server output if you wish to error handle / debug curl_close ($ch); //close the connection //var_dump($data_string); //var_dump($server_output); $decoded = json_decode($server_output,true); //var_dump($decoded); $order_id = $decoded['transaction']['order_id']; if($order_id){ echo "Transaction successfully made at order $order_id
"; }
Upvotes: 0
Views: 486
Reputation: 143
I will mark this as solved after i spoke to a shopify support tech about the situation. He stated that any transaction that is not coming from the POS will have the options for receipt and refund via the POS greyed out. You can still however access these features through the admin panel on your store's back end.
Upvotes: 1