0

我把這個信息給PayPal使用預先批准的支付功能與貝寶的預覈准付款軌3.2

response = gateway.preapprove_payment( 
    :return_url => user_orders_url(current_user), 
    :cancel_url => user_orders_url(current_user), 
    :requestEnvelope => {"errorLanguage" => "en_US"}, 
    :start_date => Time.now, 
    :end_date => Time.now + (60*60*24) * 30, 
    :currency_code =>"USD", 
    :senderEmail =>"email address of sender", 
    :max_amount => "20.00", 
    :maxNumberOfPayments => "1", 
    :notify_url => ipn_notification_user_orders_url(current_user), 
) 
redirect_to (gateway.redirect_url_for(response["preapprovalKey"])) 
p response 

我得到了貝寶頁面的消息:

This transaction is invalid. Please return to the recipient's website and try again. 

我現在用的是方法build_preapproval_payment來自這顆寶石https://github.com/jpablobr/active_paypal_adaptive_payment/blob/master/lib/active_merchant/billing/gateways/paypal_adaptive_payment.rb

這是我的日誌控制檯的輸出:

#<ActiveMerchant::Billing::AdaptivePaymentResponse:0xb7c6838 @json="{\"responseEnvelope\":{\"timestamp\":\"2012-07-23T09:32:42.631-07:00\",\"ack\":\"Success\",\"correlationId\":\"0c4df4aefe651\",\"build\":\"DEV\"},\"preapprovalKey\":\"PA-8D4362235H161382C\"}", @response=#<Hashie::Rash preapproval_key="PA-8D4362235H161382C" response_envelope=#<Hashie::Rash ack="Success" build="DEV" correlation_id="0c4df4aefe651" timestamp="2012-07-23T09:32:42.631-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>sender_email</senderEmail>\n </requestEnvelope>\n <endingDate>2012-08-22T18:32:40</endingDate>\n <startingDate>2012-07-23T18:32:40</startingDate>\n <maxTotalAmountOfAllPayments>20.00</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 <ipnNotificationUrl>http://localhost:3000/en/u/maserranocaceres/orders/ipn_notification</ipnNotificationUrl>\n</PreapprovalRequest>\n", @request={"PreapprovalRequest"=>{"requestEnvelope"=>{"detailLevel"=>"ReturnAll", "errorLanguage"=>"en_US", "senderEmail"=>"[email protected]"}, "endingDate"=>"2012-08-22T18:32:40", "startingDate"=>"2012-07-23T18:32:40", "maxTotalAmountOfAllPayments"=>"20.00", "maxNumberOfPayments"=>"1", "currencyCode"=>"USD", "cancelUrl"=>"http://localhost:3000/en/u/maserranocaceres/orders", "returnUrl"=>"http://localhost:3000/en/u/maserranocaceres/orders", "ipnNotificationUrl"=>"http://localhost:3000/en/u/maserranocaceres/orders/ipn_notification"}}, @action="Preapproval"> 

我在哪裏出錯?

謝謝!

回答