生成包含金额和收件人的 PayPal 付款链接

发布于 2024-12-03 10:57:53 字数 207 浏览 0 评论 0原文

我需要动态生成带有自定义付款金额和收件人的 PayPal 链接。我不太了解PayPal处理此类事情的方式,我实际上想知道这是否可能。我有一个包含用户电子邮件地址和付款金额的表格,在最后一列中,我需要放置该链接,单击该链接后,将进入 PayPal 页面,在经过安全检查和所有操作后,我给出的金额可以是直接转移到用户的电子邮件地址。

可以做这样的事情吗?我正在使用 PHP 工作。 谢谢。

I need to dinamically generate PayPal links with customized payment amounts and recipients. I don't know much about PayPal's way of handling this kind of stuff, and I actually wonder whether it is possible. I have a table with user's email address and payment value and, on the last column, I need to put that link that, clicked, takes to the PayPal's page where, after security checks and everything, the amount of money by me given can be directly transferred to the email address of the user.

Is it possible to do something like this? I'm working in PHP.
Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

完美的未来在梦里 2024-12-10 10:57:53

请阅读文档 - 描述得非常清楚。您需要在 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计费插件

please, read documentation - it's all very well described. you will need to register at https://developer.paypal.com/; refer to https://www.paypal.com/documentation for more information.

I believe paypal standard payments would suffice your needs. read this https://cms.paypal.com/cms_content/US/en_US/files/developer/PP_WebsitePaymentsStandard_IntegrationGuide.pdf -- it has all sorts of samples.


when we integrate paypal, we usually do like this: user picks goods to purchase, then proceeds to checkout. at this point, form is created as per documentation, and that form includes merchant account to use for processing the payment. in the form you also specify: notify_url and cancel_url, so you would get notification from the paypal as to what happened and to which account. that should address your needs.

sample form:

<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>

sample callback handler:

....

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;
}

excerpt from agiletoolkit.org paypal billing addon

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文