PayPal - 加密多项目自定义购物车动态结帐按钮与php [英] PayPal - encrypt muti item custom cart dynamic checkout button with php

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

问题描述

我已经创建了一个网站,要求我建立一个自定义的篮子,以满足业务的需要。这个工作一切正常。



我上个星期试图通过PayPal进行加密结帐按钮。



首先我尝试这样:www.x.com/message/174366(由于我是一个新用户,没有超链接,对不起),并且无法从函数中获取任何加密数据。



所以我花了一天时间研究,发现加密使用php进行网络付款



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



当我注释掉添加多个项目到代码中的代码并且只需要编写一个静态项目(即使用item_name而不是item_name_1等),它的工作正常。



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



所以这不工作

  $ ITM = 1; 
($ 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);任何人有什么想法可以使它与多个项目一起工作?

$ b $($)
$ / code $我已经解决了这个问题。
在EncryptedButtons类更改

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

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

并添加

 code> $ this-> _data。=upload = 1\\\
;

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


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?

解决方案

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.

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

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