Od::Payments

stripe version: 5.22.0 square version: 6.3.0.20200826

Installation

Step 1

Add this line to your application's Gemfile:

gem 'od-payments'

Step 2

create config/initializers/od_payments.rb with

Od::Payments.configure(:stripe,{api_key_stripe: 'api_key_stripe'})
Prop Type Required Description
adapter Symbol Yes :stripe, :square
options Hash No { api_key_stripe: 'api_key_stripe', access_token_square: 'access_token_square', environment_square: 'environment_square'}

Usage

Payment

create

 Od::Payments::Charge.create(2000, {
     token_payment: 'pm_card_visa',
     capture_method: 'automatic',
     confirm: true })
Prop Type Required Description
amount Decimal Yes Amount
options Hash No Other options show in https://stripe.com/docs/api/payment_intents/create

capture

 Od::Payments::Charge.capture("charge_id")

cancel

 Od::Payments::Charge.cancel("charge_id")

void

 Od::Payments::Charge.void("charge_id")

confirm

 Od::Payments::Charge.confirm("charge_id")

Payment Method

create with stripe example

Od::Payments::PaymentMethod.create(
        {
          type: 'card',
          card: {
            number: '4000000000000341',
            exp_month: 8,
            exp_year: 2021,
            cvc: '314'
          }
        }
      )
Prop Type Required Description
params Hash Yes Show params in https://stripe.com/docs/api/payment_methods/create

list

Od::Payments::PaymentMethod.list "customer_id"

delete

Od::Payments::PaymentMethod.delete "payment_method_id"

show

Od::Payments::PaymentMethod.show "payment_method_id"

attach

Od::Payments::PaymentMethod.attach "payment_method_id"

Customer

create with stripe example

Od::Payments::Customer.create(
    {
        email: '[email protected]',
        name: "Juan Perez",
        description: "my description"
    }
)
Prop Type Required Description
params Hash Yes Show params in https://stripe.com/docs/api/customers/create

show

Od::Payments::Customer.show("customer_id")

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec 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.

License

The gem is available as open source under the terms of the MIT License.