Giter Site home page Giter Site logo

square / active_merchant_square Goto Github PK

View Code? Open in Web Editor NEW
6.0 15.0 11.0 50 KB

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

Ruby 99.79% Shell 0.21%

active_merchant_square's Introduction

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.

active_merchant_square's People

Contributors

frojasg avatar jawspeak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

active_merchant_square's Issues

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.