仅验证PayPal电子邮件

时间:2013-08-01 21:26:36

标签: php paypal

我知道paypal API上有addressverify操作,但文档说这也是发送用户的地址和邮政编码以及电子邮件的要求。

我不想收集用户的地址,我只想确保如果我付款到该电子邮件地址就不会失败。我需要能够独立完成任何交易。我今天需要知道,我将在三周内发送交易的电子邮件是一个有效的PayPal帐户。

可能吗?

2 个答案:

答案 0 :(得分:0)

查看PayPal API的GetVerifiedStatus功能。这应该做你需要的。

答案 1 :(得分:0)

我的第一次尝试是自适应支付api GetUserLimits,但它对我不起作用。我理解它是一个受限制的API。

我最终在一起解决了一个问题,因为当有效的电子邮件被用作交易的发件人和收件人时,adaptive payments api会抛出错误。我查找此案例以测试电子邮件是否有效。 (这是红宝石代码)

 def getApi()
  PayPal::SDK.configure(
  :mode      => "sandbox",  # Set "live" for production
  :app_id    => "yourAppId",
  :username  => "yourUsername",
  :password  => "yourPassword",
  :signature => "yourSignature" )

  api = PayPal::SDK::AdaptivePayments.new
 end

 def pay(senderEmail, receiverEmail, amount, trackingId)
  @api = getApi

  # Build request object
  @pay = @api.build_pay({
    :actionType => "PAY",
    :cancelUrl =>  "https://yourwebsite.com/cancel/" + trackingId,
    :currencyCode => "USD",
    :feesPayer => "SENDER",
    :ipnNotificationUrl => "https://yourwebsite.com/ipn_notify/" + trackingId,
    :receiverList => {
      :receiver => [{
        :amount => amount,      :email => receiverEmail }] },
    :returnUrl =>  http://www.yourwebsite.com/completed/" + trackingId})

  @pay.sender.email = senderEmail
  #@pay.sender.accountId = 23434
  # Make API call & get response
  puts @pay.inspect
  @response = @api.pay(@pay)

  if @response.success?
    @response.payKey
    completeUrl = @api.payment_url(@response)
    return {url: completeUrl, payKey: @response.payKey}
  else
    raise AccountException.new(@response.error[0])
  end
 end

 def isValidAccount(email)
  begin
    result = pay(email, email, 1.0)
  rescue AccountException
    puts 'in rescue'
    senderAndReceiverCantbeTheSameErrorCode = 579033
    if $!.innerError.errorId == senderAndReceiverCantbeTheSameErrorCode
      return true
    end
  end
  return false
 end