ruby_psigate 0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/CHANGELOG +2 -0
  2. data/Gemfile +12 -0
  3. data/LICENSE +0 -0
  4. data/Manifest +45 -0
  5. data/README.markdown +99 -0
  6. data/Rakefile +28 -0
  7. data/lib/certs/cacert.pem +2633 -0
  8. data/lib/ruby_psigate/account.rb +152 -0
  9. data/lib/ruby_psigate/account_manager_api.rb +137 -0
  10. data/lib/ruby_psigate/account_methods.rb +5 -0
  11. data/lib/ruby_psigate/address.rb +54 -0
  12. data/lib/ruby_psigate/connection.rb +96 -0
  13. data/lib/ruby_psigate/credit_card.rb +104 -0
  14. data/lib/ruby_psigate/credit_card_methods.rb +12 -0
  15. data/lib/ruby_psigate/error.rb +33 -0
  16. data/lib/ruby_psigate/gateway.rb +126 -0
  17. data/lib/ruby_psigate/hash_variables.rb +58 -0
  18. data/lib/ruby_psigate/item.rb +65 -0
  19. data/lib/ruby_psigate/item_option.rb +10 -0
  20. data/lib/ruby_psigate/number_validation_methods.rb +12 -0
  21. data/lib/ruby_psigate/order.rb +120 -0
  22. data/lib/ruby_psigate/recurring_charge.rb +53 -0
  23. data/lib/ruby_psigate/recurring_item.rb +26 -0
  24. data/lib/ruby_psigate/response.rb +109 -0
  25. data/lib/ruby_psigate/serializer.rb +59 -0
  26. data/lib/ruby_psigate/transaction_methods.rb +21 -0
  27. data/lib/ruby_psigate/utils.rb +18 -0
  28. data/lib/ruby_psigate.rb +57 -0
  29. data/ruby_psigate.gemspec +31 -0
  30. data/test/remote/remote_account_test.rb +33 -0
  31. data/test/remote/remote_gateway_test.rb +32 -0
  32. data/test/test_helper.rb +144 -0
  33. data/test/unit/account_manager_api_test.rb +96 -0
  34. data/test/unit/account_test.rb +388 -0
  35. data/test/unit/address_test.rb +99 -0
  36. data/test/unit/connection_test.rb +153 -0
  37. data/test/unit/credit_card_test.rb +152 -0
  38. data/test/unit/gateway_test.rb +112 -0
  39. data/test/unit/item_option_test.rb +19 -0
  40. data/test/unit/item_test.rb +106 -0
  41. data/test/unit/order_test.rb +491 -0
  42. data/test/unit/recurring_charge_test.rb +89 -0
  43. data/test/unit/recurring_item_test.rb +62 -0
  44. data/test/unit/response_test.rb +110 -0
  45. data/test/unit/serializer_test.rb +89 -0
  46. data/test/unit/xml_api_test.rb +25 -0
  47. metadata +154 -0
