gpt4 book ai didi

asp.net - 从 Paypal 网站返回后,使用 Paypal 付款不起作用

转载 作者:太空宇宙 更新时间:2023-11-03 16:08:11 36 4
gpt4 key购买 nike

我的 Paypal 付款方式无效。在用户到达 Paypal 页面并描述他购买的商品后,它会被定向到我的网站,显示付款已成功

http://example.com/Store/ReturnPaypal/?token=EC-8F726826L7777777&PayerID=PEWR9EA

但是当我转到我的 PayPal 帐户时,我没有看到任何额外的钱

public ActionResult OrderPaypal()
{
string api_paypal = "https://api-3t.paypal.com/nvp?";
string user = "info_api1.example.com";
string pass = "testpass";
string signature = "test.test-test";
string version = "124.0";
string requete = api_paypal + "VERSION=" + version + "&USER=" + user + "&PWD=" + pass + "&SIGNATURE=" + signature;

requete = requete + "&METHOD=SetExpressCheckout" +
"&CANCELURL=" + HttpUtility.UrlEncode("http://example.com/Store/CancelPaypal/") +
"&RETURNURL=" + HttpUtility.UrlEncode("http://example.com/Store/ReturnPaypal/") +
"&AMT=" + SessionData.CurrentOrder.Total.ToString().Replace(',','.') +
"&CURRENCYCODE=EUR" +
"&DESC=" + HttpUtility.UrlEncode("Paiement total:" + SessionData.CurrentOrder.Total+" €") +
"&LOCALECODE=FR" +
"&HDRIMG=" + HttpUtility.UrlEncode("http://example.com/assets/images/home/image_10000.png");

var httpWebRequest = (HttpWebRequest)WebRequest.Create(requete);

WebResponse httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
string rep = streamReader.ReadToEnd();
if (!string.IsNullOrEmpty(rep))
{
string[] list = rep.Split('&');
Dictionary<string,string> dicParam = new Dictionary<string,string>();
foreach(string str in list)
{
string key = str.Split('=')[0];
string value = str.Split('=')[1];

dicParam.Add(key, value);
}

if (dicParam["ACK"] == "Success")
return Redirect("https://www.paypal.com/webscr&cmd=_express-checkout&token=" + dicParam["TOKEN"]);
else
{
ViewBag.State = "-1";
return View("ReturnSolution",dicParam["L_SHORTMESSAGE0"]);
}
}
else
{
ViewBag.State = "-1";
return View("ReturnSolution", "Error communication PayPal ");
}
}
}

最佳答案

我没有看到您使用 DoExpressCheckout 调用完成交易。

看起来您正在执行 SetExpressCheckout,它将为您提供付款人 ID 和快速结账 token 。你在 URL 中得到这个:

http://example.com/Store/ReturnPaypal/?token=EC-8F726826L7777777&PayerID=PEWR9EA

token =EC-8F726826L7777777

PayerID=PEWR9EA

这在 URL 中返回并用于完成 DoExpressCheckout 调用(我在您的代码中没有看到)。

这是 PHP 中的 SetExpressCheckout 和 DoExpressCheckout 的示例脚本。

<a href='http://marshalcurrier.com/paypal/ExpressCheckout/custom/SetDo.php'>RESET</a><br>
<form method='post'><input type="text" name="CHARGE" value="1"/><input type="submit" value="Pay Now"/><form>
<?php
session_start();

$PPUSER = 'marshal_api1.clubcovert.com';
$PPPWD = 'LL6NV7TDRB9RFXQ5';
$PPSIG = 'ANc3YRaMB1Tgm9TediH0gENHB02JAksSKWD08wVNN3w3pwHqdBW8Im6y';
function url(){ //PayPal Payment URL (TEST or LIVE)
$url = "https://api-3t.sandbox.paypal.com/nvp";
return $url;
}
function curlCall($nvp){ // Function for Curl Call to PayPal.
$url = url();
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($nvp) );
//echo http_build_query($nvp); //Print String
curl_setopt($ch, CURLOPT_URL, $url);
$server_output = curl_exec($ch);
mb_parse_str($server_output, $arr);
return $arr;
}
if(isset($_POST['CHARGE'])){ // SetExpressCheckout Call
$_SESSION['AMT'] = $_POST['CHARGE'];
$nvp = array(
'USER' => $PPUSER,
'PWD' => $PPPWD,
'SIGNATURE' => $PPSIG,
'METHOD' => 'SetExpressCheckout',
'VERSION' => '123',
'PAYMENTREQUEST_0_PAYMENTACTION' => 'SALE',
'PAYMENTREQUEST_0_AMT' => $_POST['CHARGE'],
'PAYMENTREQUEST_0_CURRENCYCODE' => 'USD',
'RETURNURL' => 'http://marshalcurrier.com/paypal/ExpressCheckout/SetDo.php',
'CANCELURL' => 'http://marshalcurrier.com/paypal/ExpressCheckout/SetDo.php',
);
$arr = curlCall($nvp);
echo '<br><br>SetExpressCheckout Call to PayPal:<br><pre>';
print_r ($nvp);
echo '</pre>';
echo 'SetExpressCheckout Server Response:<br><pre>';
print_r ($arr);
echo '</pre>';
echo '<a href="https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token='.($arr['TOKEN']).'">Go To PayPal</a>';
}
if(isset($_GET['PayerID']) && (isset($_POST['CHARGE'])) == false){ // DoExpressCheckoutPayment Call
if (isset($_SESSION['AMT'])){
$AMT = $_SESSION['AMT'];
}else{
$AMT = null;
}
$nvp = array(
'METHOD' => 'DoExpressCheckoutPayment',
'VERSION' => '123',
'USER' => $PPUSER,
'PWD' => $PPPWD,
'SIGNATURE' => $PPSIG,
'PAYERID' => $_GET['PayerID'],
'TOKEN' => $_GET['token'],
'PAYMENTREQUEST_0_PAYMENTACTION' => 'SALE',
'PAYMENTREQUEST_0_AMT' => $AMT,
'PAYMENTREQUEST_0_CURRENCYCODE' => 'USD',
);
$arr = curlCall($nvp);
echo '<br><br>DoExpressCheckoutPayment Call to PayPal:<br><pre>';
print_r ($nvp);
echo '</pre>';
echo 'DoExpressCheckoutPayment Server Response:<br><pre>';
print_r ($arr);
echo '</pre>';
unset($_SESSION['AMT']);
}
?>

关于asp.net - 从 Paypal 网站返回后,使用 Paypal 付款不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31658912/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com