public
Description: Tools for processing credit cards on the command line
Homepage: http://scie.nti.st
Clone URL: git://github.com/up_the_irons/credit_card_tools.git
Click here to lend your support to: credit_card_tools and make a donation at www.pledgie.com !
credit_card_tools / refund.rb
100755 29 lines (19 sloc) 0.46 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env ruby
 
$:.unshift File.join(File.dirname(__FILE__))
 
def usage
  puts "./refund.rb <amount> <auth_id>"
end
 
$AMOUNT = ARGV[0]
$AUTH_ID = ARGV[1]
 
# Convert dollars to cents
$AMOUNT = ($AMOUNT.to_f * 100).to_i unless $AMOUNT.nil?
 
unless $AMOUNT && $AUTH_ID
  usage
  exit
end
 
require 'rubygems'
require 'active_merchant'
 
# Provides @gateway instance
require 'gateway'
 
response = @gateway.credit($AMOUNT.to_i, $AUTH_ID)
 
puts response.to_yaml