data/CHANGELOG ADDED
@@ -0,0 +1,2 @@
1
+ v0.7. project semi functional. most things to should, but a lot of rough edges.
2
+ v0.1. project started
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'activesupport'
4
+ gem 'builder'
5
+ gem 'crack'
6
+ gem 'creditcard'
7
+ gem 'money'
8
+
9
+ # For testing
10
+ gem 'echoe'
11
+ gem 'mocha'
12
+ gem 'shoulda'
data/LICENSE ADDED
File without changes
data/Manifest ADDED
@@ -0,0 +1,45 @@
1
+ CHANGELOG
2
+ Gemfile
3
+ LICENSE
4
+ Manifest
5
+ README.markdown
6
+ Rakefile
7
+ lib/certs/cacert.pem
8
+ lib/ruby_psigate.rb
9
+ lib/ruby_psigate/account.rb
10
+ lib/ruby_psigate/account_manager_api.rb
11
+ lib/ruby_psigate/account_methods.rb
12
+ lib/ruby_psigate/address.rb
13
+ lib/ruby_psigate/connection.rb
14
+ lib/ruby_psigate/credit_card.rb
15
+ lib/ruby_psigate/credit_card_methods.rb
16
+ lib/ruby_psigate/error.rb
17
+ lib/ruby_psigate/gateway.rb
18
+ lib/ruby_psigate/hash_variables.rb
19
+ lib/ruby_psigate/item.rb
20
+ lib/ruby_psigate/item_option.rb
21
+ lib/ruby_psigate/number_validation_methods.rb
22
+ lib/ruby_psigate/order.rb
23
+ lib/ruby_psigate/recurring_charge.rb
24
+ lib/ruby_psigate/recurring_item.rb
25
+ lib/ruby_psigate/response.rb
26
+ lib/ruby_psigate/serializer.rb
27
+ lib/ruby_psigate/transaction_methods.rb
28
+ lib/ruby_psigate/utils.rb
29
+ test/remote/remote_account_test.rb
30
+ test/remote/remote_gateway_test.rb
31
+ test/test_helper.rb
32
+ test/unit/account_manager_api_test.rb
33
+ test/unit/account_test.rb
34
+ test/unit/address_test.rb
35
+ test/unit/connection_test.rb
36
+ test/unit/credit_card_test.rb
37
+ test/unit/gateway_test.rb
38
+ test/unit/item_option_test.rb
39
+ test/unit/item_test.rb
40
+ test/unit/order_test.rb
41
+ test/unit/recurring_charge_test.rb
42
+ test/unit/recurring_item_test.rb
43
+ test/unit/response_test.rb
44
+ test/unit/serializer_test.rb
45
+ test/unit/xml_api_test.rb
data/README.markdown ADDED
@@ -0,0 +1,99 @@
1
+ ## Ruby Psigate Library ##
2
+
3
+ Psigate (http://www.psigate.com) is a Canadian company which specializes in payment transactions over the internet. They support real time transactions and recurring billing options with a stored credit card accounts.
4
+
5
+ The purpose of this library to allow Ruby applications to interact with Psigate's API.
6
+
7
+ ## Why not use Active Merchant instead? ##
8
+
9
+ Active Merchant is a library that supports many different gateways. If you were to, say, build an online shopping cart, and must support 10-20 gateways because the store owner may be partnered with any one of those companies, then Active Merchant is the appropriate choice. However, if you were building a service based web application, and you happened to use Psigate, then Active Merchant's features do not necessarily fulfill what you need. Specifically, if you wished to create billing profiles (eg. for recurring billings), Active Merchant's API does not currently support that option.
10
+
11
+ I am sure there are many edge cases that require more specific features of Psigate's API, and so this library attempts to satisfy those needs.
12
+
13
+ Underneath the hood, Ruby Psigate differs from Active Merchant in that it uses XML to communicate with Psigate's servers rather than through posted parameters.
14
+
15
+ Disclaimer: Parts of this library were based on Active Merchant's design
16
+
17
+ ## Installation ##
18
+
19
+ In your terminal, just type:
20
+ gem install ruby-psigate
21
+
22
+ Then, in your application:
23
+ require 'ruby_psigate'
24
+
25
+ ## Usage ##
26
+
27
+ 1) First initialize your gateway instance object
28
+
29
+ @gateway = RubyPsigate::Gateway.new(
30
+ :cid => "1000001",
31
+ :login => "teststore",
32
+ :password => "test1234"
33
+ )
34
+
35
+ The library defaults to TEST environment. When you are ready to use it in production environment, simply:
36
+
37
+ RubyPsigate::Gateway.test = false
38
+
39
+
40
+ 2) You can treat this object as the "params container" you want to send to psigate to process. But first you must specify whether you want to send it to Psigate's xml transaction server (for pre auth/post auth/sale/void/refund type of transactions) or to Psigate's account manager server (for creating recurring accounts, viewing existing accounts, changing charges for recurring accounts)
41
+
42
+ @gateway.mode = :transaction
43
+
44
+ or
45
+
46
+ @gateway.mode = :account_manager
47
+
48
+
49
+ 4) Say we are using the transaction server (@gateway = :transaction), and we want to create a "SALE" transaction. The RubyPsigate library contains several other classes beside the RubyPsigate::Gateway class, in order to help you organize the data you will be sending to Psigate.
50
+
51
+ First, there is the RubyPsigate::Address class. This class simply allows you to create an instance to hold together address information. The purpose of separating this out to its own class is so that if you wanted to specify a shipping and billing address, you can simply by referring it to the same instance object.
52
+
53
+ @address = RubyPsigate::Address.new(
54
+ :email => "bob.john@somewhere.com",
55
+ :firstname => "Bob",
56
+ :lastname => "John",
57
+ :company => "Bob John's Company",
58
+ :line1 => "1234 Alley Street",
59
+ :line2 => nil,
60
+ :city => "Los Caltown",
61
+ :state => "California",
62
+ :zipcode => "12345",
63
+ :country => "USA",
64
+ :telephone => "416-123-1232",
65
+ :fax => nil
66
+ )
67
+
68
+ @gateway.billing = @address
69
+ @gateway.shipping = @address
70
+
71
+
72
+ 4) Next, there is the RubyPsigate::CreditCard class. This class does some basic validations that the credit card you've provided is a valid one. Since Psigate only accepts Visa/Mastercard/Amex, if you try to enter something other than these three, an error will be raised.
73
+
74
+ @credit_card = RubyPsigate::CreditCard.new(
75
+ :number => "4111111111111111",
76
+ :month => "9",
77
+ :year => "2010",
78
+ :name => "Bob John"
79
+ )
80
+
81
+ @gateway.cc = @credit_card
82
+
83
+ 5) Specify the amount you will be charging. This is done via the instance object #amount:
84
+
85
+ @gateway.amount = "10.00"
86
+
87
+
88
+ 6) Finally, tell the object what you want it to do. Depending on the action you want the object to take, you may or may not have provided enough details and an error may be raised. However, for this example, we have enough information for the object to post a "SALE" to Psigate.
89
+
90
+ @gateway.sale!
91
+
92
+
93
+ 7) There are a lot of different functionalities to the RubyPsigate library, such as adding items and option details to the order. Please look at the source documentation for details!
94
+
95
+ ## Authors ##
96
+
97
+ Ruby Psigate is created by Simon Chiu.
98
+
99
+ Parts of this software is based on Active Merchant. Active Merchant is written by Tobias Luetke, Cody Fauser, and contributors.
data/Rakefile ADDED
@@ -0,0 +1,28 @@
1
+ require 'rake'
2
+
3
+ # Echoe project management
4
+ require 'echoe'
5
+ Echoe.new('ruby_psigate') do |p|
6
+ p.author = "Simon Chiu"
7
+ p.email = "skhchiu@gmail.com"
8
+ p.summary = "A library to connect with the XML and Account interfaces of Psigate's servers"
9
+ p.description = "RubyPsigate parses and packages XML messages to/from Psigate's servers for transactions and recurring billing management."
10
+ p.url = "http://oss.simonchiu.com"
11
+ end
12
+
13
+ # Use rake:test:units when in development mode so you don't end up pinging Psigate's server every time!
14
+ namespace :test do
15
+ Rake::TestTask.new(:units) do |t|
16
+ t.pattern = 'test/unit/**/*_test.rb'
17
+ t.ruby_opts << '-rubygems'
18
+ t.libs << 'test'
19
+ t.verbose = true
20
+ end
21
+
22
+ Rake::TestTask.new(:remote) do |t|
23
+ t.pattern = 'test/remote/**/*_test.rb'
24
+ t.ruby_opts << '-rubygems'
25
+ t.libs << 'test'
26
+ t.verbose = true
27
+ end
28
+ end