我的脚本与 ipn 模拟器完美配合,但它不适用于沙盒事务。如果我将网址更改为实时网站,它将无法正常工作。模拟器将传入的帖子打印到文件中。使用事务时,没有任何反应。我怎样才能使这项工作?
编辑:我的 wordpress 插件通过设置自定义 notify_url 值来覆盖贝宝的 ipn。我尝试将需要触发的函数放入 Payment Complete Jigoshop 操作中,但 $_POST 变量要么已更改,要么不存在。如果我用字符串填写这些字段,它工作正常。这是我需要开火的。
$data = array();
$data['Name'] = $_POST['address_name'];
$data['Company'] = '';
$data['Address1'] = $_POST['address_street'];
$data['Address2'] = '';
$data['City'] = $_POST['address_city'];
$data['State'] = $_POST['address_state'];
$data['Zip'] = $_POST['address_zip'];
$data['Country'] = $_POST['address_country'];
$data['Ship_Method_MSID'] = '1STCLASS';
$data['SpecialInstr'] = $_POST['memo'];
$data['Items'] = array(array('Item_ESID' => 'EVENTBAG', 'Quantity' => intval($_POST['quantity'])));
$json_data = json_encode($data);
$post_data = array('AccountID' => 10019, 'SecretKey' ='jsjxb', 'Method' => 'AddShipment', 'JSON' => $json_data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'example.com');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$returndata = curl_exec ($ch);
file_put_contents('test.txt', $returndata);
这就是我想出的:
$data = array();
$data['Name'] = $paypal_args['first_name'] . " " . $paypal_args['last_name'];
$data['Company'] = '';
$data['Address1'] = $paypal_args['address1'];
$data['Address2'] = $paypal_args['address2'];
$data['City'] = $paypal_args['city'];
$data['State'] = $paypal_args['state'];
$data['Zip'] = $paypal_args['zip'];
$data['Country'] = $paypal_args['country'];
$data['Ship_Method_MSID'] = '1STCLASS';
$data['SpecialInstr'] = '';
$data['Items'] = array(array('Item_ESID' => 'EVENTBAG', 'Quantity' => intval($paypal_args['quantity_1'])));
$json_data = json_encode($data);
$post_data = array('AccountID' => 10019, 'SecretKey' => 'z1', 'Method' => 'AddShipment', 'JSON' => $json_data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'example.com');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$returndata = curl_exec ($ch);
file_put_contents('test.txt', $returndata);
来自:
if ($this->send_shipping=='yes') :
$paypal_args['no_shipping'] = 1;
$paypal_args['address_override'] = 1;
$paypal_args['first_name'] = $order->shipping_first_name;
$paypal_args['last_name'] = $order->shipping_last_name;
$paypal_args['address1'] = $order->shipping_address_1;
$paypal_args['address2'] = $order->shipping_address_2;
$paypal_args['city'] = $order->shipping_city;
$paypal_args['state'] = $order->shipping_state;
$paypal_args['zip'] = $order->shipping_postcode;
$paypal_args['country'] = $order->shipping_country;