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

查看:73
本文介绍了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)

推荐答案

一种方法是在您的网站上放置一个购物车,用户可以在其中输入促销代码.一旦他们输入了促销代码,并准备开始结帐过程,就可以将它们重定向到Express Checkout(在这里向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论坛上的此帖子,他们没有将折扣详细信息传递到结帐流程的功能:

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.")

在将价格发送给贝宝之前如何计算
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和贝宝网站上的示例:
https://cms.paypal.com/us/cgi-bin/?cmd = _render-content& content_ID = developer/library_download_sdks

To initiate express checkout on server side
Download PHP NVP SDK & examples from Paypal's website:
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天全站免登陆