zapient / active_merchant_square

Square's e-commerce API support added to Active Merchant. (This depends on core active merchant, so it can coexist peacefully with upstream changes there. Not merged into Active Merchant for reasons as described here https://github.com/activemerchant/active_merchant/pull/2242) See example below, and our blog post: https://medium.com/square-corner-blog/activemerchantsquare-for-squares-e-commerce-api-111ea63e530a

Repository from Github https://github.comzapient/active_merchant_squareRepository from Github https://github.comzapient/active_merchant_square

Active Merchant Square

Installation

Add this line to your application's Gemfile:

gem 'active_merchant_square'

And then execute:

$ bundle

Or install it yourself as:

$ gem install active_merchant_square

Usage

This simple example demonstrates how a purchase can be made after getting a card nonce

require 'active_merchant_square'

# Get your login and password by going to: https://connect.squareup.com/apps
credentials = {
  login: 'sandbox-sq0idp-APPLICATION_ID',
  password: 'sandbox-sq0atb-APPLICATION_SECRET',
  # How to get your location ID, see: https://docs.connect.squareup.com/articles/faq-lookup-my-location-id
  location_id: 'LOCATION_ID',
}

amount = 1000  # $10.00

gateway = ActiveMerchant::Billing::SquareGateway.new(credentials)
response = gateway.purchase(amount, card_nonce)

if response.success?
   puts "Successfully charged $#{sprintf("%.2f", amount / 100)}"
else
   raise StandardError, response.message
end

For more in-depth documentation and tutorials, see Square Documentation site

Simple Web Example

You can take a look at our example application using gem 'sinatra' and gem 'square_active_merchant' here.

About

Square's e-commerce API support added to Active Merchant. (This depends on core active merchant, so it can coexist peacefully with upstream changes there. Not merged into Active Merchant for reasons as described here https://github.com/activemerchant/active_merchant/pull/2242) See example below, and our blog post: https://medium.com/square-corner-blog/activemerchantsquare-for-squares-e-commerce-api-111ea63e530a

License:MIT License


Languages

Language:Ruby 99.8%Language:Shell 0.2%