私の最初の試みは、アダプティブ ペイメント 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