Paypal Express - Add Discount(Paypal Express - 添加折扣)
问题描述
我目前正在向 Paypal Express 发送常规交易,并且正在顺利到达网关.
I'm currently posting a regular transaction to Paypal Express and am reaching the gateway without error.
我现在想配置我的购物车以向网关发送折扣.我的第一个想法是修改发送到网关的AMT"值.但是,Paypal 似乎通过计算 ITEMAMT
、TAXAMT
和 SHIPPINGAMT
字段的总数来验证AMT"字段,以确保总数为不变:
I would like to now configure my cart to send a discount to the gateway. My first thought was to modify the 'AMT' value that is sent to the gateway. However, it seems that Paypal validates the 'AMT' field by calculating the total of the ITEMAMT
, TAXAMT
and SHIPPINGAMT
fields to ensure the total is unchanged:
[L_AMT0] => 49.99
[L_NUMBER0] => 3706{3}8
[L_QTY0] => 1
[L_TAXAMT0] => 0.00
[ITEMAMT] => 49.99
[TAXAMT] => 0
[SHIPPINGAMT] => 14.95
[AMT] => 64.94
我向 Paypal 发送多少折扣?我已经查看了我能找到的文档,但没有运气;SO上的类似问题也无济于事.谢谢.
How many I send a discount to Paypal? I have looked through what documentation I can find, with no luck; the similar questions here on SO were no help, either. Thanks.
编辑:我注意到我可以通过字段SHIPDISCMT
.我不知道这是否能让我做我需要它做的事情 - 我仍然收到表明某些内容不匹配"的错误.
Edit: I've noticed I can pass through the field SHIPDISCAMT
. I don't know if this will let me do what I need it to though - I am still getting errors that indicate soemthing is 'mismatched'.
推荐答案
知道了.
事实证明,您可以将负金额作为订单项传递并自己将其标记为折扣.我不得不添加上面的代码:
It turns out that you can pass a negative amount through as a line item and label it as a discount yourself. I had to add the above code:
$params['L_NAME1'] = 'Discount Coupon';
$params['L_AMT1'] = -$discountCodeAmount;
$params['L_QTY1'] = 1;
$params['ITEMAMT'] -= $discountCodeAmount;
$params['AMT'] -= $discountCodeAmount;
这产生了以下效果:
我在此 PDF 中找到了答案:
I found my answer in this PDF:
https://cms.paypal.com/cms_content/CA/en_US/files/developer/PP_ExpressCheckout_IntegrationGuide.pdf
出于某种原因,我读过的其他几篇 PayPal express 官方文章/文件中没有提供该信息.
For some reason, that information was not given in several other official PayPal express articles/documents I had read.
这篇关于Paypal Express - 添加折扣的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Paypal Express - 添加折扣
基础教程推荐
- PHP 守护进程/worker 环境 2022-01-01
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01
- 使用 PDO 转义列名 2021-01-01
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01
- HTTP 与 FTP 上传 2021-01-01
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01
- 如何在 XAMPP 上启用 mysqli? 2021-01-01