Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 在paypal支付屏幕中显示商品价格、商品id、商品名称_Ruby On Rails_Ruby_Paypal Adaptive Payments - Fatal编程技术网

Ruby on rails 在paypal支付屏幕中显示商品价格、商品id、商品名称

Ruby on rails 在paypal支付屏幕中显示商品价格、商品id、商品名称,ruby-on-rails,ruby,paypal-adaptive-payments,Ruby On Rails,Ruby,Paypal Adaptive Payments,我使用了gem“active\u paypal\u adaptive\u payment”也设置了付款选项 def checkout recipients = [recipientarray] response = gateway.setup_purchase( :return_url => url_for(:action => 'action', :only_path => false), :cancel_url => url_for(:acti

我使用了
gem“active\u paypal\u adaptive\u 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
它正在重定向到paypal支付页面。。 这是页面

在付款汇总表中,它不显示任何项目名称、价格等

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


谢谢

您可能想尝试使用“”gem代替-它由Shofiy更新,我们可以让它完全满足您的需求

问题

让PayPal列出项目的方法是使用(我认为您只是在设置点对点支付),然后以哈希数组传递项目。我们用手推车,但你可能有别的东西

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


解决方案

我只能为ActiveMerchant担保,因为这是我仅有的代码,但我们要做的是:

路线

#config/routes.rb
get 'checkout/paypal' => 'orders#paypal_express', :as => 'checkout'
get 'checkout/paypal/go' => 'orders#create_payment', :as => 'go_paypal'
#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
订单控制器

#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
#控制器/orders_controller.rb
类OrdersController<应用程序控制器
#贝宝快捷
def贝宝快递
响应=EXPRESS\u GATEWAY.安装\u购买(总计,
:items=>cart_session.build_order,#这是创建项目哈希的地方
:小计=>小计,
:装运=>50,
:处理=>0,
:tax=>0,
:return\u url=>url\u for(:action=>create\u payment'),
:cancel\u return\u url=>url\u for(:controller=>'cart',:action=>'index')
)
重定向到EXPRESS\u网关。重定向(response.token)的\u url\u
终止
#这里还有其他东西。。。。
终止
生成项目

#config/routes.rb
get 'checkout/paypal' => 'orders#paypal_express', :as => 'checkout'
get 'checkout/paypal/go' => 'orders#create_payment', :as => 'go_paypal'
#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
#models/cart_session.rb(我们将其用于购物车)
#为ActiveMerchant构建哈希
def生成顺序
#获取购物车对象并将其添加到项目哈希
产品=购物车内容
@订单=[]
产品。每个do |产品|

@订单是否有任何选项直接发送付款到收件人贝宝电子邮件?因此,我必须使用adaptive gem。通过paypal电子邮件,您是指“非商业”帐户吗?客户只能通过注册电子邮件将金额发送到paypal帐户。。假设我是一个客户,我想买一个广告,卖家正在添加一封paypal电子邮件以转发购买金额。。因此,每当客户购买任何广告时,它都会直接重定向到paypal并支付..收件人=[recipientarray]。。做同样的事情,通过电子邮件发送paypl帐户,并将金额拆分到这些帐户。。