jeudi 10 novembre 2016

rails paypal adaptive 302 redirect

i'm implementing the paypal adaptive sdk for rails https://github.com/paypal/adaptivepayments-sdk-ruby

but, after create the action buy on order controller i'm getting the 302 redirect, someone have any ideia or any tip to give.

at first i thought that is a session problem, but, after change and use permanent cookie still the same, later i thought that was the nginx with pagespeed or the passenger, or maybe is the rails verion 3.2.22?

controller:

def buy
order = Order.find(params[:id])
    store_amount = (order.total_price * configatron.store_fee).round(2)
    seller_amount = (order.total_price - store_amount) + order.shipping_cost

   @api = PayPal::SDK::AdaptivePayments.new
      @pay = @api.build_pay({
        :actionType => "PAY",
        :cancelUrl => carts_url,
        :currencyCode => "US",
        :feesPayer => "SENDER",
        :ipnNotificationUrl => ipn_notification_order_url(order),

        :receiverList => {
          :receiver => [{
            :email =>  order.product.shop.paypal,
            :amount => seller_amount,
            :primary => true},
            {:email => configatron.paypal.merchant,
             :amount => store_amount,     
             :primary => false}]},
             :returnUrl => carts_url })
 begin
             @response = @api.pay(@pay)

             # Access response
             if @response.success? && @response.payment_exec_status != "ERROR"
               @response.payKey
              redirect_to  @api.payment_url(@response)  # Url to complete payment
             else
               @response.error[0].message
               redirect_to fail_order_path(order)

             end
  end
 end

the result

URL
http://41.67.229.88/orders/1/buy
Status
Complete
Response Code
302 Moved Temporarily
Protocol
HTTP/1.1
SSL
-
Method
GET
Kept Alive
Yes
Content-Type
text/html; charset=utf-8
Client Address
/127.0.0.1
Remote Address
41.67.229.88/41.67.229.88
Connection

Timing

Request Start Time
11/9/16 18:40:11
Request End Time
11/9/16 18:40:11
Response Start Time
11/9/16 18:40:12
Response End Time
11/9/16 18:40:12
Duration
939 ms
DNS
-
Connect
-
SSL Handshake
-
Request
2 ms
Response
6 ms
Latency
930 ms
Speed
2.28 KB/s
Response Speed
357.26 KB/s
Size

Request
1.38 KB (1,417 bytes)
Header
1.38 KB (1,417 bytes)
Query String
-
Cookies
1,000 bytes
Body
-
Uncompressed Body
-
Compression
-
Response
778 bytes
Header
663 bytes
Cookies
-
Body
115 bytes
Uncompressed Body
-
Compression
-
Total
2.14 KB (2,195 bytes)

Aucun commentaire:

Enregistrer un commentaire