Ruby on rails ActiveMerchant';s支持确定PayPal Express结账客户/买家的帐户状态(已验证/未验证)

Ruby on rails ActiveMerchant';s支持确定PayPal Express结账客户/买家的帐户状态(已验证/未验证),ruby-on-rails,paypal,activemerchant,Ruby On Rails,Paypal,Activemerchant,我目前正在开发一个Ruby on Rails web应用程序,它通过PayPal的Express Checkout和ActiveMerchant接受PayPal支付。我已经做了几项关于ActiveMerchant对确定客户/买家是否使用经验证或未经验证的PayPal帐户付款的支持的研究,但我没有幸运地找到有用的指南 我还发现ActiveMerchant目前还没有很好的文档记录,所以根本没有什么帮助 下面是我的项目当前使用的相关代码。在PaymentsController购买中,我临时使用了EXP

我目前正在开发一个Ruby on Rails web应用程序,它通过PayPal的Express Checkout和ActiveMerchant接受PayPal支付。我已经做了几项关于ActiveMerchant对确定客户/买家是否使用经验证或未经验证的PayPal帐户付款的支持的研究,但我没有幸运地找到有用的指南

我还发现ActiveMerchant目前还没有很好的文档记录,所以根本没有什么帮助

下面是我的项目当前使用的相关代码。在PaymentsController购买中,我临时使用了EXPRESS\u GATEWAY.purchase方法调用返回的
ActiveMerchant::Billing::PaypalExpressResponse
对象的
#params['protection\u Qualification']
#params['protection\u Qualification\u type']
方法,评估PayPal客户/买家是否拥有已验证/未验证的PayPal帐户。后来我发现这不是了解客户帐户状态的可靠依据

我希望有人能给我一个智慧,让我知道PayPal客户/买家是否有一个使用Ruby on Rails的ActiveMerchant或使用Rails上的其他替代品验证/未验证的帐户

#config/environments/development.rb
config.after\u初始化do
ActiveMerchant::Billing::Base.mode=:测试
paypal_选项={
#已删除此StackOverflow问题的凭据
:login=>“”,
:password=>“”,
:签名=>“”
}
::EXPRESS\u GATEWAY=ActiveMerchant::Billing::PaypalExpressGateway.new(paypal\u选项)
结束
#app/models/payment.rb
类付款  75_00,
4  => 200_00,
12 => 550_00
}
状态=[“待定”、“完成”、“失败”]
类型=[“paypal”、“paypal已验证”、“paypal未验证”、“电汇”、“信用卡”]
# ...
结束
#app/controllers/payments\u controller.rb
类PaymentsController<应用程序控制器
# ...
def校验
会话[:信用卡数量]=参数[:信用卡数量].至
总金额=付款::贝宝信用卡到价格[会话[:信用卡数量]]
设置\采购\参数={
:allow_guest_checkout=>true,
:ip=>request.remote\u ip,
:return\u url=>url\u for(:action=>purchase',:only\u path=>false),
:cancel_return_url=>url_for(:controller=>'payments',:action=>'new',:only_path=>false),
:项目=>[{
:name=>pluralize(会话[:学分\数量],“学分”),
:number=>1,
:数量=>1,
:amount=>Payment::PAYPAL_CREDIT_TO_PRICE[会话[:credits_qty]]
}]
}
setup\u response=EXPRESS\u GATEWAY.setup\u purchase(总金额,setup\u purchase参数)
重定向\u到EXPRESS\u网关。重定向\u url\u用于(setup\u response.token)
结束
def购买
如果参数[:标记].nil?或参数[:payrid].nil?
重定向到新的支付url:notice=>I18n.t('flash.payment.paypal.error'))
返回
结束
总金额=付款::贝宝信用卡到价格[会话[:信用卡数量]]
采购参数={
:ip=>request.remote\u ip,
:token=>params[:token],
:payer_id=>params[:PayerID],
:项目=>[{
:name=>pluralize(会话[:学分\数量],“学分”),
:number=>1,
:数量=>1,
:amount=>Payment::PAYPAL_CREDIT_TO_PRICE[会话[:credits_qty]]
}]
}
purchase=EXPRESS\u GATEWAY.purchase total\u as\u cents,purchase\u params
如果你成功了?
payment=当前用户。payments.new
payment.paypal_params=参数
payment.credits=会话[:credits\u数量]
payment.amount=付款::PAYPAL\u信用卡\u到价格[会话[:信用卡\u数量]]
payment.currency=“USD”
payment.status=“完成”
if(purchase.params[“receipt\u id”]&(purchase.params[“success\u page\u redirect\u requested”]=“true”))
payment.payment\u type=“信用卡”
其他的
如果purchase.params['protection\u qualification']=='qualified'&&purchase.params['protection\u qualification\u type']=='ItemNotReceivedEligible,UnauthorizedPaymentqualified'
payment.payment\u type='paypal-verified'
其他的
payment.payment\u type='paypal unverified'
结束
结束
payment.ip_address=request.remote_ip.to_
付款,省钱!
网站邮箱。贝宝支付(支付)。交付
SiteMailer.通知付款(付款)。交付
notice=I18n.t('flash.payment.status.Thank'))
将\重定向到配置文件\ url,:notice=>notice
其他的
notice=I18n.t('flash.payment.status.failed',:message=>purchase.message)
重定向到新的支付url:notice=>notice
结束
结束
# ...
结束

我不熟悉ActiveMerchant,因此我无法具体告诉您,但通过任何快速结帐实现,您都可以用来获取付款人信息,其中包括一个PAYERSTATUS参数,该参数的值为“已验证”或“未验证”

这是一个可选调用,但我假设ActiveMerchant可能包含它,所以您只需要跟踪它并相应地提取该参数


或者,您可以使用接收交易信息,并在此处返回payer_状态参数

我对ActiveMerchant不太熟悉,因此我无法具体告诉您,但对于任何快速结帐实现,您都可以使用它来获取付款人信息,其中包括一个值为“已验证”或“未验证”的PAYERSTATUS参数

这是一个可选调用,但我假设ActiveMerchant可能包含它,所以您只需要跟踪它并相应地提取该参数

或者,您可以使用
def self.get_paypal_payer_status(transaction_id)
  require 'paypal-sdk-merchant'
  api = PayPal::SDK::Merchant::API.new

  get_transaction_details = api.build_get_transaction_details({
    :Version => "94.0",
    :TransactionID => transaction_id
  })
  get_transaction_details_response = api.get_transaction_details(get_transaction_details)

  get_transaction_details_response.payment_transaction_details.payer_info.payer_status
end