1

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

我不想收集用户的地址,我只想确保如果我向该电子邮件地址付款,它不会失败。我需要能够独立于任何交易来做到这一点。我今天需要知道我要在三周内发送交易的电子邮件是一个有效的贝宝帐户。

那可能吗?

4

2 回答 2

0

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

我最终基于以下事实编写了一个解决方案:当有效的电子邮件被用作交易的发件人和收件人时,自适应支付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
于 2014-04-06T20:50:02.517 回答
0

看看 PayPal API 的GetVerifiedStatus函数。那应该做你需要的。

于 2013-08-01T21:31:19.300 回答