此交易无效。请返回收件人的网站并重试
Posted
技术标签:
【中文标题】此交易无效。请返回收件人的网站并重试【英文标题】:This transaction is invalid. Please return to the recipient's website and try again 【发布时间】:2012-07-20 00:47:41 【问题描述】:这是我的控制器:
setup_purchase 方法对我的数据 api 来说效果很好,但 preapprove_payment 方法不起作用。
def pay
gateway = ActiveMerchant::Billing::PaypalAdaptivePayment.new(
:login => "email",
:password => "pass",
:signature => "signature",
:appid => "APP-80W284485P519543T" )
response = gateway.preapprove_payment(
:return_url => user_orders_url(current_user),
:cancel_url => user_orders_url(current_user),
:sender_email =>"email",
:start_date => Time.now,
:end_date => Time.now,
:currency_code =>"USD",
:max_amount => "20",
:maxNumberOfPayments => "2")
puts response.preapproval_key
puts gateway.debug
# for redirecting the customer to the actual paypal site to finish the payment.
redirect_to (gateway.redirect_url_for(response["preapproval_key"]))
end
我进入日志:
PA-8K9332086D720151L
:url=>#<URI::HTTPS:0xdf9bd18 URL:https://svcs.sandbox.paypal.com/AdaptivePayments/Preapproval>, :request=>"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<PreapprovalRequest>\n <requestEnvelope>\n <detailLevel>ReturnAll</detailLevel>\n <errorLanguage>en_US</errorLanguage>\n <senderEmail>email</senderEmail>\n </requestEnvelope>\n <endingDate>2012-07-20T19:09:20</endingDate>\n <startingDate>2012-07-20T19:09:20</startingDate>\n <maxTotalAmountOfAllPayments>20</maxTotalAmountOfAllPayments>\n <maxNumberOfPayments>2</maxNumberOfPayments>\n <currencyCode>USD</currencyCode>\n <cancelUrl>http://localhost:3000/en/u/maserranocaceres/orders</cancelUrl>\n <returnUrl>http://localhost:3000/en/u/maserranocaceres/orders</returnUrl>\n</PreapprovalRequest>\n", :response=>"\"responseEnvelope\":\"timestamp\":\"2012-07-20T10:09:22.459-07:00\",\"ack\":\"Success\",\"correlationId\":\"ada6a3e7da93d\",\"build\":\"DEV\",\"preapprovalKey\":\"PA-8K9332086D720151L\""
完整回复:
#<ActiveMerchant::Billing::AdaptivePaymentResponse:0xc817278 @json="\"responseEnvelope\":\"timestamp\":\"2012-07-23T07:43:56.603-07:00\",\"ack\":\"Success\",\"correlationId\":\"7f759c5da73ad\",\"build\":\"DEV\",\"preapprovalKey\":\"PA-1M101813XU7801314\"", @response=#<Hashie::Rash preapproval_key="PA-1M101813XU7801314" response_envelope=#<Hashie::Rash ack="Success" build="DEV" correlation_id="7f759c5da73ad" timestamp="2012-07-23T07:43:56.603-07:00">>, @xml_request="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<PreapprovalRequest>\n <requestEnvelope>\n <detailLevel>ReturnAll</detailLevel>\n <errorLanguage>en_US</errorLanguage>\n <senderEmail>microf_1342709161_per@gmail.com</senderEmail>\n </requestEnvelope>\n <endingDate>2012-08-22T16:43:54</endingDate>\n <startingDate>2012-07-23T16:43:54</startingDate>\n <maxTotalAmountOfAllPayments>20</maxTotalAmountOfAllPayments>\n <maxNumberOfPayments>1</maxNumberOfPayments>\n <currencyCode>USD</currencyCode>\n <cancelUrl>http://localhost:3000/en/u/maserranocaceres/orders</cancelUrl>\n <returnUrl>http://localhost:3000/en/u/maserranocaceres/orders</returnUrl>\n</PreapprovalRequest>\n", @request="PreapprovalRequest"=>"requestEnvelope"=>"detailLevel"=>"ReturnAll", "errorLanguage"=>"en_US", "senderEmail"=>"email", "endingDate"=>"2012-08-22T16:43:54", "startingDate"=>"2012-07-23T16:43:54", "maxTotalAmountOfAllPayments"=>"20", "maxNumberOfPayments"=>"1", "currencyCode"=>"USD", "cancelUrl"=>"http://localhost:3000/en/u/maserranocaceres/orders", "returnUrl"=>"http://localhost:3000/en/u/maserranocaceres/orders", @action="Preapproval">
我做错了什么?
【问题讨论】:
【参考方案1】:问题已解决。
改变
gateway.redirect_url_for(response["preapprovalKey"])
到
gateway.redirect_pre_approval_url_for(response["preapprovalKey"])
正确的方法是redirect_pre_approval_url_for
你可以在这篇文章中看到修复:
preapproved payments with paypal in rails 3.2
非常感谢!
【讨论】:
谢谢! paypal api 文档完全烂透了。以上是关于此交易无效。请返回收件人的网站并重试的主要内容,如果未能解决你的问题,请参考以下文章
支付宝错误。此交易无效。请返回收款人的网站以使用他们的常规结账流程完成您的交易
asp.net网站管理工具遇到错误。请返回上一页并重试。还有母板页ContextPlaceHolder中存在的控件不能用等问
如何解决 Paypal 错误 - 您用于进入 PayPal 系统的链接无效。请查看链接并重试?