Yukon
This Micro Gem encapsulates Express Checkout Paypal API. To experiment with that code, run bin/console
for an interactive prompt. To play with cart object:
require_relative './lib/yukon/cart.rb'
Installation
Add this line to your application's Gemfile:
gem 'yukon'
And then execute:
$ bundle
Or install it yourself as:
$ gem install yukon
Usage
- SetExpressCheckout: Makes a call to the API sending the details of the payment to obtain a token and generate a payment url
- GetExpressCheckout: Redirects the user to the payment url and obtains the authorization
- DoExpressCheckout: Uses the given authorization to make the real payment
Test Credentials
Credentials Test
Once you’ve set up your test accounts and have your API test credentials, you’re ready to make PayPal requests to the Sandbox environment.
The following cURL command makes an Express Checkout call to the Sandbox. Execute the request from the command line by replacing the credential values in the command with those from your Sandbox Business account. You should get success in response to the request:
Request:
curl -s --insecure https://api-3t.sandbox.paypal.com/nvp -d "USER=bparan_1360459336_biz_api1.gmail.com&PWD=1360459362&SIGNATURE=AiPC9BjkCyDFQXbSkoZcgqH3hpacARbNPHYwGcAEv3pAorm.KuIxgJw8&METHOD=SetExpressCheckout&VERSION=98&PAYMENTREQUEST_0_AMT=10&PAYMENTREQUEST_0_CURRENCYCODE=USD&PAYMENTREQUEST_0_PAYMENTACTION=SALE&cancelUrl=http://www.example.com/cancel.html&returnUrl=http://www.example.com/success.html"
Response: TOKEN=EC%2d7E679406DY7307812&TIMESTAMP=2015%2d08%2d16T20%3a54%3a43Z&CORRELATIONID=61233e65728ce&ACK=Success&VERSION=98&BUILD=000000
Use the following sample by replacing
curl -s --insecure https://api-3t.sandbox.paypal.com/nvp -d "USER=bparan_1360459336_biz_api1.gmail.com&PWD=1360459362&SIGNATURE=AiPC9BjkCyDFQXbSkoZcgqH3hpacARbNPHYwGcAEv3pAorm.KuIxgJw8&METHOD=GetExpressCheckoutDetails&VERSION=93&TOKEN=
The response from this call includes the PayerID value, which is needed to capture the payment:
GetExpressCheckoutDetails response:
TOKEN=EC%2d4RX1920730957200V ...
&PAYERID=6B9DKHQRKW4SG ...
Paypal Test Credentials
test: username: jb-us-seller_api1.paypal.com password: WX4WTU3S8MY44S7F signature: AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy app_id: APP-80W284485P519543T http_timeout: 30 mode: sandbox sandbox_email_address: platform.sdk.seller@gmail.com
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run rake test
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://bitbucket.orb/bparanj/yukon.
License
The gem is available as open source under the terms of the MIT License.