GithubHelp home page GithubHelp logo

railsagency / paysimple-ruby Goto Github PK

View Code? Open in Web Editor NEW

This project forked from koss-lebedev/paysimple-ruby

0.0 2.0 0.0 23 KB

Ruby client library for Paysimple API v4.0

License: MIT License

Ruby 99.46% Shell 0.54%

paysimple-ruby's Introduction

Ruby client library for Paysimple API v4.0

Ruby client to interact with PaySimple API. Detailed API documentation can be found here: documentation

Installation

Execute this command:

gem install 'paysimple-ruby'

If you're using Rails, simply add this to your Gemfile :

gem 'paysimple-ruby'

Configuration

Initialize Paysimple client with user id and access token:

require 'paysimple'
Paysimple.api_user = '<your api username>'
Paysimple.api_key = '<your api key>

By default the library will try to connect to the production endpoint. You can customize this behavior by specifying API endpoint explicitly:

Paysimple.api_endpoint = Paysimple::Endpoint::PRODUCTION

or

Paysimple.api_endpoint = Paysimple::Endpoint::SANDBOX

Usage examples

###Customer

# create new customer
customer = Paysimple::Customer.create({ first_name: 'John', last_name: 'Doe' })

# update customer
updated_customer = Paysimple::Customer.update({ id: customer[:id], first_name: 'John', last_name: 'Smith' })

# get customer by ID
customer = Paysimple::Customer.get(customer[:id])

# find customers
customers = Paysimple::Customer.find({ page: 1, page_size: 10, company: 'ABC company' })

# get customer's payments and payment schedules
payments = Paysimple::Customer.payments(customer[:id], { page_size: 5 })
payment_schedules = Paysimple::Customer.payment_schedules(customer[:id], { page_size: 5 })

# delete customer
Paysimple::Customer.delete(customer[:id])

CreditCard

# create credit card
credit_card = Paysimple::CreditCard.create({  
	customer_id: customer[:id],
    credit_card_number: '4111111111111111',
    expiration_date: '12/2021',
    billing_zip_code: '80202',
    issuer: Paysimple::Issuer::VISA,
    is_default: true 
})

# update credit card
updated_credit_card = Paysimple::CreditCard.update({ id: credit_card[:id], ... })

# delete credit card
Paysimple::CreditCard.delete(credit_card[:id])

###ACH

# create ACH
ach = Paysimple::ACH.create({
	customer_id: customer[:id],
    account_number: '751111111',
    routing_number: '131111114',
    bank_name: 'PaySimple Bank',
    is_checking_account: true,
    is_default: true
})

# update ACH
updated_ach = Paysimple::ACH.update({ id: ach[:id], ... })

# delete ACH
Paysimple::ACH.delete(ach[:id])

###Payment

# create payment
payment = Paysimple::Payment.create({ amount: 100, account_id: credit_card[:id] })

# get payment
payment = Paysimple::Payment.get(payment[:id])

# void payment
Paysimple::Payment.void(payment[:id])

# refund payment
Paysimple::Payment.refund(payment[:id])

# find payments
payments = Paysimple::Payment.find({ status: 'authorized', page_size: 10 })

RecurringPayment

# create recurring payment
recurring_payment = Paysimple::RecurringPayment.create({
	account_id: credit_card[:id],
    payment_amount: 10,
    start_date: Date.today,
    execution_frequency_type: Paysimple::ExecutionFrequencyType::DAILY
})

# get recurring payment
recurring_payment = Paysimple::RecurringPayment.get(recurring_payment[:id])

# suspend recurring payment
Paysimple::RecurringPayment.suspend(recurring_payment[:id])

# resume recurring payment
Paysimple::RecurringPayment.resume(recurring_payment[:id])

# get payments connected with recurring payment
payments = Paysimple::RecurringPayment.payments(recurring_payment[:id])

# find recurring payments
recurring_payments = Paysimple::RecurringPayment.find({ page_size: 10 })

# delete recurring payment
Paysimple::RecurringPayment.delete(payment[:id])

###PaymentPlan

 # create payment plan
payment_plan = Paysimple::PaymentPlan.create({
	account_id: credit_card[:id],
    total_due_amount: 10,
    total_number_of_payments: 3,
    start_date: Date.today,
    execution_frequency_type: Paysimple::ExecutionFrequencyType::DAILY
})

# get payment plan
payment_plan = Paysimple::PaymentPlan.get(payment_plan[:id])

# suspend payment plan
Paysimple::PaymentPlan.suspend(payment_plan[:id])

# resume payment plan
Paysimple::PaymentPlan.resume(payment_plan[:id])

# get payments connected with payment plan
payments = Paysimple::PaymentPlan.payments(payment_plan[:id])

# find payment plan
payment_plans = Paysimple::PaymentPlan.find({ page_size: 10 })

# delete payment plan
Paysimple::PaymentPlan.delete(payment_plan[:id])

paysimple-ruby's People

Contributors

koss-lebedev avatar jerryjohnjacob avatar

Watchers

Daniel Rice 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.