本文介绍了使用 ActiveMerchant 自定义 Paypal Express 的评论页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 ActiveMerchant 让我的 rails 应用程序访问 Paypal 的 Express Checkout.我想在评论页面上包含订单详细信息,如下所述:https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECCustomizing

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.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECCustomizing

这能做到吗?

目前,我的控制器代码如下所示:

Currently, my controller code looks like this:

def paypal
  #currently, options is unused, I'm not sure where to send this info
  options = {
              :L_NAME0=>"Tickets",
              :L_QTY0=>@payment.quantity,
              :L_DESC0=>"Tickets for #{@payment.event_name}",
              :L_AMT0=>@payment.unit_price
            }

  #the actual code that gets used
  setup_response = gateway.setup_purchase(@payment.amount,
    :ip=> request.remote_ip,
    :return_url=> url_for(:action=>:confirm, :id=>@payment.id, :only_path=>false),
    :cancel_return_url => url_for(:action=>:show, :id=>@payment.id, :only_path=>false)
  )
  redirect_to gateway.redirect_url_for(setup_response.token)
end

如果我想做的事情是可能的,我需要改变什么?

If what I'm trying to do is possible, what do I need to change?

推荐答案

@Soleone我尝试了您的解决方案,但对我不起作用.

@SoleoneI try your solution,but don't work for me.

xml.tag! 'n2:OrderDescription', options[:description]
xml.tag! 'n2:Name', options[:name]
xml.tag! 'n2:Description', options[:desc]
xml.tag! 'n2:Amount', options[:amount]
xml.tag! 'n2:Quantity', options[:quantity]

我觉得xml结构不对,订单项有多个,所以应该这样

I think the xml structure is not right,the order items is multiple,so should like this

xml.tag! 'n2:OrderItems' do
    xml.tag! 'n2:OrderItem' do
        xml.tag! 'n2:Name', options[:name]
        xml.tag! 'n2:Description', options[:desc]
        xml.tag! 'n2:Amount', options[:amount]
        xml.tag! 'n2:Quantity', options[:quantity]
    end
end

但我真的不知道正确的结构,现在寻找.

But really I don't know the correct structure,looking for now.

====更新

我找到了 SOAP api 文档,https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_soap_r_SetExpressCheckout#id09BHC0QF07Q

I found the SOAP api doc, https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_soap_r_SetExpressCheckout#id09BHC0QF07Q

xml.tag! 'n2:PaymentDetails' do
    xml.tag! 'n2:PaymentDetailsItem' do
        xml.tag! 'n2:Name', options[:name]
        xml.tag! 'n2:Description', options[:desc]
        xml.tag! 'n2:Amount', options[:amount]
        xml.tag! 'n2:Quantity', options[:quantity]
    end
end

但也不起作用,谁能帮忙?

But also doesn't work,who can help?

======更新====

=====UPDATE====

我尝试了添加 PaymentDetails 参数的方法,但似乎还是不行,我找到了 SetExpressCheckoutReq xml 的架构,http://www.visualschema.com/vs/paypal/SetExpressCheckoutReq/ ,PaymentDetails 没有定义,以前谁做过这个东西,希望大家帮忙.

I tried the method of adding PaymentDetails parameter,but seems still not work,I found the schema of SetExpressCheckoutReq xml, http://www.visualschema.com/vs/paypal/SetExpressCheckoutReq/ , there is no definition of PaymentDetails,who did this stuff before,hope for your help.

======最终========

======FINAL========

我已经解决了这个问题,新版ActiveMerchant支持订单详情审核,mwagg也推送了这个补丁,你们可以用这个版本https://github.com/mwagg/active_merchant

I have fixed this issue,new version of ActiveMerchant support the order details review,and mwagg pushed the patch about this,you guys can use this version https://github.com/mwagg/active_merchant

这篇关于使用 ActiveMerchant 自定义 Paypal Express 的评论页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 13:48