验证电子邮件地址是PayPal用户

时间:2012-04-12 17:50:16

标签: ruby-on-rails ruby paypal

我想验证电子邮件地址是PayPal用户。 是否有API调用来执行此操作?

是否有一个ruby lib来做到这一点?

谢谢

2 个答案:

答案 0 :(得分:7)

来自GetVerifiedStatus平台的

PayPal's Adaptive Accounts将为您完成此操作。

PayPal在Ruby中没有任何code samplesSDKs自适应帐户,但我确实找到了编写code for GetVerifiedStatus in Ruby的人。

对该代码进行的唯一更改是您需要检查它们所拥有的帐户类型才能更改

if @xml['accountStatus']!=nil
    account_status = @xml['accountStatus'][0]
    #its pretty obvious from here init?
    if account_status.to_s() == "VERIFIED"
        render :text => "Account verified"
    else
        render :text => "Oopsy! Yet to be verified"
    end
else
    render :text => "Gee! sorry! something went seriously wrong"
end

if @xml['accountType']!=nil
    account_type = @xml['accountType'][0]
    #its pretty obvious from here init?
    if account_type.to_s() == "Business"
        render :text => "Business account!"
    elseif account_type.to_s() == "Premier"
        render :text => "Premier Account!"
    elseif account_type.to_s() == "Personal"
        render :text => "Personal account!"
    else
        render :text => "Account type not null but not a valid PayPal account type."
    end
else
    render :text => "Gee! sorry! something went seriously wrong"
end

注意:PayPal显然尚未更新其API参考页,因此请暂时使用Adaptive Accounts guide中第65-66页中包含的信息。

答案 1 :(得分:4)

查看adaptiveaccounts-sdk-ruby gem。它允许您获取有关paypal帐户的信息。

看看the sample apps,了解api可以做些什么。

以下是一个例子:

require 'paypal-sdk-adaptiveaccounts'
@api = PayPal::SDK::AdaptiveAccounts::API.new( :device_ipaddress => "127.0.0.1" )

# Build request object
@get_verified_status = @api.build_get_verified_status({
  :emailAddress => "newEmailAddress@paypal.com",
  :matchCriteria => "NONE" })

# Make API call & get response
@get_verified_status_response = @api.get_verified_status(@get_verified_status)

# Access Response
if @get_verified_status_response.success?
  @get_verified_status_response.accountStatus
  @get_verified_status_response.countryCode
  @get_verified_status_response.userInfo
else
  @get_verified_status_response.error
end

here是paypal的自适应帐户官方文档