PayPal - 使用 php 加密多项目自定义购物车动态结帐按钮

发布于 2024-10-06 05:37:44 字数 1054 浏览 6 评论 0原文

我创建了一个网站,要求我构建一个自定义购物篮以满足业务需求。这一切工作正常。

上周我一直在尝试制作一个加密的“使用 PayPal 结帐”按钮。

首先我尝试了这个:www.x.com/message/174366(没有超链接,因为我是新用户,抱歉),并且无法从该函数中获取任何加密数据。

于是我又花了一天时间研究,发现 Encrypted web payment with php

定制后将代码添加到我的购物篮中,它会生成加密数据。但是,当单击该按钮时,PayPal 仅显示一个项目输入框 - 即没有传递任何数据。

当我注释掉向按钮添加多个项目的代码并仅编写一个静态项目(即使用 item_name 而不是 item_name_1 等)时,它工作正常。

我尝试将 cmd 变量从 _s-xclick 更改为 _cart 和 _s-cart,正如我遇到的一些论坛中提到的那样,但无济于事。我确实设置了上传变量。

所以这不起作用

$itm=1;
for($j=0;$j<count($tempIArr);$j++)
{
    $names[] = 'item_name_'.$itm;
    $values[] = $tempIArr[$j]->getName();
    $names[] = 'amount_'.$itm;
    $values[] = $tempIArr[$j]->getTotal();
    $itm++;
}
$paypal->addButtonParam($names, $values);

但这确实起作用

$names[] = 'item_name';
$values[] = 'someProduct';
$names[] = 'amount';
$values[] = 99;
$paypal->addButtonParam($names, $values);

有人对如何使其与多个项目一起工作有任何想法吗?

I have created a site that required me to build a custom basket in order to meet the needs of the business. This is all working fine.

I have spent the last week trying to make an encrypted 'checkout with PayPal' button.

Firstly I tried this: www.x.com/message/174366 (not hyperlinked because I'm a new user, sorry), and couldn't get any encrypted data out of the function.

So I spent another day researching and found Encrypted web payments with php

After customizing the code to my basket, it generates encrypted data. But when the button is clicked PayPal just shows an item input box - i.e. none of the data is passed.

When I comment out the code for adding multiple items to the button and just code one static item (i.e. using item_name instead of item_name_1 etc) it works fine.

I have tried to change the cmd variable from _s-xclick to _cart and _s-cart as mentioned in some forum I came across to no avail. I do have the upload variable set.

So this doesn't work

$itm=1;
for($j=0;$j<count($tempIArr);$j++)
{
    $names[] = 'item_name_'.$itm;
    $values[] = $tempIArr[$j]->getName();
    $names[] = 'amount_'.$itm;
    $values[] = $tempIArr[$j]->getTotal();
    $itm++;
}
$paypal->addButtonParam($names, $values);

But this does work

$names[] = 'item_name';
$values[] = 'someProduct';
$names[] = 'amount';
$values[] = 99;
$paypal->addButtonParam($names, $values);

Anybody got any ideas on how to make it work with multiple items?

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

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

发布评论

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

评论(2

送君千里 2024-10-13 05:37:45

对了,我已经解决了。
在 EncryptedButtons 类中更改

$this->_data = "cmd=_xclick\n"; 

$this->_data = "cmd=_cart\n"; 

并添加

$this->_data .= "upload=1\n";

Remember the .最后一行=之前,否则会导致错误。希望这对某人有帮助。一旦这个项目完成,我将写一篇博客文章,并在完成后添加一个链接。

right, i've solved it.
In the EncryptedButtons class change

$this->_data = "cmd=_xclick\n"; 

to

$this->_data = "cmd=_cart\n"; 

and add

$this->_data .= "upload=1\n";

Remember the . before the = on the last line otherwise it will lead to errors. Hope this helps someone. Once this project is finished I will be writing up a blog post and will add a link when I get it done.

巡山小妖精 2024-10-13 05:37:45

并不是每个人都有能力在他们的托管计划中安装 OpenSSL,或者让它通过所有这些步骤和障碍来工作。另一种解决方案是使用未加密的按钮进行篡改检测。我在这里解释一下:

如何使用自定义字段制作 PayPal 加密的立即购买按钮?

Not everyone has the power to install OpenSSL on their hosting plan, or to get it working with all these steps and hoops to jump through. Another solution is tamper detection with an unencrypted button. I explain this here:

How do I make a PayPal encrypted buy now button with custom fields?

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