网站内针对不同帐户的 PayPal 集成

发布于 2024-10-20 14:52:37 字数 315 浏览 3 评论 0原文

我正在构建简单的销售网站,任何用户(卖家)都可以上传照片并将其出售给其他用户(买家)

卖家需要在注册时写入他的 PayPal 帐户,因此当买家订购图像时,他会被转移到 PayPal 网站,即使他没有 PayPal 可以使用外部卡(当您使用 PayPal 付款时经常看到的页面),当买方付款时,将这些资金发送给卖方并将买方转移回网站并确认付款。 当 php 确认付款时,他允许买家下载图像。

这可能吗?如何实现?

有人可以给我写一个简单的脚本,或者告诉我在哪里可以找到这方面的示例...... 它在网络上传播,所以任何人都不应该这样做......

谢谢!

I'm building simple selling site where any user ( seller ) can upload photo and sell it to other users ( buyers )

Seller needs to write his PayPal account when he register, so when buyer order image he get transferred to paypal site, even if he doesn't have PayPal to use outside Card ( that page you often see when you paying something with paypal ), and when buyer pay send those funds to seller and transfer buyer back to site and confirm payment.
When php confirm payment he enable buyer to download image.

Is this possible, and how?

Can someone write me or simple script or tell me where to find examples for this...
It's spread around the web, so anyone should no this...

Thank you!

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

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

发布评论

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

评论(2

千柳 2024-10-27 14:52:37

当他注册时,您不需要存储他的 PayPal 帐户。

PayPal 在其支持部分编写了大量信息。

查找 PayPal IPN。

You wouldn't need to store his paypal account when he registers.

And PayPal has written tonnes of infomation in their support sections.

Look up PayPal IPN.

不知所踪 2024-10-27 14:52:37

这是第一步,创建表单,将其放在您想要购买按钮的位置,它可以在任何页面上,您可以通过 PayPal 网站上的按钮向导创建它,只需添加此 notification_url 隐藏输入即可。
您可以使用 php 输入金额、item_name、企业电子邮件、自定义...

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="[email protected]">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="item_name" value="Item Name">
<input type="hidden" name="item_number" value="150">
<input type="hidden" name="amount" value="100.00">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="tax_rate" value="0.000">
<input type="hidden" name="shipping" value="0.00">
<input type="hidden" name="custom" value="user_id_goes_here">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted">
<input type="hidden" name="notify_url" value="http://checking-url-goes-here/file.php">
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

第二步,检查是否有效付款、file.php(或您在上面表单中的 notification_url 隐藏输入中指定的任何文件 URL)来编辑这些字段:

<?php

$req = 'cmd=_notify-validate';

foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}

$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);

if (!$fp) {

//ERROR READING PAGE - CODE ERROR

} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {

//VALID CODE, DO WHATEVER YOU WANT WITH IT HERE, PAYMENT IS CONFIRMED...

}
else if (strcmp ($res, "INVALID") == 0) {

//INVALID CODE

}
}

?>

您可以测试里面的代码:
https://developer.paypal.com/
(贝宝沙箱)
只需将

www.paypal.com

替换为

www.sandbox.paypal.com

(您可以在两个地方找到它)。

就是这样...

我正在询问这个方向,但没有人愿意在这里指导我...

我什至对这个问题得到了-2评级,但是这些缺点都没有足够聪明来给我写这些例子,因为我要求...

而我就是那个该受减分的人?

(我希望有人会发现这些例子有用)

Here is first step, creating form, put it where you want your BUY button to be, it can be on any page, you can create it by buttons wizard on PayPal site, just add this notify_url hidden input.
You can edit those fields with php entering amount, item_name, business email, custom...

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="[email protected]">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="item_name" value="Item Name">
<input type="hidden" name="item_number" value="150">
<input type="hidden" name="amount" value="100.00">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="tax_rate" value="0.000">
<input type="hidden" name="shipping" value="0.00">
<input type="hidden" name="custom" value="user_id_goes_here">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted">
<input type="hidden" name="notify_url" value="http://checking-url-goes-here/file.php">
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

Second step, checking is it valid payment, file.php ( or any file URL you specify in notify_url hidden input in form above ) :

<?php

$req = 'cmd=_notify-validate';

foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}

$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);

if (!$fp) {

//ERROR READING PAGE - CODE ERROR

} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {

//VALID CODE, DO WHATEVER YOU WANT WITH IT HERE, PAYMENT IS CONFIRMED...

}
else if (strcmp ($res, "INVALID") == 0) {

//INVALID CODE

}
}

?>

You can test this code inside:
https://developer.paypal.com/
( PayPal Sandbox )
just replace

www.paypal.com

with

www.sandbox.paypal.com

( you can find it at two places ).

And that's it...

I was asking for this directions, and no one want to direct me here...

I even get -2 rating for this question, but none of those minuses was smart enough to write me those examples, as I ask for...

And I'm the one who deserve minuses?

( I hope someone will find those examples useful )

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