This library is meant to interface with PayPal's Adaptive Payment Gateway.
- Payments
- Peapprovals
- Refunds
- Currency conversions
- More soon!
Add the following line to your app Gemfile:
gem "active_paypal_adaptive_payment"
bundle install
See iAuction: An Adaptive Payments Tutorial Featuring Parallel Payments tutorial for more info.
gateway =
ActiveMerchant::Billing::PaypalAdaptivePayment.new(
:login => "acutio_1313133342_biz_api1.gmail.com",
:password => "1255043567",
:signature => "Abg0gYcQlsdkls2HDJkKtA-p6pqhA1k-KTYE0Gcy1diujFio4io5Vqjf",
:appid => "APP-80W284485P519543T" )
gateway.preapprove_payment (
:return_url => "returnURL",
:cancel_url => "cancelURL",
:senderEmail =>"email address of sender",
:start_date => Time.now,
:end_date => Time.now + (60*60*24) * 30,
:currency_code =>"currency code",
:max_amount => "maxTotalAmountOfAllPayments",
:maxNumberOfPayments => "maxNumberOfPayments" )
gateway.cancel_preapproval(:preapproval_key => "preapprovalkey")
def checkout
recipients = [{:email => 'receiver_email',
:amount => some_amount,
:primary => true},
{:email => 'receiver_email',
:amount => recipient_amount,
:primary => false}
]
response = gateway.setup_purchase(
:return_url => url_for(:action => 'action', :only_path => false),
:cancel_url => url_for(:action => 'action', :only_path => false),
:notify_url => url_for(:action => 'notify_action', :only_path => false),
:receiver_list => recipients
)
# for redirecting the customer to the actual paypal site to finish the payment.
redirect_to (gateway.redirect_url_for(response["payKey"]))
end
Set the :primary
flag to false
for each recipient for a split payment.
Maybe also check the tests for a sample implementation.
First modify the values in test/fixtures.yml
to fit your app credentials.
After that you can just execute them via autotest
.
Use either gateway.debug or response.debug this gives you the json response, the xml sent and the url it was posted to.
From the Rails console it can be accessed like such:
ActiveMerchant::Billing::PaypalAdaptivePayment
PaypalAdaptivePayment#debug
or AdaptivePaymentResponse#debug
return the raw
xml request, raw json response and the URL of the endpoint.
- Documentation
- More tests
- Jose Pablo Barrantes (http://jpablobr.com/)
- Zarne Dravitzki (http://github.com/zarno)
- LeviRosol (https://github.com/LeviRosol)
- Florian95 (https://github.com/Florian95)
- Adaptive Payment Fee Calculation Analysis
- ActiveMerchant paypaladaptive payments gateway
- Trying to use with Paypal adaptive payments
- adpative payments (chained)
- Testing with a sandbox account without being logged on developer.paypal.com
- Split a transaction to distribute funds to two accounts?
- Fork the project.
- Make your feature addition or bug fix.
- Send me a pull request. Bonus points for topic branches.
(The MIT License)
Copyright 2011 Jose Pablo Barrantes. MIT Licence, so go for it.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, an d/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.