Paypal Express 结账的优惠券代码 [英] Coupon Code For Paypal Express Checkout

查看:20
本文介绍了Paypal Express 结账的优惠券代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站上使用 Paypal Express Checkout 系统.但我想放一个优惠券(折扣)代码区.如果代码为真,它将减少.(就像 GoDaddy.com 的购物车系统)

I'm using Paypal Express Checkout system on my website. But I want to put a coupon (discount) code area. It will make a reduction if code is true. (Like GoDaddy.com's cart system)

你知道我应该从哪里开始吗?

Have you any idea, where should I start for this?

(我没有使用任何电子商务框架)

(I'm not using any eCommerce framework)

推荐答案

一种方法是在您的网站上放置一个购物车,用户可以在其中输入促销代码.一旦他们输入了他们的促销代码,并准备好开始结帐过程,这就是您将他们重定向到快速结帐(您将订单的最终金额发送给 Paypal 等)的时间.

One approach is to have a shopping cart on your site where the user can enter a promo code. Once they've entered their promo codes, and are ready to begin the checkout process, this is when you redirect them to the Express Checkout (where you send Paypal the final amount of your order, etc).

根据 Paypal 论坛上的这篇帖子,他们没有将折扣详细信息传递给结帐流程的功能:https://www.x.com/thread/39681(使用快速结账功能,所有折扣计算都需要在您的网站上完成.")

According to this post on Paypal forum, they do not have a feature to pass the discount details to the checkout process: https://www.x.com/thread/39681 ("With express checkout all discount calculations will need to be done on your site.")

在将价格发送到 paypal 之前如何计算
1) 将促销代码的单独表单添加到您的页面:

How to calculate before sending price to paypal
1) Add a SEPARATE form for the promo code to your page:

<form method="GET">
    <input type="text" name="promocode"> 
    <input type="submit" value="Add Promo">
</form>

2) 在服务器端,检查代码,用新价格相应地更新页面(例如,用新价格重新构建您的选择菜单).PHP 示例:

2) On the server side, check the code, update the page accordingly with new prices (e.g. re-build your select menu with new prices). Example with PHP:

<?
if(isset($_GET('promocode')) {
    $prices = processPromo($_GET('promocode'));
}
else {
    $prices = array(2000, 4000, 6000);
}
?>

如果您无权访问服务器,我猜您将不得不使用 JavaScript 来执行此操作(即将您的促销代码和价格硬编码到页面中)

If you don't have access to the server, you would have to do this with JavaScript I guess (i.e. have your promo-code and price hard-coded into the page)

在服务器端启动快速结账
下载 PHP NVP SDK &来自 Paypal 网站的示例:
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/library_download_sdks

<?php
require_once 'CallerService.php';

session_start();


ini_set('session.bug_compat_42',0);
ini_set('session.bug_compat_warn',0);

/* Gather the information to make the final call to
   finalize the PayPal payment.  The variable nvpstr
   holds the name value pairs
   */
$token =urlencode( $_SESSION['token']);
$paymentAmount =urlencode ($_SESSION['TotalAmount']);
$paymentType = urlencode($_SESSION['paymentType']);
$currCodeType = urlencode($_SESSION['currCodeType']);
$payerID = urlencode($_SESSION['payer_id']);
$serverName = urlencode($_SERVER['SERVER_NAME']);

$nvpstr='&TOKEN='.$token.'&PAYERID='.$payerID.'&PAYMENTACTION='.$paymentType.'&AMT='.$paymentAmount.'&CURRENCYCODE='.$currCodeType.'&IPADDRESS='.$serverName ;



 /* Make the call to PayPal to finalize payment
    If an error occured, show the resulting errors
    */
$resArray=hash_call("DoExpressCheckoutPayment",$nvpstr);

/* Display the API response back to the browser.
   If the response from PayPal was a success, display the response parameters'
   If the response was an error, display the errors received using APIError.php.
   */
$ack = strtoupper($resArray["ACK"]);


if($ack != 'SUCCESS' && $ack != 'SUCCESSWITHWARNING'){
    $_SESSION['reshash']=$resArray;
    $location = "APIError.php";
         header("Location: $location");
               }

?>

这篇关于Paypal Express 结账的优惠券代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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