Question

I'm trying to use the PayPal Adaptive Payments Payment API. I am trying to test the API with my own email address, but I get an error specifying the sender by email. I'm wondering how to determine my own account ID to try that way?

I'm referring to the account id here: https://developer.paypal.com/docs/classic/api/adaptive-payments/PaymentDetails_API_Operation/

I get the error: "The email address smithd98@gmail.com is invalid. It may not be registered in PayPal's system yet" when trying to pay by my email. When I log in with PayPal my email address is correct. My account is verified with a bank account, credit card, and debit card connected.

Here is my code:

require 'paypal-sdk-adaptivepayments' 

PayPal::SDK.configure(
  :mode      => "sandbox",  # Set "live" for production
  :app_id    => "HIDDEN",
  :username  => "HIDDEN",
  :password  => "HIDDEN",
  :signature => "HIDDEN" )

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

# Build request object
@pay = @api.build_pay({
  :actionType => "PAY",
  :cancelUrl => "http://localhost:3000/samples/adaptive_payments/pay",
  :currencyCode => "USD",
  :feesPayer => "SENDER",
  :ipnNotificationUrl => "http://localhost:3000/samples/adaptive_payments/ipn_notify",
  :receiverList => {
    :receiver => [{
      :amount => 1.0,
      :email => "smithd98@gmail.com" }] },
  :returnUrl => "http://localhost:3000/samples/adaptive_payments/pay" })

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

# Access response
if @response.success?
    puts 'responsepayKey'
  @response.payKey
  puts 'url to complete payment'
  @api.payment_url(@response)  # Url to complete payment
else
  puts 'error'
  puts @response.error[0].message
  puts @response.error[1].parameter.value
end
Was it helpful?

Solution

You can get it via the API using GetPalDetails. You can get it manually in your PayPal profile. Go to the Business Info section and you'll see a Merchant Account ID.

On another note, I see that you're using localhost in your return and cancel URL's, as well as IPN. This isn't going to work. Remember, it's PayPal's server that will be hitting that address. If they hit localhost, they're just hitting their own server, which isn't going to do what you want, of course.

If you want to test all of this with your local test server you'll need to use your IP address or setup some DNS and a domain of some sort. I personally like to follow PayPal's lead and setup a sandbox.domain.com as a test server for any site I'm working on.

OTHER TIPS

David,

To get the Account ID of your test accounts.

  1. Login into your sandbox paypal account at https://www.sandbox.paypal.com/
  2. Click on the "Profile" tab on the top menu
  3. You will see your Account ID for that account beside "Merchant account ID"

It's the same exact process for a real account but instead login into your real paypal account.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top