getRow('SELECT * FROM userPayOrder WHERE orderNo = "' . $_POST['orderid'] . '"'); header('Content-Type: application/json'); if (!$order) { echo 'wrong orderid'; exit; } $paypalHelper = new PayPalHelper; $orderData = '{ "intent" : "CAPTURE", "application_context" : { "return_url" : "' . $_POST['return_url'] . '", "cancel_url" : "' . $_POST['cancel_url'] . '" }, "purchase_units" : [ { "reference_id" : "' . $_POST['orderid'] . '", "description" : "' . $_POST['desc'] . '", "custom_id" : "' . $order['productIdentifying'] . '", "amount" : { "currency_code" : "USD", "value" : "' . $order['commodityPrice'] . '" } } ] }'; if (array_key_exists('shipping_country_code', $_POST)) { $orderDataArr = json_decode($orderData, true); $orderDataArr['application_context']['shipping_preference'] = "SET_PROVIDED_ADDRESS"; $orderDataArr['application_context']['user_action'] = "PAY_NOW"; $orderDataArr['purchase_units'][0]['shipping']['address']['address_line_1'] = $_POST['shipping_line1']; $orderDataArr['purchase_units'][0]['shipping']['address']['address_line_2'] = $_POST['shipping_line2']; $orderDataArr['purchase_units'][0]['shipping']['address']['admin_area_2'] = $_POST['shipping_city']; $orderDataArr['purchase_units'][0]['shipping']['address']['admin_area_1'] = $_POST['shipping_state']; $orderDataArr['purchase_units'][0]['shipping']['address']['postal_code'] = $_POST['shipping_postal_code']; $orderDataArr['purchase_units'][0]['shipping']['address']['country_code'] = $_POST['shipping_country_code']; $orderData = json_encode($orderDataArr); } $_SESSION['language'] = $_POST['lan']; echo json_encode($paypalHelper->orderCreate($orderData));