lundi 31 octobre 2016

rails paypal adaptive undefined method `[]' for false:FalseClass

Someone is having this issue?

i place the sdk configure on: buy action

and on the log shows:

line 58 is PayPal::SDK.configure

NoMethodError (undefined method []' for false:FalseClass): app/controllers/orders_controller.rb:58:inbuy'

def buy require 'paypal-sdk-adaptivepayments'

PayPal::SDK.configure(
  :mode      => "live",  # Set "live" for production
  :app_id    => "APP-xxxxx",
  :username  => "xxxx.yyyy.com",
  :password  => "xxxx",
  :signature => "xxxxx" )



  @api = PayPal::SDK::AdaptivePayments.new


  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

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

    :receiverList => {
      :receiver => [{
        :email =>  order.product.vitrine.policy.paypal,
        :amount => seller_amount,
        :primary => true},
        {:email => configatron.paypal.merchant,
         :amount => store_amount, 
         :primary => false}]},
         :returnUrl => carts_url })

         @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

Aucun commentaire:

Enregistrer un commentaire