首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在paypal支付屏幕中显示商品价格、商品id、商品名称

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

Stack Overflow用户
提问于 2013-10-11 18:42:46
回答 1查看 408关注 0票数 1

我已经使用了gem "active_paypal_adaptive_payment"也设置了付款选项

代码语言:javascript
复制
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付款页面。这是页面

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

有没有人能建议如何配置它。请帮帮忙

谢谢

EN

回答 1

Stack Overflow用户

发布于 2013-10-11 18:57:59

你可能想尝试使用"“gem --它是由Shofify更新的,我们提供了它来做你想做的事情。

Problem

让PayPal列出商品的方法是使用ExpressCheckout version (我认为您只是设置了一个点对点支付),然后在散列数组中传递商品。我们用的是手推车,不过你也可以用别的。

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

解决方案

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

路由

代码语言:javascript
复制
#config/routes.rb
get 'checkout/paypal' => 'orders#paypal_express', :as => 'checkout'
get 'checkout/paypal/go' => 'orders#create_payment', :as => 'go_paypal'

订单控制器

代码语言:javascript
复制
#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

生成项

代码语言:javascript
复制
#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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19316221

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档