I'm using the paypal-sdk-merchant gem. So far I have set one merchant account with this command:
PayPal::SDK.configure(
:mode => "sandbox",
:app_id => "APP-sdfgjkl",
:username => "lprieto-facilitator_api1.hasu.cl",
:password => "Z7XGVDCHBJN",
:signature => "AFcWxV21C7fd0v3bYYYRCpSSRlXDCFVGBHLBRTnmAzXxHddoa5e",
:sandbox_email_address => "lprieto-facilitator_api1.hasu.cl")
and then create a payment with
api = PayPal::SDK::Merchant::API.new
This have work perfectly so far but now I have to change the paypal account according to the country the person is buying from. If I'm constantly changing the PayPal::SDK.configure will there be any consistence problems??
For example, if a person in Brasil access and the configuration is change. Then a person in Chile access and the configuration is change. After, the brasilian pays. Will it have the brasilian configuration or the chilean one?
What would you recommend for having multiple Paypal accounts in a ruby on rails app?
Thank you in advance.
I recommend taking a look at https://github.com/paypal/PayPal-Ruby-SDK because this gem doesn't support rails 4 and will be deprecated.
As for your problem at hand: Seeing the API, you would indeed need to call PayPal::SDK.configure()
for each different type of merchant/country. You can create a YML config file for this something like config/paypal.yml
:
chile:
mode: sandbox
app_id: APP-123
username: user1
password: pass1
signature: ABCDEF
sandbox_email_address: test@example.com
brasil:
mode: sandbox
app_id: APP-456
username: user2
password: pass2
signature: GHIJKL
sandbox_email_address: test2@example.com
and use this in your app like:
@api_chile = PayPal::SDK::Merchant::API.new(:chile)
@api_brasil = PayPal::SDK::Merchant::API.new(:brasil)
Hope this helps!