- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我在我的项目中使用了这个类:
http://www.saaraan.com/2012/07/paypal-expresscheckout-with-php
我修改了process.php中的一些编码。
以及 2 个 json 变量传递到 php 以获取交易数据。
交易成功。但最终只能在卖家账户中显示总价。
这很奇怪。
我查看了旧帖子,没有运气......
- 我已设置使用最新版本 nvp 106.0
- 我为 webscr url 重定向添加了 useraction=commit。
- 我已经为 SetExpressCheckOut 方法和 DoExpressCheckOut 方法设置了项目的参数。
我的情况有什么解决方案吗?~
这是我的代码:
进程.php
<?php
header("Content-type: text/html; charset=utf-8");
session_start();
include_once("config.php");
include_once("paypal.class.php");
if($_POST) //Post Data received from product list page.
{
$products_obj_arr=urldecode($_POST['products_obj_arr']);
$products_obj_arr = str_replace('\"', '"', $products_obj_arr);
$products_obj_arr=json_decode($products_obj_arr);
$current_cart_items=urldecode($_POST['current_cart_items']);
$current_cart_items = str_replace('\"', '"', $current_cart_items);
$current_cart_items=json_decode($current_cart_items);
$item_str='';
$ItemTotalPrice=0;
for($i=0;$i<sizeof($current_cart_items);$i++)
{
$ItemNumber=$current_cart_items[$i]->product_ref;
$ItemQty=$current_cart_items[$i]->amount;
for($j=0;$j<sizeof($products_obj_arr);$j++)
{
if($products_obj_arr[$j]->product_ref==$current_cart_items[$i]->product_ref)
{
$ItemPrice=$products_obj_arr[$j]->product_price;
$ItemName=$products_obj_arr[$j]->product_name_en;
$ItemName=str_replace('<br/>', ' ', $ItemName);
}
}
$item_str.='&L_PAYMENTREQUEST_0_QTY'.$i.'='. urlencode($ItemQty).
'&L_PAYMENTREQUEST_0_AMT'.$i.'='.urlencode($ItemPrice).
'&L_PAYMENTREQUEST_0_NAME'.$i.'='.urlencode($ItemName).
'&L_PAYMENTREQUEST_0_NUMBER'.$i.'='.urlencode($ItemNumber).
'&L_PAYMENTREQUEST_0_DESC'.$i.'=';
$ItemTotalPrice += ($ItemPrice*$ItemQty);
}
$email=$_POST['paypal_email'];
$name=$_POST['paypal_name'];
$phone=$_POST['paypal_phone'];
$address=$_POST['paypal_address'];
$padata = '&EMAIL='.urlencode($email).
'&SHIPTONAME='.urlencode($name).
'&SHIPTOPHONENUM='.urlencode($phone).
'&SHIPTOSTREET='.urlencode($address).
'&CURRENCYCODE='.urlencode($PayPalCurrencyCode).
'&PAYMENTACTION=Sale'.
'&ALLOWNOTE=1'.
'&PAYMENTREQUEST_0_CURRENCYCODE='.urlencode($PayPalCurrencyCode).
'&PAYMENTREQUEST_0_AMT='.urlencode($ItemTotalPrice).
'&PAYMENTREQUEST_0_ITEMAMT='.urlencode($ItemTotalPrice).
'&AMT='.urlencode($ItemTotalPrice).
'&RETURNURL='.urlencode($PayPalReturnURL ).
'&CANCELURL='.urlencode($PayPalCancelURL).$item_str;
//We need to execute the "SetExpressCheckOut" method to obtain paypal token
$paypal= new MyPayPal();
$httpParsedResponseAr = $paypal->PPHttpPost('SetExpressCheckout', $padata, $PayPalApiUsername, $PayPalApiPassword, $PayPalApiSignature, $PayPalMode);
//Respond according to message we receive from Paypal
if("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"]))
{
/*
$_SESSION['email'] = $email;
$_SESSION['name'] = $name;
$_SESSION['phone'] = $phone;
$_SESSION['address'] = $address;
$_SESSION['item_str'] = $item_str;
*/
if($PayPalMode=='sandbox')
{
$paypalmode = '.sandbox';
}
else
{
$paypalmode = '';
}
//Redirect user to PayPal store with Token received.
$paypalurl ='https://www'.$paypalmode.'.paypal.com/cgi-bin/webscr?cmd=_express-checkout&useraction=commit&token='.$httpParsedResponseAr["TOKEN"].'';
header('Location: '.$paypalurl);
}else{
//Show error message
echo '<div style="color:red"><b>Error : </b>'.urldecode($httpParsedResponseAr["L_LONGMESSAGE0"]).'</div>';
echo '<pre>';
print_r($httpParsedResponseAr);
echo '</pre>';
}
}
//Paypal redirects back to this page using ReturnURL, We should receive TOKEN and Payer ID
if(isset($_GET["token"]) && isset($_GET["PayerID"]))
{
//we will be using these two variables to execute the "DoExpressCheckoutPayment"
//Note: we haven't received any payment yet.
$token = $_GET["token"];
$playerid = $_GET["PayerID"];
//get session variables
$ItemTotalPrice= $_SESSION['totalamount'] ;
/* $email= $_SESSION['email'] ;
$name=$_SESSION['name'] ;
$phone= $_SESSION['phone'] ;
$address= $_SESSION['address'] ;
*/
$item_str= $_SESSION['item_str'] ;
$padata = '&TOKEN='.urlencode($token).
'&PAYERID='.urlencode($playerid).
'&EMAIL='.urlencode($email).
// '&SHIPTONAME='.urlencode($name).
// '&SHIPTOPHONENUM='.urlencode($phone).
// '&SHIPTOSTREET='.urlencode($address).
'&CURRENCYCODE='.urlencode($PayPalCurrencyCode).
'&PAYMENTACTION=Sale'.
'&ALLOWNOTE=1'.
'&PAYMENTREQUEST_0_CURRENCYCODE='.urlencode($PayPalCurrencyCode).
// '&PAYMENTREQUEST_0_AMT='.urlencode($ItemTotalPrice).
'&PAYMENTREQUEST_0_ITEMAMT='.urlencode($ItemTotalPrice).
'&AMT='.urlencode($ItemTotalPrice).
'&RETURNURL='.urlencode($PayPalReturnURL ).
'&CANCELURL='.urlencode($PayPalCancelURL).$item_str;
//We need to execute the "DoExpressCheckoutPayment" at this point to Receive payment from user.
$paypal= new MyPayPal();
$httpParsedResponseAr = $paypal->PPHttpPost('DoExpressCheckoutPayment', $padata, $PayPalApiUsername, $PayPalApiPassword, $PayPalApiSignature, $PayPalMode);
//Check if everything went ok..
if("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"]))
{
echo '<h2>Success</h2>';
echo 'Your Transaction ID :'.urldecode($httpParsedResponseAr["TRANSACTIONID"]);
/*
//Sometimes Payment are kept pending even when transaction is complete.
//May be because of Currency change, or user choose to review each payment etc.
//hence we need to notify user about it and ask him manually approve the transiction
*/
if('Completed' == $httpParsedResponseAr["PAYMENTSTATUS"])
{
echo '<div style="color:green">Payment Received! Your product will be sent to you very soon!</div>';
}
elseif('Pending' == $httpParsedResponseAr["PAYMENTSTATUS"])
{
echo '<div style="color:red">Transaction Complete, but payment is still pending! You need to manually authorize this payment in your <a target="_new" href="http://www.paypal.com">Paypal Account</a></div>';
}
echo '<br /><b>Stuff to store in database :</b><br /><pre>';
$transactionID = urlencode($httpParsedResponseAr["TRANSACTIONID"]);
$nvpStr = "&TRANSACTIONID=".$transactionID;
$paypal= new MyPayPal();
$httpParsedResponseAr = $paypal->PPHttpPost('GetTransactionDetails', $nvpStr, $PayPalApiUsername, $PayPalApiPassword, $PayPalApiSignature, $PayPalMode);
if("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) {
/*
#### SAVE BUYER INFORMATION IN DATABASE ###
$buyerName = $httpParsedResponseAr["FIRSTNAME"].' '.$httpParsedResponseAr["LASTNAME"];
$buyerEmail = $httpParsedResponseAr["EMAIL"];
$conn = mysql_connect("localhost","MySQLUsername","MySQLPassword");
if (!$conn)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("Database_Name", $conn);
mysql_query("INSERT INTO BuyerTable
(BuyerName,BuyerEmail,TransactionID,ItemName,ItemNumber, ItemAmount,ItemQTY)
VALUES
('$buyerName','$buyerEmail','$transactionID','$ItemName',$ItemNumber, $ItemTotalPrice,$ItemQTY)");
mysql_close($con);
*/
echo '<pre>';
print_r($httpParsedResponseAr);
echo '</pre>';
} else {
echo '<div style="color:red"><b>GetTransactionDetails failed:</b>'.urldecode($httpParsedResponseAr["L_LONGMESSAGE0"]).'</div>';
echo '<pre>';
print_r($httpParsedResponseAr);
echo '</pre>';
}
}else{
echo '<div style="color:red"><b>Error : </b>'.urldecode($httpParsedResponseAr["L_LONGMESSAGE0"]).'</div>';
echo '<pre>';
print_r($httpParsedResponseAr);
echo '</pre>';
}
}
?>
配置.php
$PayPalMode = 'sandbox'; // sandbox or live
$PayPalApiUsername = '___.___.com'; //PayPal API Username
$PayPalApiPassword = '___'; //Paypal API password
$PayPalApiSignature = '___.___.___'; //Paypal API Signature
$PayPalCurrencyCode = 'HKD'; //Paypal Currency Code
$PayPalReturnURL = 'http://___.___-___.___/___-___-/process.php'; //Point to process.php page
$PayPalCancelURL = 'http://___.___-___.___/'; //Cancel URL if user clicks cancel
paypal.class.php
<?php
class MyPayPal {
function PPHttpPost($methodName_, $nvpStr_, $PayPalApiUsername, $PayPalApiPassword, $PayPalApiSignature, $PayPalMode) {
// Set up your API credentials, PayPal end point, and API version.
$API_UserName = urlencode($PayPalApiUsername);
$API_Password = urlencode($PayPalApiPassword);
$API_Signature = urlencode($PayPalApiSignature);
if($PayPalMode=='sandbox')
{
$paypalmode = '.sandbox';
}
else
{
$paypalmode = '';
}
$API_Endpoint = "https://api-3t".$paypalmode.".paypal.com/nvp";
$version = urlencode('106.0');
// Set the curl parameters.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
// Turn off the server and peer verification (TrustManager Concept).
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
// Set the API operation, version, and API signature in the request.
$nvpreq = "METHOD=$methodName_&VERSION=$version&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature$nvpStr_";
// Set the request as a POST FIELD for curl.
curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
// Get response from the server.
$httpResponse = curl_exec($ch);
if(!$httpResponse) {
exit("$methodName_ failed: ".curl_error($ch).'('.curl_errno($ch).')');
}
// Extract the response details.
$httpResponseAr = explode("&", $httpResponse);
$httpParsedResponseAr = array();
foreach ($httpResponseAr as $i => $value) {
$tmpAr = explode("=", $value);
if(sizeof($tmpAr) > 1) {
$httpParsedResponseAr[$tmpAr[0]] = $tmpAr[1];
}
}
if((0 == sizeof($httpParsedResponseAr)) || !array_key_exists('ACK', $httpParsedResponseAr)) {
exit("Invalid HTTP Response for POST request($nvpreq) to $API_Endpoint.");
}
return $httpParsedResponseAr;
}
}
?>
这是 print_r($httpParsedResponseAr) 的结果;
Array
(
[RECEIVEREMAIL] => ________
[RECEIVERID] => 32C4LC3EFLHPQ
[EMAIL] => ________
[PAYERID] => 2TKPDP8R96HJG
[PAYERSTATUS] => unverified
[COUNTRYCODE] => HK
[SHIPTONAME] => ________
[SHIPTOSTREET] => room%202%2c%20room%202%2croom%202
[SHIPTOCOUNTRYCODE] => HK
[SHIPTOCOUNTRYNAME] => Hong%20Kong
[ADDRESSOWNER] => PayPal
[ADDRESSSTATUS] => Unconfirmed
[SALESTAX] => 0%2e00
[SHIPAMOUNT] => 0%2e00
[SHIPHANDLEAMOUNT] => 0%2e00
[TIMESTAMP] => 2013%2d09%2d17T07%3a38%3a07Z
[CORRELATIONID] => ed796a185bca7
[ACK] => Success
[VERSION] => 106%2e0
[BUILD] => 7715813
[FIRSTNAME] => li
[LASTNAME] => yu
[TRANSACTIONID] => 9H1595228W773654H
[RECEIPTID] => 5527%2d6661%2d1991%2d5826
[TRANSACTIONTYPE] => expresscheckout
[PAYMENTTYPE] => instant
[ORDERTIME] => 2013%2d09%2d17T07%3a38%3a05Z
[AMT] => 540%2e00
[FEEAMT] => 20%2e71
[TAXAMT] => 0%2e00
[CURRENCYCODE] => HKD
[PAYMENTSTATUS] => Completed
[PENDINGREASON] => None
[REASONCODE] => None
[PROTECTIONELIGIBILITY] => Ineligible
[PROTECTIONELIGIBILITYTYPE] => None
[L_QTY0] => 1
[L_TAXAMT0] => 0%2e00
[L_CURRENCYCODE0] => HKD
[L_TAXABLE0] => false
)
最佳答案
SetExpressCheckout 是您进行的唯一调用吗?如果是这样,那还不够。在您使用 DoExpressCheckoutPayment 完成所有付款之前,不会实际付款。
您需要确保在请求中包含项目详细信息。从您的示例看起来没有发生,但从您的代码看起来您正试图将它们传递到库中,因此关于该类的某些内容或您传递项目详细信息的方式一定是不准确的。
这是一个示例,其中包含显示在付款详细信息中所需的项目详细信息:
[REQUESTDATA] => Array
(
[USER] => sandbo_1.....leye.com
[PWD] => 12.....74
[VERSION] => 97.0
[BUTTONSOURCE] => AngellEYE_PHPClass
[SIGNATURE] => AiKZhEEPLJjSIccz.....W18v
[METHOD] => SetExpressCheckout
[MAXAMT] => 200.00
[RETURNURL] => http://paypal.angelleye.com/standard/samples/DoExpressCheckoutPayment.php
[CANCELURL] => http://paypal.angelleye.com/paypal/class/cancel.php
[REQCONFIRMSHIPPING] => 0
[NOSHIPPING] => 1
[ALLOWNOTE] => 1
[SOLUTIONTYPE] => Sole
[LANDINGPAGE] => Billing
[BRANDNAME] => Angell EYE
[CUSTOMERSERVICENUMBER] => 555-555-5555
[GIFTMESSAGEENABLE] => 1
[GIFTRECEIPTENABLE] => 1
[GIFTWRAPENABLE] => 1
[GIFTWRAPNAME] => Box with Ribbon
[GIFTWRAPAMOUNT] => 2.50
[BUYEREMAILOPTIONENABLE] => 1
[SURVEYENABLE] => 1
[BUYERREGISTRATIONDATE] => 2012-07-14T00:00:00Z
[L_BILLINGTYPE0] => MerchantInitiatedBilling
[L_BILLINGAGREEMENTDESCRIPTION0] => Billing Agreement
[L_PAYMENTTYPE0] => Any
[PAYMENTREQUEST_0_AMT] => 100.00
[PAYMENTREQUEST_0_CURRENCYCODE] => USD
[PAYMENTREQUEST_0_ITEMAMT] => 80.00
[PAYMENTREQUEST_0_SHIPPINGAMT] => 15.00
[PAYMENTREQUEST_0_TAXAMT] => 5.00
[PAYMENTREQUEST_0_DESC] => This is a test order.
[PAYMENTREQUEST_0_NOTETEXT] => This is a test note before ever having left the web site.
[PAYMENTREQUEST_0_PAYMENTACTION] => Sale
[L_PAYMENTREQUEST_0_NAME0] => Widget 123
[L_PAYMENTREQUEST_0_DESC0] => Widget 123
[L_PAYMENTREQUEST_0_AMT0] => 40.00
[L_PAYMENTREQUEST_0_NUMBER0] => 123
[L_PAYMENTREQUEST_0_QTY0] => 1
[L_PAYMENTREQUEST_0_ITEMURL0] => http://www.angelleye.com/products/123.php
[L_PAYMENTREQUEST_0_NAME1] => Widget 456
[L_PAYMENTREQUEST_0_DESC1] => Widget 456
[L_PAYMENTREQUEST_0_AMT1] => 40.00
[L_PAYMENTREQUEST_0_NUMBER1] => 456
[L_PAYMENTREQUEST_0_QTY1] => 1
[L_PAYMENTREQUEST_0_ITEMURL1] => http://www.angelleye.com/products/456.php
[L_PAYMENTREQUEST_0_ITEMCATEGORY1] => Digital
)
关于javascript - Paypal 快速结账 : Successful transaction but cannot show the order detail in seller account,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18838970/
问题:假设我们有一个名为success 的C++ 字符串。 &success 和 success& 有什么区别? 这题是我期中复习的,我理解&success是获取对象的地址。但我不确定 success
我正在阅读 gearman 代码的手册页( http://manpages.ubuntu.com/manpages/precise/man3/gearman_success.3.html )。他们有两
在 Angular 中,[class]="'success'" 和 class="success" 有区别吗? 例如: ... 或 ... 如果同时使用 IIUC 后者会导致替换前者,所以我想更好
当我查看日志文件时 D:\SAS\XXX\Lev1\SASMain\BatchServer\Logs 我看到了这两行 NOTE: Libref TESTLIB successfully assigne
我正在努力完成这项工作: $http.post('/route/path', {'username': $scope.threadedUsers[currentIndex].name}). s
我正在尝试设置协议(protocol)来处理我的 javascript 函数中的成功和错误,但是当函数成功时它似乎并不合作。我收到以下错误: Failed with: TypeError: Objec
在 typescript 中,我有一个 DataAccess 类,以便所有 Ajax 调用都通过单个对象进行路由,以节省应用程序中许多地方的代码重复。 在使用这种方法时,我需要使用回调将响应返回到调用
我已经用 Spring Security 3.0.2 实现了一个登录-注销系统,一切都很好,但是对于这一点:在我添加了一个带有 invalid-session-url 属性的 session 管理标签
运行命令pip install rpy2会导致以下输出和错误消息:。我按照另一篇Stackoverflow帖子上的说明卸载并重新安装了R和相关目录,但得到了相同的错误。我还尝试安装以前版本的rpy2,
我最近在项目的测试目标中添加了一个新的单元测试,当我点击产品 > 测试时,Xcode 说“测试成功”。我相当确定测试应该失败,因为被测试的方法尚未实现。我在测试中添加了一个断点,但从未到达过;测试仍然
我正在编写一个程序来创建一个AD帐户并启用Exchange邮箱,并且从中得到一些奇怪的行为。 首先,尽管它成功创建了AD用户,但由于“找不到MyPath/先生示例”,因此无法启用邮箱。我认为这是由于A
在cd_deployer_conf文件中我们设置了Cleanup="false,这样传输包在发布后不会被删除,但是我们可以看到单个发布操作有3个不同的包喜欢 tcm_0-264891-66560.CO
我正在使用 $().each() 循环访问一些项目。我想确保这段脚本之后的操作仅在 each() 完成时执行。 示例: $('something').each(function() { // do
我正在尝试创建一个 ping 洪水程序,它将目标 IP 地址和广播 IP 地址作为参数。该程序将向广播地址发送 icmp echo 数据包,并将受害者的 IP 地址作为源。网络上所有收到数据包的主机都
我正在实现一个虚拟 LTE EPC 设置,其模块 (HSS) 之一需要 mysql 数据库。创建后,我必须运行该模块,但收到屏幕截图 1 中所示的错误。附:我对这个东西很陌生 最佳答案 您必须修改您的
#include #include #include #include #include #include #include #include #include void error(cha
我的基本代码如下, fd = open("test.file", O_RDONLY); if (read(fd, &tempch, 1) < 1) { perror("F
更新 :这似乎是在 Pipeline: Declarative 中引入的错误插件版本 1.3.5 - 降级到 1.3.4.1解决了这个问题。票证创建于: https://issues.jenkins-
我最近在 jQuery 网站上看到了弃用通知。 Deprecation Notice: The jqXHR.success(), jqXHR.error(), and jqXHR.complete()
我假设调用 status.success() 会终止后台作业。但是,当我运行它时,我仍然看到第二条日志消息: Parse.Cloud.job("Tester", function (request,
我是一名优秀的程序员,十分优秀!