我需要使用自定义付款金额和收件人动态生成PayPal链接。我对PayPal处理这种东西的方式了解不多,我真的很想知道它是否可行。我有一张桌子,上面有用户的电子邮件地址和支付价值,在最后一栏,我需要把点击的链接放到PayPal的页面上,经过安检和一切后,我给出的金额可以是直接转移到用户的电子邮件地址。
有可能做这样的事吗?我在PHP工作。 感谢。
答案 0 :(得分:2)
请阅读文档 - 这一切都很好描述。您需要在https://developer.paypal.com/注册;有关详细信息,请参阅https://www.paypal.com/documentation。
我相信贝宝标准支付足以满足您的需求。阅读此https://cms.paypal.com/cms_content/US/en_US/files/developer/PP_WebsitePaymentsStandard_IntegrationGuide.pdf - 它有各种样本。
当我们整合paypal时,我们通常会这样做:用户选择要购买的商品,然后继续结帐。此时,表单是根据文档创建的,该表单包括用于处理付款的商家帐户。在表单中,您还指定了:notify_url和cancel_url,因此您将从paypal获得有关发生的事件和帐户的通知。这应该满足你的需求。
样本表格:
<form action="https://www.'.$this->isSandbox().'paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="business" value="'.$this->api->getConfig('billing/paypal/merchant').'">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="rm" value="2">
<input type="hidden" name="item_name" value="'.addslashes($_GET['descr']).'">
<input type="hidden" name="item_number" value="'.addslashes($_GET['id']).'">
<input type="hidden" name="amount" value="'.addslashes($_GET['amount']).'">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="notify_url" value="http://' . $_SERVER['HTTP_HOST'].$this->api->getDestinationURL('/ppproxy',array('ipn'=>$_GET['id'])).'">
<input type="hidden" name="cancel_return" value="http://' . $_SERVER['HTTP_HOST'].$this->api->getDestinationURL('/ppproxy',array('cancel'=>$_GET['id'])).'">
<input type="hidden" name="return" value="http://' . $_SERVER['HTTP_HOST'].$this->api->getDestinationURL('/ppproxy',array('success'=>$_GET['id'])).'">
<input type="hidden" name="currency_code" value="'.addslashes($_GET['currency']).'">
</form>
示例回调处理程序:
...
if($_POST){
// might be getting adta from paypal! better log!
foreach ($_POST as $key=>$value) $postdata.=$key."=".urlencode($value)."&";
$postdata.="cmd=_notify-validate";
$curl = curl_init("https://www.".$this->isSandbox()."paypal.com/cgi-bin/webscr");
curl_setopt ($curl, CURLOPT_HEADER, 0);
curl_setopt ($curl, CURLOPT_POST, 1);
curl_setopt ($curl, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($curl, CURLOPT_SSL_VERIFYHOST, 1);
$response = curl_exec ($curl);
curl_close ($curl);
$this->api->logger->logLine($response);
if ($response != "VERIFIED"){
$this->api->logger->logLine('FAILED: post='.print_r($_POST,true));
exit;
}else{
$this->api->logger->logLine('VERIFIED: post='.print_r($_POST,true));
}
if($_POST['payment_status']=='Completed' and $_POST['txn_type']!='reversal')return true; // or perform your desired actions
exit;
}
摘自agiletoolkit.org paypal billing addon