Customizing Paypal Express's Review Page using ActiveMerchant

后端 未结 4 1413
遥遥无期
遥遥无期 2021-02-09 18:16

I am using ActiveMerchant to give my rails app access to Paypal\'s Express Checkout. I would like to include the Order Details on the Review Page as described here: https://cms.

4条回答
  •  太阳男子
    2021-02-09 19:04

    I also had problems to get this to work. The solution is that the sum of the amount of all items must be the subtotal of the order, where the subtotal, shipping, handling and tax must sum up to the total value of the order. My paypal controller looks like this:

    def begin_paypal
      # ...
      options = express_options(@order)
      # ... 
      response = EXPRESS_GATEWAY.setup_purchase(@order.gross_price_in_cent, options)
      redirect_to EXPRESS_GATEWAY.redirect_url_for(response.token)
    end
    
    private
    def express_options order
      options = {}
      options[:ip] = request.remote_ip
      options[:order_id] = order.bearbeitungsnummer
    
      # subtotal, shipping, handling and tax must sum up to the orders total value
      # subtotal must be the sum of all amounts of all items
      options[:subtotal] = order.gross_price_in_cent
      options[:shipping] = 0
      options[:handling] = 0
      options[:tax] = 0
    
      options[:items] = order.line_items.map do |line_item|
        {
          :name => line_item.product.name,
          :number => line_item.product.kcode,
          :quantity => line_item.quantity,
          :description => line_item.product.beschreibung,
          :amount => line_item.gross_price_in_cent,
          :url => nil
        }
      end
      # ...
    end
    

    Works fine

提交回复
热议问题