1

我也使用过gem "active_paypal_adaptive_payment"设置付款方式

def checkout
  recipients = [recipientarray]
  response = gateway.setup_purchase(
    :return_url => url_for(:action => 'action', :only_path => false),
    :cancel_url => url_for(:action => 'action', :only_path => false),
    :ipn_notification_url => url_for(:action => 'notify_action', :only_path => false),
    :receiver_list => recipients
  )

  # For redirecting the customer to the actual paypal site to finish the payment.
  redirect_to (gateway.redirect_url_for(response["payKey"]))
end

它正在重定向到贝宝付款页面.. 这是页面在此处输入图像描述

在付款摘要中,它不显示任何项目名称、价格等。

任何人都可以建议如何配置它。请帮忙

谢谢

4

1 回答 1

0

您可能想尝试改用“ ActiveMerchant ” gem - 它由 Shofify 更新,我们已经让它完全满足您的需求。

问题

让 PayPal 列出项目的方法是使用ExpressCheckout 版本(我认为您只是在设置点对点支付),然后在哈希数组中传递项目。我们使用购物车,但您可能有其他东西。

paypal epxress 的诀窍是您必须将所有总数正确加起来。正如您将在我发布的代码中看到的那样,我们现在只是使用静态运费值(我们仍在开发这个当前项目),但如果您不需要它,您可以省略运费。


解决方案

我只能为 ActiveMerchant 担保,因为这是我拥有的唯一代码,但这是我们所做的:

路线

#config/routes.rb
get 'checkout/paypal' => 'orders#paypal_express', :as => 'checkout'
get 'checkout/paypal/go' => 'orders#create_payment', :as => 'go_paypal'

订单控制器

#controllers/orders_controller.rb
class OrdersController < ApplicationController

    #Paypal Express
    def paypal_express
        response = EXPRESS_GATEWAY.setup_purchase(total,
          :items => cart_session.build_order, #this is where you create the hash of items
          :subtotal => subtotal,
          :shipping => 50,
          :handling => 0,
          :tax => 0,
          :return_url => url_for(:action => 'create_payment'),
          :cancel_return_url => url_for(:controller => 'cart', :action => 'index')
        )
        redirect_to EXPRESS_GATEWAY.redirect_url_for(response.token)
    end
#some other stuff is here....
end

建造物品

#models/cart_session.rb (we use this with a cart)
    #Build Hash For ActiveMerchant
    def build_order

        #Take cart objects & add them to items hash
        products = cart_contents

        @order = []
        products.each do |product|
            @order << {name: product[0].name, quantity: product[1]["qty"], amount: (product[0].price * 100).to_i }
        end

        return @order

    end
end
于 2013-10-11T10:57:59.207 回答