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

2023-06-23php开发问题
4

本文介绍了PayPal - 使用 php 加密多项目自定义购物车动态结账按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

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

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.

上周我一直在尝试制作一个加密的使用 PayPal 结账"按钮.

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

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

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.

所以我又花了一天的时间研究并发现 使用 php 加密的网络支付

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

将代码自定义到我的购物篮后,它会生成加密数据.但是当点击按钮时,PayPal 只显示一个项目输入框 - 即没有任何数据被传递.

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.

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

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.

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

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.

所以这不起作用

$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);

有人知道如何让它处理多个项目吗?

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

推荐答案

好的,我已经解决了.在 EncryptedButtons 类中更改

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

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

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

并添加

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

记住.在最后一行的 = 之前,否则会导致错误.希望这可以帮助某人.这个项目完成后,我将写一篇博文,并在完成后添加一个链接.

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.

这篇关于PayPal - 使用 php 加密多项目自定义购物车动态结账按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

PHP实现DeepL翻译API调用
DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以...
2025-08-20 php开发问题
168

PHP通过phpspreadsheet导入Excel日期数据处理方法
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的...
2024-10-23 php开发问题
287

mediatemple - 无法使用 codeigniter 发送电子邮件
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)...
2024-08-23 php开发问题
11

Laravel Gmail 配置错误
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)...
2024-08-23 php开发问题
16

将 PHPMailer 用于 SMTP 的问题
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)...
2024-08-23 php开发问题
4

关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)...
2024-08-23 php开发问题
17