- 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/
我刚刚克隆了 ProductHunt.com 网站,在处理 url 时,我收到了名称错误的错误!当我输入“localhost:8000/accounts/signup”时,它应该带我进入一个 html
我正在将 account.analytic.account 字段从销售订单传递到发票。意图是在确认销售订单时通过该字段。 def _prepare_invoice(self, cr, uid, ord
我有一个奇怪的问题,并不是真正的技术性问题,但我确实希望收集有意义的建议。 我正在构建一个大型 Web 应用程序,基本上是一个照片共享社区站点。作为该站点的一部分,登录用户可以转到他们的个人资料,从中
在 Google Play 开发者控制台中,我在启动前测试中收到警告,其中提到: java.lang.NullPointerException:尝试从字段“java.lang.String andro
我的网站抛出以下异常: IOException: The account used is a computer account. Use your global user account or loc
我在 test 模块下通过 stripe api 在 stripe 中创建了一个帐户。并与该账户绑定(bind)一个银行账户。转到 Stripe dashboard -> connect -> acc
我最近在 Play 商店中更新了我的第一个 android 应用程序,并且发布前报告报告了特定设备上的一个错误。提供的堆栈跟踪如下: FATAL EXCEPTION: main Process: co
我想显示类似的东西: 案例一:“以用户身份登录” @ UserName [ logout ] 这里没有问题,我只是这样做: @ {{ app.user.username}} [ 注销 ] 案例2:“以
为了能够测试 Android Market 许可的任何实现(例如 LVL、应用内结算),Google 建议创建一个 Google Checkout 测试账号 ,因为开发者无法使用自己的 Google
我的公司有一个 Apple 企业帐户,我们用它来为使用 MDM 的员工部署应用程序。工作正常。 我们正在与外部开发人员一起开发一款应用。这个应用程序可能会被放入 App Store。 我大致理解Ent
我有这个方法: @api.multi @api.depends('order_picking', 'order_picking.isbn', 'contract_worksheet', 'state'
我来自以太坊环境,Solana 概念有点令人困惑。我找到了各种指导代码步骤的教程,但并没有真正解释逻辑背后的概念。 我知道在 Solana 中我们有程序,它们不包含数据,只是逻辑 - 网络中的可执行实
我正在编写一个应用程序来访问 Office 365 中用户的数据(电子邮件、联系人、日历)。因此我需要为外部用户启用对我的访问。 我已按照此处的 Microsoft Office 说明 ( http:
我正在构建我的第一个 Meteor 应用程序,在配置accounts-ui/accounts-google 时,系统会提示我将授权重定向 URI 设置为:http://localhost:3000/_
我正在创建一个应该能够读取某个域的所有用户的市场应用程序。我请求访问这些范围: https://www.googleapis.com/auth/userinfo.email https://www.
几天来,我一直在努力显示数据集中表中的数据。当我不在 WHERE 中放置条件时,它会显示完整的表,但只需要表中满足条件的行。如果有更快查看的建议。多谢。 myConnectionString = pw
我正在尝试使用来自 qt c++ 代码的 android AccountManager。要添加帐户,我想创建一个 android.accounts.Account 的实例,我正在尝试使用以下代码执行此
出于某种原因,一小部分 iOS 10 用户无法从我的公共(public) iCloud 容器中读取数据。 CloudKit 返回的 localisedError 是“Account doesn't h
我刚刚开始使用 Stripe API,并且已经遇到了一些我不明白的事情: 我如何确定我自己的 Stripe 帐户的标识符(例如, acct_abcd1234blablabla )? 我在临时 Stri
需要从贷方和借方帐号相同的借方总额中减去贷方总额。如果一个值只存在于借记账号,没有什么可以减去的,只需要得到这个值。 名为 18_7_ChartOfAccounts 的表如下所示: ID | Acco
我是一名优秀的程序员,十分优秀!