Created
June 22, 2017 21:10
-
-
Save frojasg/3ad77cb2baa2fecaa56b4d0b759240d2 to your computer and use it in GitHub Desktop.
ActiveMerchantSquare
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_merchant_square' | |
# Get your login and password by going to: https://connect.squareup.com/apps | |
credentials = { | |
login: 'APPLICATION_ID', | |
password: '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_cents = 1000 # $10.00 | |
gateway = ActiveMerchant::Billing::SquareGateway.new(credentials) | |
response = gateway.purchase(amount_cents, card_nonce, { | |
:description => 'Store Purchase Note'}) | |
if response.success? | |
puts "Successfully charged $#{sprintf("%.2f", amount_cents / 100)}" | |
else | |
raise StandardError, response.message | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment