这篇文章主要围绕asp.net-mvc–PaypalRESTAPI–在付款过程中传递参数和付款方式paypal是什么意思展开,旨在为您提供一份详细的参考资料。我们将全面介绍asp.net-mvc–Pa
这篇文章主要围绕asp.net-mvc – Paypal REST API – 在付款过程中传递参数和付款方式paypal是什么意思展开,旨在为您提供一份详细的参考资料。我们将全面介绍asp.net-mvc – Paypal REST API – 在付款过程中传递参数的优缺点,解答付款方式paypal是什么意思的相关问题,同时也会为您带来api – PayPal自适应付款错误您无权隐式执行此付款、asp.net – PayPal Express Checkout MVC C#示例代码、asp.net – Paypal Express Checkout集成问题(WEBREQUEST)、asp.net – PayPal REST API DotNet SDK 1.9.1 – URI端点在哪里?的实用方法。
本文目录一览:- asp.net-mvc – Paypal REST API – 在付款过程中传递参数(付款方式paypal是什么意思)
- api – PayPal自适应付款错误您无权隐式执行此付款
- asp.net – PayPal Express Checkout MVC C#示例代码
- asp.net – Paypal Express Checkout集成问题(WEBREQUEST)
- asp.net – PayPal REST API DotNet SDK 1.9.1 – URI端点在哪里?
asp.net-mvc – Paypal REST API – 在付款过程中传递参数(付款方式paypal是什么意思)
>我打电话给PayPal.Api.Payment.Create(APIContext)重定向到Paypal网站,成功的网址;
>在与成功URL对应的回调操作中,调用PayPal.Api.Payment.Execute(APIContext,ExecutionContext).
我需要的是在调用Payment.Create()时将新订单的ID传递给Paypal,并在Payment.Execute()中接收其值,以便它可以知道付款与哪个订单相关联.
可能吗?非常感谢.
解决方法
找到以下这一行:invoice_number = YOUR_ORDER_NUMBER
您的PayPal请求:(taken from SDK Samples)
var apiContext = Configuration.GetAPIContext(); // A transaction defines the contract of a payment - what is the payment for and who is fulfilling it. var transaction = new Transaction() { amount = new Amount(){...},description = "This is the payment transaction description.",item_list = new ItemList(){...},//SET YOUR ORDER NUMBER HERE invoice_number = YOUR_ORDER_NUMBER }; // A resource representing a Payer that funds a payment. var payer = new Payer(){...}; // A Payment resource; create one using the above types and intent as `sale` or `authorize` var payment = new Payment() { intent = "sale",payer = payer,transactions = new List<Transaction>() { transaction } }; this.flow.AddNewRequest("Create credit card payment",payment); // Create a payment using a valid APIContext var createdPayment = payment.Create(apiContext);
PayPal(Taken From Here)的回应:
api – PayPal自适应付款错误您无权隐式执行此付款
将XML发送到端点https://svcs.paypal.com/AdaptivePayments/Pay:
我使用我的实时API密钥和真实帐户凭据发送它:
> applicationId =我的实时应用ID(已批准)
> X-PAYPAL-Security-USERID =我的实时API用户ID(blah_api1.mysite.com)
> X-PAYPAL-Security-PASSWORD =我的实时API密码
> X-PAYPAL-Security-SIGNATURE =我的实时API信号
> X-PAYPAL-SERVICE-VERSION = 1.1.0
> X-PAYPAL-APPLICATION-ID =实时应用ID(例如APP-5F976659LV9322736)
> X-PAYPAL-REQUEST-DATA-FORMAT = XML
> X-PAYPAL-RESPONSE-DATA-FORMAT = XML
发送有效载荷:
<?xml version="1.0" encoding="UTF-8"?> <PayRequest xmlns:ns2="http://svcs.paypal.com/types/ap"> <requestEnvelope> <errorLanguage>en_US</errorLanguage> <detailLevel>ReturnAll</detailLevel> </requestEnvelope> <clientDetails> <applicationId>APP-5F976659LV9322736</applicationId> <partnerName>MyName</partnerName> </clientDetails> <actionType>PAY</actionType> <cancelUrl>https://mysite.com</cancelUrl> <returnUrl>https://mysite.com</returnUrl> <currencyCode>USD</currencyCode> <feesPayer>EACHRECEIVER</feesPayer> <memo>blah blah</memo> <receiverList> <receiver> <amount>6.66</amount> <email>personimpaying@gmail.com</email> </receiver> </receiverList> <senderEmail>me@gmail.com</senderEmail> <trackingId>f166b253-063e-4e24-9fd0-519ccddfffeb</trackingId> </PayRequest>
答复:
<?xml version='1.0' encoding='UTF-8'?> <ns3:FaultMessage xmlns:ns3="http://svcs.paypal.com/types/common" xmlns:ns2="http://svcs.paypal.com/types/ap"> <responseEnvelope> <timestamp>2014-01-13T20:49:46.191-08:00</timestamp> <ack>Failure</ack> <correlationId>5924cfcacbf00</correlationId> <build>7935900</build> </responseEnvelope> <error><errorId>550001</errorId> <domain>PLATFORM</domain> <subdomain>Application</subdomain> <severity>Error</severity> <category>Application</category> <message>You do not have permission to execute this payment implicitly</message> </error> </ns3:FaultMessage>
我在“senderEmail”字段中尝试了两个已注册的电子邮件 – 两者都有同样的问题.
我见过一些人反对这个问题,但没有决议.有人有什么建议吗?
编辑 – 我也尝试过明确付款,但是当我尝试在付款时使用ExecutePayment时,我收到以下错误:
<?xml version='1.0' encoding='UTF-8'?> <ns3:FaultMessage xmlns:ns3="http://svcs.paypal.com/types/common" xmlns:ns2="http://svcs.paypal.com/types/ap"> <responseEnvelope> <timestamp>2014-02-02T19:34:44.256-08:00</timestamp> <ack>Failure</ack> <correlationId>abcdefg</correlationId> <build>7935900</build> </responseEnvelope> <error> <errorId>550001</errorId> <domain>PLATFORM</domain> <subdomain>Application</subdomain> <severity>Error</severity> <category>Application</category> <message>User is not allowed to perform this action</message> </error> </ns3:FaultMessage>
解决方法
asp.net – PayPal Express Checkout MVC C#示例代码
谢谢!
解决方法
你可以从这里得到来源;
https://bitbucket.org/jhelmink/paypalexpresscheckoutmvc
希望有帮助!
asp.net – Paypal Express Checkout集成问题(WEBREQUEST)
所以我把所有的代码都剥离回基本并简单地通过HTTP提交了请求,PLUS方面是我现在从PayPal沙箱服务器得到一个响应,其中ACK = Success和TOKEN = Valid-token-value-这里有一些还返回其他变量,例如CORRELATIONID和TIMESTAMP.
因此,我尝试了一些webrequest示例,我只是得到一个空白屏幕,而不是被重定向到Paypal(沙盒)客户完成付款.
因此,如果任何人都可以发布他们的WebRequest方法,这将是伟大的.
这是我用于webrequest的代码,我确定它错了,但无法确定它出错的地方.
此外,当我在调试期间在localhost上运行代码时,一切正常,并且通过SUCCESS完成调用并收到TOKEN.
当我实时运行时,我在错误异常中收到错误号5,并在状态描述中收到文件“远程主机无法连接”.
这是更新的代码
Function MakeWebRequest(ByVal pUseSandBox As Boolean,ByVal pRequestMethod As String,ByVal pReturnUrl As String,ByVal pCancelUrl As String,ByRef pRtnStatus As String,ByRef pRtnStatusId As HttpStatusCode,ByRef pRtnResponseString As String) As Boolean ' Dim _sxHost As String = nothing Dim _sxEndpoint As String = nothing Dim _sxNameValCol As System.Collections.Specialized.NameValueCollection = nothing Dim _sxResponseCol As System.Collections.Specialized.NameValueCollection = nothing Dim _sxCounta As Integer = nothing Dim _sxParamsstring As String = nothing ' '-> Init _sxParamsstring = "" MakeWebRequest = False _sxNameValCol = New System.Collections.Specialized.NameValueCollection() _sxResponseCol = New System.Collections.Specialized.NameValueCollection() If pUseSandBox Then _sxHost = "http://www.sandBox.paypal.com" _sxEndpoint = "https://api-3t.sandBox.paypal.com/nvp" Else _sxHost = "http://www.paypal.com" _sxEndpoint = "https://api-3t.paypal.com/nvp" End If '-> Create Request Try '-> Key/Value Collection Params _sxNameValCol.Add("METHOD","SetExpressCheckout") _sxNameValCol.Add("USER",_UserName) _sxNameValCol.Add("PWD",_Password) _sxNameValCol.Add("SIGNATURE",_Signature) _sxNameValCol.Add("PAYMENTREQUEST_0_AMT",Format(_Basket.BasketTotalIncDelivery / 100,"0.00")) _sxNameValCol.Add("PAYMENTREQUEST_0_PAYMENTACTION","Sale") _sxNameValCol.Add("PAYMENTREQUEST_0_CURRENCYCODE","GBP") _sxNameValCol.Add("RETURNURL",pReturnUrl) _sxNameValCol.Add("CANCELURL",pCancelUrl) _sxNameValCol.Add("REQCONFIRMSHIPPING","0") _sxNameValCol.Add("NOSHIPPING","2") _sxNameValCol.Add("LOCALECODE","EN") _sxNameValCol.Add("BUTTONSOURCE","PP-ECWizard") _sxNameValCol.Add("VERSION","93.0") '-> UrlEncode For _sxCounta = 0 To _sxNameValCol.Count - 1 If _sxCounta = 0 Then _sxParamsstring = _sxParamsstring & _sxNameValCol.Keys(_sxCounta) & "=" & HttpUtility.UrlEncode(_sxNameValCol(_sxCounta)) Else _sxParamsstring = _sxParamsstring & "&" & _sxNameValCol.Keys(_sxCounta) & "=" & HttpUtility.UrlEncode(_sxNameValCol(_sxCounta)) End If Next '-> Credentials (not used) '_sxRequest.Credentials = CredentialCache.DefaultCredentials Try Dim _sxRequest As WebRequest = DirectCast(System.Net.WebRequest.Create(_sxEndpoint),System.Net.HttpWebRequest) '-> Convert request to byte-array Dim _sxByteArray As Byte() = Encoding.UTF8.GetBytes(_sxParamsstring) _sxRequest.Method = "POST" 'Our method is post,otherwise the buffer (_sxParamsstring) would be useless _sxRequest.ContentType = "application/x-www-form-urlencoded" 'We use form contentType,for the postvars _sxRequest.ContentLength = _sxByteArray.Length 'The length of the buffer (postvars) is used as contentlength Dim _sxPostDataStream As System.IO.Stream = _sxRequest.GetRequestStream() 'We open a stream for writing the postvars _sxPostDataStream.Write(_sxByteArray,_sxByteArray.Length) 'Now we write,and afterwards,we close _sxPostDataStream.Close() 'Closing is always important! '-> Create Response Dim _sxResponse As HttpWebResponse = DirectCast(_sxRequest.GetResponse(),HttpWebResponse) '-> Get Response Status pRtnStatus = _sxResponse.StatusDescription pRtnStatusId = _sxResponse.StatusCode '-> Reponse Stream Dim _sxResponseStream As Stream = _sxResponse.GetResponseStream() 'Open a stream to the response '-> Response Stream Reader Dim _sxStreamReader As New StreamReader(_sxResponseStream) 'Open as reader for the stream pRtnResponseString = _sxStreamReader.ReadToEnd() 'Read the response string MakeWebRequest = True '-> Tidy up _sxStreamReader.Close() _sxResponseStream.Close() _sxResponse.Close() _sxByteArray = nothing _sxPostDataStream = nothing _sxRequest = nothing _sxResponse = nothing _sxResponseStream = nothing _sxStreamReader = nothing Catch ex As Exception pRtnStatusId = Err.Number pRtnStatus = "response(" & ex.Message & ")" Decode(pRtnResponseString,_sxResponseCol) pRtnResponseString = Stringify(_sxResponseCol) End Try Catch ex As Exception pRtnStatusId = Err.Number pRtnStatus = "request(" & ex.Message & ")" Decode(pRtnResponseString,_sxResponseCol) pRtnResponseString = Stringify(_sxResponseCol) End Try '-> Tidy Up _sxHost = nothing _sxEndpoint = nothing _sxNameValCol = nothing _sxResponseCol = nothing _sxCounta = nothing _sxParamsstring = nothing ' End Function
解决方法
TIMESTAMP=2015-07-07T09:07:39Z&CORRELATIONID=7f4d2313c9696&ACK=Failure&VERSION=93.0&BUILD=17276661&L_ERRORCODE0=10002&L_SHORTMESSAGE0=Authentication/Authorization Failed&L_LONGMESSAGE0=You do not have permissions to make this API call&L_SEVERITYCODE0=Error
显然那是因为我测试了一个空白的用户名和密码.
因此,您的服务器设置存在问题,导致您无法在IIS级别或防火墙配置进行外部连接.
如果没有物理存在于您的计算机上,我们可以做很多事情来追踪阻止它的内容,但您可以尝试向其他公共网站(如Google.com)打开HTTP请求,看看这些是否成功.
asp.net – PayPal REST API DotNet SDK 1.9.1 – URI端点在哪里?
运行SDK代码示例(取自PayPal的开发人员站点)似乎会自动生成3个链接.
我是否需要担心URI是否嵌入在某个地方的dll中?
有没有理由改变它?
*****编辑*******
这是我用来获取APIContext的代码 – 有没有人看到这段代码的问题?无论我为端点(或模式,或者你有什么)投入什么,SDK总是使用沙箱端点.这里真正的疯狂是它正在接受LIVE ClientId和Secret(因此它肯定会连接到LIVE端点),但是任何进一步的请求始终都是沙箱端点.注意:此函数仅调用一次,Context仅传递给其他函数/调用/ what-have-you.我甚至把它设置为通过引用而没有快乐.
public static PayPal.Api.APIContext GetPaypalRestAPIContext() { try { Dictionary<string,string> config = null; if (WebAppSettings.PaypalMode.ToLower != "live") { config = new Dictionary<string,string>() { {"mode",WebAppSettings.PaypalMode.ToLower},{"clientId",WebAppSettings.PaypalTestClientId},{"clientSecret",WebAppSettings.PaypalTestClientSecret},{"endpoint","https://api.sandBox.paypal.com/"} }; } else { config = new Dictionary<string,WebAppSettings.PaypalClientId},WebAppSettings.PaypalClientSecret},"https://api.paypal.com/"} }; } string accesstoken = (new PayPal.Api.OAuthTokenCredential(config)).GetAccesstoken(); PayPal.Api.APIContext apiContext = new PayPal.Api.APIContext(accesstoken); return apiContext; } catch (Exception ex) { EventLog.LogEvent("Paypal APIContext","PaypalRestAPIContext has Failed.",EventLogSeverity.Warning); return null; } }
我觉得我在这里错过了一些东西或者失去了理智.
解决方法
The URL to the API service
- SandBox.
https://api.sandBox.paypal.com
- Live.
https://api.paypal.com
这些相同的URL可以在BaseConstants类的GitHub Repository of the SDK中找到,这意味着它们实际上是在SDK中嵌入/硬编码的
/// <summary> /// SandBox REST API endpoint /// </summary> public const string RESTSandBoxEndpoint = "https://api.sandBox.paypal.com/"; /// <summary> /// Live REST API endpoint /// </summary> public const string RESTLiveEndpoint = "https://api.paypal.com/"; /// <summary> /// Security Test SandBox REST API endpoint /// </summary> public const string RESTSecurityTestSandoxEndpoint = "https://test-api.sandBox.paypal.com/";
这将确认观察到由SDK“生成”的3个链接.
文档中也提到了.
In order to use the PayPal .NET SDK with your application,you will need to first configure your application. By default,the SDK will attempt to look for PayPal-specific settings in your application’s web.config or app.config file.
PayPal Config Settings
The following is a sample config file containing the configuration sections that are required in order for the settings to be used with this SDK:
<configuration> <configSections> <section name="paypal" type="PayPal.SDKConfigHandler,PayPal" /> </configSections> <!-- PayPal SDK settings --> <paypal> <settings> <add name="mode" value="sandBox"/> <add name="clientId" value="_client_Id_"/> <add name="clientSecret" value="_client_secret_"/> </settings> </paypal> </configuration>
mode: Determines which PayPal endpoint URL will be used with your application. Possible values are
live
orsandBox
.
因此,看起来设置中的模式将确定在向API发出请求时SDK调用哪个端点URL.
回答你的问题.
Do I need to worry that the URI is embedded in the dll somewhere?
没有.
Would there be any reason to change it?
它们允许工具在设置中更改代码运行的模式,以便在执行时使用适当的enpoint URL.这意味着如果要对沙箱运行测试,则只需更改应用程序的模式设置即可.
今天关于asp.net-mvc – Paypal REST API – 在付款过程中传递参数和付款方式paypal是什么意思的介绍到此结束,谢谢您的阅读,有关api – PayPal自适应付款错误您无权隐式执行此付款、asp.net – PayPal Express Checkout MVC C#示例代码、asp.net – Paypal Express Checkout集成问题(WEBREQUEST)、asp.net – PayPal REST API DotNet SDK 1.9.1 – URI端点在哪里?等更多相关知识的信息可以在本站进行查询。
本文标签: