我怎么能卷曲到贝宝确认付款后,快递结帐在网上商店?PHP


How can i Curl into paypal to confirm payment after express checkout in a webshop? PHP

当您点击任何网店的Express Checkout PayPal按钮时,它会将您重定向到特定的PayPal登录链接,用于支付订单。

我一直在搜索高和低3天,现在一个简单的贝宝php curl脚本,从这一步登录你,并确认付款,但没能找到任何东西。我只发现脚本,登录你从贝宝的主页,这不会工作,因为你打破贝宝的流程。

我发现使用API是不可能的,所以它必须由CURL来完成。

我问这个,因为我运行一个dropshipping网站,并希望自动化某些步骤,如放置和支付订单。一个有效的代码不仅可以帮助我,还可以帮助所有希望以某种形式自动购买的人。

我会粘贴我所做的非工作脚本,这只会给我一个"对不起-你的最后一个动作无法完成"的消息贝宝,如果这可以帮助以任何方式在所有..


$agent = "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.8) Gecko/20061025 Firefox/1.5.0.8";
$header[] = "text/html; charset UTF-8";
$url = $_GET[link];
// $url = "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&&token=EC-EXAMPLE7839244";
$email = urlencode("email");
$password = urlencode("password");
$cookies = "cookies.txt";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_REFERER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookies);
curl_setopt($ch, CURLOPT_URL, $url);
// HIT LOGINPAGE
$login = curl_exec ($ch);
// PRINT LOGINPAGE
var_dump($login);
// GET LOGIN-LINK AND SET POSTFIELDS
preg_match("/merchantpaymentweb'?cmd'='_flow(.*?)'"/", $login, $output);
$link = "https://www.paypal.com/c2/cgi-bin/merchantpaymentweb?cmd=_flow$output[1]";
// PRINT LOGIN-LINK
echo "LINK: $link
"; preg_match("/CONTEXT'" value='"(.*?)'"/", $login, $output); $CONTEXT = $output[1]; $postfields = "CONTEXT=$CONTEXT&close_external_flow=false&cmd=_flow&external_close_account_payment_flow=payment_flow&flow_name=xpt/Merchant/hostedpayments/Login&flow_name=xpt/Merchant/hostedpayments/Login&form_charset=UTF-8&id=&login.x=Log+In&login_email=".$email."&login_password=".$password."&myAllTextSubmitID="; echo "
POSTFIELDS : '"$postfields'"
"; curl_setopt($ch, CURLOPT_URL, $link); curl_setopt ($ch, CURLOPT_POST, 1); curl_setopt ($ch, CURLOPT_POSTFIELDS, $postfields); // POST FORM, fails, gives "Sorry - Your last action could not be completed" message $should_be_logged_in_now = curl_exec($ch); var_dump($should_be_logged_in_now);

我不太熟悉使用PayPal。我像4年前一样停止使用它,因为我有充电。

你可能想检查PayPal Pro API这是一个付费服务。这可能是你正在寻找的,而不是处理CURL &贝宝,因为你提到使用API。