GithubHelp home page GithubHelp logo

rpmilevskiy / adaptivepayments-sdk-ruby Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mikepence/adaptivepayments-sdk-ruby

0.0 2.0 0.0 437 KB

Adaptive Payment SDK for RUBY

License: Other

Ruby 82.88% JavaScript 0.52% CSS 1.32% HTML 15.27%

adaptivepayments-sdk-ruby's Introduction

Adaptive Payments SDK

The PayPal Adaptive Payments SDK provides Ruby APIs to create, process and manage simple and complex (parallel and chained) payments, and pre-approvals using the Adaptive Payments API.

Installation

Add this line to your application's Gemfile:

gem 'paypal-sdk-adaptivepayments'

And then execute:

$ bundle

Or install it yourself as:

$ gem install paypal-sdk-adaptivepayments

Configuration

For Rails application:

rails g paypal:sdk:install

For other ruby application, create a configuration file(config/paypal.yml):

development: &default
  username: jb-us-seller_api1.paypal.com
  password: WX4WTU3S8MY44S7F
  signature: AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy
  app_id: APP-80W284485P519543T
  http_timeout: 30
  mode: sandbox
  sandbox_email_address: [email protected]
  # # with certificate
  # cert_path: "config/cert_key.pem"
  # # with token authentication
  # token: ESTy2hio5WJQo1iixkH29I53RJxaS0Gvno1A6.YQXZgktxbY4I2Tdg
  # token_secret: ZKPhUYuwJwYsfWdzorozWO2U9pI
  # # with Proxy
  # http_proxy: http://proxy-ipaddress:3129/
  # # with device ip address
  # device_ipaddress: "127.0.0.1"
test:
  <<: *default
production:
  mode: live
  username: USERNAME
  password: PASSWORD
  signature: SIGNATURE
  app_id: APP_ID

Load Configurations from specified file:

PayPal::SDK.load('config/paypal.yml',  ENV['RACK_ENV'] || 'development')

Or without configuration file:

PayPal::SDK.configure(
  :mode      => "sandbox",  # Set "live" for production
  :app_id    => "APP-80W284485P519543T",
  :username  => "jb-us-seller_api1.paypal.com",
  :password  => "WX4WTU3S8MY44S7F",
  :signature => "AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy" )

Example

require 'paypal-sdk-adaptivepayments'
PayPal::SDK.configure(
  :mode      => "sandbox",  # Set "live" for production
  :app_id    => "APP-80W284485P519543T",
  :username  => "jb-us-seller_api1.paypal.com",
  :password  => "WX4WTU3S8MY44S7F",
  :signature => "AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy" )

@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 => "[email protected]" }] },
  :returnUrl => "http://localhost:3000/samples/adaptive_payments/pay" })

# Make API call & get response
@response = @api.pay(@pay)

# Access response
if @response.success? && @response.payment_exec_status != "ERROR"
  @response.payKey
  @api.payment_url(@response)  # Url to complete payment
else
  @response.error[0].message
end

For more samples https://paypal-sdk-samples.herokuapp.com/adaptive_payments/

Samples App

Add following line in rails Gemfile:

gem 'paypal-sdk-adaptivepayments'
gem 'adaptive_payments_samples', :git => "https://github.com/paypal/adaptivepayments-sdk-ruby.git", :group => :development

Configure routes(config/routes.rb):

mount AdaptivePaymentsSamples::Engine => "/samples" if Rails.env.development?

To get default paypal configuration execute:

rails g paypal:sdk:install

Run rails server and check the samples.

adaptivepayments-sdk-ruby's People

Contributors

siddick avatar lvairamani avatar avidas avatar prannamalai avatar buntyjoshi avatar juwlee avatar phillbaker avatar

Watchers

Ruslan Milevskiy avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.