bitfluent-activemerchant 1.5.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. data/CHANGELOG +520 -0
  2. data/CONTRIBUTORS +138 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.rdoc +136 -0
  5. data/gem-public_cert.pem +20 -0
  6. data/lib/active_merchant/billing/avs_result.rb +98 -0
  7. data/lib/active_merchant/billing/base.rb +57 -0
  8. data/lib/active_merchant/billing/check.rb +68 -0
  9. data/lib/active_merchant/billing/credit_card.rb +159 -0
  10. data/lib/active_merchant/billing/credit_card_formatting.rb +21 -0
  11. data/lib/active_merchant/billing/credit_card_methods.rb +125 -0
  12. data/lib/active_merchant/billing/cvv_result.rb +38 -0
  13. data/lib/active_merchant/billing/expiry_date.rb +34 -0
  14. data/lib/active_merchant/billing/gateway.rb +163 -0
  15. data/lib/active_merchant/billing/gateways/authorize_net.rb +654 -0
  16. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +736 -0
  17. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +244 -0
  18. data/lib/active_merchant/billing/gateways/beanstream.rb +102 -0
  19. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +54 -0
  20. data/lib/active_merchant/billing/gateways/bogus.rb +102 -0
  21. data/lib/active_merchant/billing/gateways/braintree.rb +17 -0
  22. data/lib/active_merchant/billing/gateways/card_stream.rb +230 -0
  23. data/lib/active_merchant/billing/gateways/cyber_source.rb +406 -0
  24. data/lib/active_merchant/billing/gateways/data_cash.rb +593 -0
  25. data/lib/active_merchant/billing/gateways/efsnet.rb +229 -0
  26. data/lib/active_merchant/billing/gateways/elavon.rb +134 -0
  27. data/lib/active_merchant/billing/gateways/eway.rb +277 -0
  28. data/lib/active_merchant/billing/gateways/exact.rb +222 -0
  29. data/lib/active_merchant/billing/gateways/first_pay.rb +172 -0
  30. data/lib/active_merchant/billing/gateways/garanti.rb +222 -0
  31. data/lib/active_merchant/billing/gateways/instapay.rb +164 -0
  32. data/lib/active_merchant/billing/gateways/jetpay.rb +270 -0
  33. data/lib/active_merchant/billing/gateways/linkpoint.rb +449 -0
  34. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +154 -0
  35. data/lib/active_merchant/billing/gateways/merchant_ware.rb +283 -0
  36. data/lib/active_merchant/billing/gateways/modern_payments.rb +36 -0
  37. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +220 -0
  38. data/lib/active_merchant/billing/gateways/moneris.rb +205 -0
  39. data/lib/active_merchant/billing/gateways/net_registry.rb +189 -0
  40. data/lib/active_merchant/billing/gateways/netbilling.rb +168 -0
  41. data/lib/active_merchant/billing/gateways/ogone.rb +279 -0
  42. data/lib/active_merchant/billing/gateways/pay_junction.rb +392 -0
  43. data/lib/active_merchant/billing/gateways/pay_secure.rb +120 -0
  44. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +207 -0
  45. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +39 -0
  46. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
  47. data/lib/active_merchant/billing/gateways/payflow.rb +236 -0
  48. data/lib/active_merchant/billing/gateways/payflow_express.rb +138 -0
  49. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +15 -0
  50. data/lib/active_merchant/billing/gateways/payflow_uk.rb +21 -0
  51. data/lib/active_merchant/billing/gateways/payment_express.rb +230 -0
  52. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +326 -0
  53. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +38 -0
  54. data/lib/active_merchant/billing/gateways/paypal.rb +121 -0
  55. data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
  56. data/lib/active_merchant/billing/gateways/paypal_express.rb +135 -0
  57. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +20 -0
  58. data/lib/active_merchant/billing/gateways/plugnpay.rb +292 -0
  59. data/lib/active_merchant/billing/gateways/psigate.rb +214 -0
  60. data/lib/active_merchant/billing/gateways/psl_card.rb +304 -0
  61. data/lib/active_merchant/billing/gateways/quickpay.rb +213 -0
  62. data/lib/active_merchant/billing/gateways/realex.rb +200 -0
  63. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +88 -0
  64. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +116 -0
  65. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +97 -0
  66. data/lib/active_merchant/billing/gateways/sage.rb +146 -0
  67. data/lib/active_merchant/billing/gateways/sage_pay.rb +309 -0
  68. data/lib/active_merchant/billing/gateways/sallie_mae.rb +144 -0
  69. data/lib/active_merchant/billing/gateways/secure_pay.rb +31 -0
  70. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +157 -0
  71. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +113 -0
  72. data/lib/active_merchant/billing/gateways/skip_jack.rb +453 -0
  73. data/lib/active_merchant/billing/gateways/smart_ps.rb +265 -0
  74. data/lib/active_merchant/billing/gateways/trans_first.rb +127 -0
  75. data/lib/active_merchant/billing/gateways/transax.rb +25 -0
  76. data/lib/active_merchant/billing/gateways/trust_commerce.rb +418 -0
  77. data/lib/active_merchant/billing/gateways/usa_epay.rb +194 -0
  78. data/lib/active_merchant/billing/gateways/verifi.rb +228 -0
  79. data/lib/active_merchant/billing/gateways/viaklix.rb +189 -0
  80. data/lib/active_merchant/billing/gateways/wirecard.rb +318 -0
  81. data/lib/active_merchant/billing/gateways.rb +18 -0
  82. data/lib/active_merchant/billing/integrations/action_view_helper.rb +79 -0
  83. data/lib/active_merchant/billing/integrations/bogus/helper.rb +17 -0
  84. data/lib/active_merchant/billing/integrations/bogus/notification.rb +11 -0
  85. data/lib/active_merchant/billing/integrations/bogus/return.rb +10 -0
  86. data/lib/active_merchant/billing/integrations/bogus.rb +23 -0
  87. data/lib/active_merchant/billing/integrations/chronopay/helper.rb +120 -0
  88. data/lib/active_merchant/billing/integrations/chronopay/notification.rb +158 -0
  89. data/lib/active_merchant/billing/integrations/chronopay/return.rb +10 -0
  90. data/lib/active_merchant/billing/integrations/chronopay.rb +23 -0
  91. data/lib/active_merchant/billing/integrations/gestpay/common.rb +42 -0
  92. data/lib/active_merchant/billing/integrations/gestpay/helper.rb +70 -0
  93. data/lib/active_merchant/billing/integrations/gestpay/notification.rb +85 -0
  94. data/lib/active_merchant/billing/integrations/gestpay/return.rb +10 -0
  95. data/lib/active_merchant/billing/integrations/gestpay.rb +25 -0
  96. data/lib/active_merchant/billing/integrations/helper.rb +93 -0
  97. data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +58 -0
  98. data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +59 -0
  99. data/lib/active_merchant/billing/integrations/hi_trust/return.rb +67 -0
  100. data/lib/active_merchant/billing/integrations/hi_trust.rb +27 -0
  101. data/lib/active_merchant/billing/integrations/ipay88/helper.rb +120 -0
  102. data/lib/active_merchant/billing/integrations/ipay88/return.rb +121 -0
  103. data/lib/active_merchant/billing/integrations/ipay88.rb +40 -0
  104. data/lib/active_merchant/billing/integrations/nochex/helper.rb +68 -0
  105. data/lib/active_merchant/billing/integrations/nochex/notification.rb +94 -0
  106. data/lib/active_merchant/billing/integrations/nochex/return.rb +10 -0
  107. data/lib/active_merchant/billing/integrations/nochex.rb +88 -0
  108. data/lib/active_merchant/billing/integrations/notification.rb +62 -0
  109. data/lib/active_merchant/billing/integrations/paypal/helper.rb +119 -0
  110. data/lib/active_merchant/billing/integrations/paypal/notification.rb +154 -0
  111. data/lib/active_merchant/billing/integrations/paypal/return.rb +10 -0
  112. data/lib/active_merchant/billing/integrations/paypal.rb +39 -0
  113. data/lib/active_merchant/billing/integrations/quickpay/helper.rb +72 -0
  114. data/lib/active_merchant/billing/integrations/quickpay/notification.rb +74 -0
  115. data/lib/active_merchant/billing/integrations/quickpay.rb +17 -0
  116. data/lib/active_merchant/billing/integrations/return.rb +35 -0
  117. data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +59 -0
  118. data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +114 -0
  119. data/lib/active_merchant/billing/integrations/two_checkout/return.rb +17 -0
  120. data/lib/active_merchant/billing/integrations/two_checkout.rb +23 -0
  121. data/lib/active_merchant/billing/integrations.rb +29 -0
  122. data/lib/active_merchant/billing/response.rb +32 -0
  123. data/lib/active_merchant/billing.rb +9 -0
  124. data/lib/active_merchant/common/connection.rb +172 -0
  125. data/lib/active_merchant/common/country.rb +319 -0
  126. data/lib/active_merchant/common/error.rb +26 -0
  127. data/lib/active_merchant/common/post_data.rb +24 -0
  128. data/lib/active_merchant/common/posts_data.rb +47 -0
  129. data/lib/active_merchant/common/requires_parameters.rb +16 -0
  130. data/lib/active_merchant/common/utils.rb +18 -0
  131. data/lib/active_merchant/common/validateable.rb +76 -0
  132. data/lib/active_merchant/common.rb +14 -0
  133. data/lib/active_merchant.rb +38 -0
  134. data/lib/activemerchant.rb +1 -0
  135. data/lib/certs/cacert.pem +7815 -0
  136. data/lib/support/gateway_support.rb +58 -0
  137. data/lib/support/outbound_hosts.rb +25 -0
  138. metadata +235 -0
@@ -0,0 +1,319 @@
1
+ #!ruby19
2
+ # encoding: utf-8
3
+
4
+ module ActiveMerchant #:nodoc:
5
+ class InvalidCountryCodeError < StandardError
6
+ end
7
+
8
+ class CountryCodeFormatError < StandardError
9
+ end
10
+
11
+ class CountryCode
12
+ attr_reader :value, :format
13
+ def initialize(value)
14
+ @value = value.to_s.upcase
15
+ detect_format
16
+ end
17
+
18
+ def to_s
19
+ value
20
+ end
21
+
22
+ private
23
+
24
+ def detect_format
25
+ case @value
26
+ when /^[[:alpha:]]{2}$/
27
+ @format = :alpha2
28
+ when /^[[:alpha:]]{3}$/
29
+ @format = :alpha3
30
+ when /^[[:digit:]]{3}$/
31
+ @format = :numeric
32
+ else
33
+ raise CountryCodeFormatError, "The country code is not formatted correctly #{@value}"
34
+ end
35
+ end
36
+ end
37
+
38
+ class Country
39
+ include RequiresParameters
40
+ attr_reader :name
41
+
42
+ def initialize(options = {})
43
+ requires!(options, :name, :alpha2, :alpha3, :numeric)
44
+ @name = options.delete(:name)
45
+ @codes = options.collect{|k,v| CountryCode.new(v)}
46
+ end
47
+
48
+ def code(format)
49
+ @codes.select{|c| c.format == format}
50
+ end
51
+
52
+ def to_s
53
+ @name
54
+ end
55
+
56
+ COUNTRIES = [
57
+ { :alpha2 => 'AF', :name => 'Afghanistan', :alpha3 => 'AFG', :numeric => '004' },
58
+ { :alpha2 => 'AL', :name => 'Albania', :alpha3 => 'ALB', :numeric => '008' },
59
+ { :alpha2 => 'DZ', :name => 'Algeria', :alpha3 => 'DZA', :numeric => '012' },
60
+ { :alpha2 => 'AS', :name => 'American Samoa', :alpha3 => 'ASM', :numeric => '016' },
61
+ { :alpha2 => 'AD', :name => 'Andorra', :alpha3 => 'AND', :numeric => '020' },
62
+ { :alpha2 => 'AO', :name => 'Angola', :alpha3 => 'AGO', :numeric => '024' },
63
+ { :alpha2 => 'AI', :name => 'Anguilla', :alpha3 => 'AIA', :numeric => '660' },
64
+ { :alpha2 => 'AG', :name => 'Antigua and Barbuda', :alpha3 => 'ATG', :numeric => '028' },
65
+ { :alpha2 => 'AR', :name => 'Argentina', :alpha3 => 'ARG', :numeric => '032' },
66
+ { :alpha2 => 'AM', :name => 'Armenia', :alpha3 => 'ARM', :numeric => '051' },
67
+ { :alpha2 => 'AW', :name => 'Aruba', :alpha3 => 'ABW', :numeric => '533' },
68
+ { :alpha2 => 'AU', :name => 'Australia', :alpha3 => 'AUS', :numeric => '036' },
69
+ { :alpha2 => 'AT', :name => 'Austria', :alpha3 => 'AUT', :numeric => '040' },
70
+ { :alpha2 => 'AX', :name => 'Åland Islands', :alpha3 => 'ALA', :numeric => '248' },
71
+ { :alpha2 => 'AZ', :name => 'Azerbaijan', :alpha3 => 'AZE', :numeric => '031' },
72
+ { :alpha2 => 'BS', :name => 'Bahamas', :alpha3 => 'BHS', :numeric => '044' },
73
+ { :alpha2 => 'BH', :name => 'Bahrain', :alpha3 => 'BHR', :numeric => '048' },
74
+ { :alpha2 => 'BD', :name => 'Bangladesh', :alpha3 => 'BGD', :numeric => '050' },
75
+ { :alpha2 => 'BB', :name => 'Barbados', :alpha3 => 'BRB', :numeric => '052' },
76
+ { :alpha2 => 'BY', :name => 'Belarus', :alpha3 => 'BLR', :numeric => '112' },
77
+ { :alpha2 => 'BE', :name => 'Belgium', :alpha3 => 'BEL', :numeric => '056' },
78
+ { :alpha2 => 'BZ', :name => 'Belize', :alpha3 => 'BLZ', :numeric => '084' },
79
+ { :alpha2 => 'BJ', :name => 'Benin', :alpha3 => 'BEN', :numeric => '204' },
80
+ { :alpha2 => 'BM', :name => 'Bermuda', :alpha3 => 'BMU', :numeric => '060' },
81
+ { :alpha2 => 'BT', :name => 'Bhutan', :alpha3 => 'BTN', :numeric => '064' },
82
+ { :alpha2 => 'BO', :name => 'Bolivia', :alpha3 => 'BOL', :numeric => '068' },
83
+ { :alpha2 => 'BA', :name => 'Bosnia and Herzegovina', :alpha3 => 'BIH', :numeric => '070' },
84
+ { :alpha2 => 'BW', :name => 'Botswana', :alpha3 => 'BWA', :numeric => '072' },
85
+ { :alpha2 => 'BV', :name => 'Bouvet Island', :alpha3 => 'BVD', :numeric => '074' },
86
+ { :alpha2 => 'BR', :name => 'Brazil', :alpha3 => 'BRA', :numeric => '076' },
87
+ { :alpha2 => 'BN', :name => 'Brunei Darussalam', :alpha3 => 'BRN', :numeric => '096' },
88
+ { :alpha2 => 'IO', :name => 'British Indian Ocean Territory', :alpha3 => 'IOT', :numeric => '086' },
89
+ { :alpha2 => 'BG', :name => 'Bulgaria', :alpha3 => 'BGR', :numeric => '100' },
90
+ { :alpha2 => 'BF', :name => 'Burkina Faso', :alpha3 => 'BFA', :numeric => '854' },
91
+ { :alpha2 => 'BI', :name => 'Burundi', :alpha3 => 'BDI', :numeric => '108' },
92
+ { :alpha2 => 'KH', :name => 'Cambodia', :alpha3 => 'KHM', :numeric => '116' },
93
+ { :alpha2 => 'CM', :name => 'Cameroon', :alpha3 => 'CMR', :numeric => '120' },
94
+ { :alpha2 => 'CA', :name => 'Canada', :alpha3 => 'CAN', :numeric => '124' },
95
+ { :alpha2 => 'CV', :name => 'Cape Verde', :alpha3 => 'CPV', :numeric => '132' },
96
+ { :alpha2 => 'KY', :name => 'Cayman Islands', :alpha3 => 'CYM', :numeric => '136' },
97
+ { :alpha2 => 'CF', :name => 'Central African Republic', :alpha3 => 'CAF', :numeric => '140' },
98
+ { :alpha2 => 'TD', :name => 'Chad', :alpha3 => 'TCD', :numeric => '148' },
99
+ { :alpha2 => 'CL', :name => 'Chile', :alpha3 => 'CHL', :numeric => '152' },
100
+ { :alpha2 => 'CN', :name => 'China', :alpha3 => 'CHN', :numeric => '156' },
101
+ { :alpha2 => 'CX', :name => 'Christmas Island', :alpha3 => 'CXR', :numeric => '162' },
102
+ { :alpha2 => 'CC', :name => 'Cocos (Keeling) Islands', :alpha3 => 'CCK', :numeric => '166' },
103
+ { :alpha2 => 'CO', :name => 'Colombia', :alpha3 => 'COL', :numeric => '170' },
104
+ { :alpha2 => 'KM', :name => 'Comoros', :alpha3 => 'COM', :numeric => '174' },
105
+ { :alpha2 => 'CG', :name => 'Congo', :alpha3 => 'COG', :numeric => '178' },
106
+ { :alpha2 => 'CD', :name => 'Congo, the Democratic Republic of the', :alpha3 => 'COD', :numeric => '180' },
107
+ { :alpha2 => 'CK', :name => 'Cook Islands', :alpha3 => 'COK', :numeric => '184' },
108
+ { :alpha2 => 'CR', :name => 'Costa Rica', :alpha3 => 'CRI', :numeric => '188' },
109
+ { :alpha2 => 'CI', :name => 'Cote D\'Ivoire', :alpha3 => 'CIV', :numeric => '384' },
110
+ { :alpha2 => 'HR', :name => 'Croatia', :alpha3 => 'HRV', :numeric => '191' },
111
+ { :alpha2 => 'CU', :name => 'Cuba', :alpha3 => 'CUB', :numeric => '192' },
112
+ { :alpha2 => 'CY', :name => 'Cyprus', :alpha3 => 'CYP', :numeric => '196' },
113
+ { :alpha2 => 'CZ', :name => 'Czech Republic', :alpha3 => 'CZE', :numeric => '203' },
114
+ { :alpha2 => 'DK', :name => 'Denmark', :alpha3 => 'DNK', :numeric => '208' },
115
+ { :alpha2 => 'DJ', :name => 'Djibouti', :alpha3 => 'DJI', :numeric => '262' },
116
+ { :alpha2 => 'DM', :name => 'Dominica', :alpha3 => 'DMA', :numeric => '212' },
117
+ { :alpha2 => 'DO', :name => 'Dominican Republic', :alpha3 => 'DOM', :numeric => '214' },
118
+ { :alpha2 => 'EC', :name => 'Ecuador', :alpha3 => 'ECU', :numeric => '218' },
119
+ { :alpha2 => 'EG', :name => 'Egypt', :alpha3 => 'EGY', :numeric => '818' },
120
+ { :alpha2 => 'SV', :name => 'El Salvador', :alpha3 => 'SLV', :numeric => '222' },
121
+ { :alpha2 => 'GQ', :name => 'Equatorial Guinea', :alpha3 => 'GNQ', :numeric => '226' },
122
+ { :alpha2 => 'ER', :name => 'Eritrea', :alpha3 => 'ERI', :numeric => '232' },
123
+ { :alpha2 => 'EE', :name => 'Estonia', :alpha3 => 'EST', :numeric => '233' },
124
+ { :alpha2 => 'ET', :name => 'Ethiopia', :alpha3 => 'ETH', :numeric => '231' },
125
+ { :alpha2 => 'FK', :name => 'Falkland Islands (Malvinas)', :alpha3 => 'FLK', :numeric => '238' },
126
+ { :alpha2 => 'FO', :name => 'Faroe Islands', :alpha3 => 'FRO', :numeric => '234' },
127
+ { :alpha2 => 'FJ', :name => 'Fiji', :alpha3 => 'FJI', :numeric => '242' },
128
+ { :alpha2 => 'FI', :name => 'Finland', :alpha3 => 'FIN', :numeric => '246' },
129
+ { :alpha2 => 'FR', :name => 'France', :alpha3 => 'FRA', :numeric => '250' },
130
+ { :alpha2 => 'GF', :name => 'French Guiana', :alpha3 => 'GUF', :numeric => '254' },
131
+ { :alpha2 => 'PF', :name => 'French Polynesia', :alpha3 => 'PYF', :numeric => '258' },
132
+ { :alpha2 => 'TF', :name => 'French Southern Territories', :alpha3 => 'ATF', :numeric => '260' },
133
+ { :alpha2 => 'GA', :name => 'Gabon', :alpha3 => 'GAB', :numeric => '266' },
134
+ { :alpha2 => 'GM', :name => 'Gambia', :alpha3 => 'GMB', :numeric => '270' },
135
+ { :alpha2 => 'GE', :name => 'Georgia', :alpha3 => 'GEO', :numeric => '268' },
136
+ { :alpha2 => 'DE', :name => 'Germany', :alpha3 => 'DEU', :numeric => '276' },
137
+ { :alpha2 => 'GH', :name => 'Ghana', :alpha3 => 'GHA', :numeric => '288' },
138
+ { :alpha2 => 'GI', :name => 'Gibraltar', :alpha3 => 'GIB', :numeric => '292' },
139
+ { :alpha2 => 'GR', :name => 'Greece', :alpha3 => 'GRC', :numeric => '300' },
140
+ { :alpha2 => 'GL', :name => 'Greenland', :alpha3 => 'GRL', :numeric => '304' },
141
+ { :alpha2 => 'GD', :name => 'Grenada', :alpha3 => 'GRD', :numeric => '308' },
142
+ { :alpha2 => 'GP', :name => 'Guadeloupe', :alpha3 => 'GLP', :numeric => '312' },
143
+ { :alpha2 => 'GU', :name => 'Guam', :alpha3 => 'GUM', :numeric => '316' },
144
+ { :alpha2 => 'GT', :name => 'Guatemala', :alpha3 => 'GTM', :numeric => '320' },
145
+ { :alpha2 => 'GN', :name => 'Guinea', :alpha3 => 'GIN', :numeric => '324' },
146
+ { :alpha2 => 'GW', :name => 'Guinea-Bissau', :alpha3 => 'GNB', :numeric => '624' },
147
+ { :alpha2 => 'GY', :name => 'Guyana', :alpha3 => 'GUY', :numeric => '328' },
148
+ { :alpha2 => 'GG', :name => 'Guernsey', :alpha3 => 'GGY', :numeric => '831' },
149
+ { :alpha2 => 'HT', :name => 'Haiti', :alpha3 => 'HTI', :numeric => '332' },
150
+ { :alpha2 => 'VA', :name => 'Holy See (Vatican City State)', :alpha3 => 'VAT', :numeric => '336' },
151
+ { :alpha2 => 'HN', :name => 'Honduras', :alpha3 => 'HND', :numeric => '340' },
152
+ { :alpha2 => 'HK', :name => 'Hong Kong', :alpha3 => 'HKG', :numeric => '344' },
153
+ { :alpha2 => 'HM', :name => 'Heard Island And Mcdonald Islands', :alpha3 => 'HMD', :numeric => '334' },
154
+ { :alpha2 => 'HU', :name => 'Hungary', :alpha3 => 'HUN', :numeric => '348' },
155
+ { :alpha2 => 'IS', :name => 'Iceland', :alpha3 => 'ISL', :numeric => '352' },
156
+ { :alpha2 => 'IN', :name => 'India', :alpha3 => 'IND', :numeric => '356' },
157
+ { :alpha2 => 'ID', :name => 'Indonesia', :alpha3 => 'IDN', :numeric => '360' },
158
+ { :alpha2 => 'IR', :name => 'Iran, Islamic Republic of', :alpha3 => 'IRN', :numeric => '364' },
159
+ { :alpha2 => 'IQ', :name => 'Iraq', :alpha3 => 'IRQ', :numeric => '368' },
160
+ { :alpha2 => 'IE', :name => 'Ireland', :alpha3 => 'IRL', :numeric => '372' },
161
+ { :alpha2 => 'IM', :name => 'Isle Of Man', :alpha3 => 'IMN', :numeric => '833' },
162
+ { :alpha2 => 'IL', :name => 'Israel', :alpha3 => 'ISR', :numeric => '376' },
163
+ { :alpha2 => 'IT', :name => 'Italy', :alpha3 => 'ITA', :numeric => '380' },
164
+ { :alpha2 => 'JM', :name => 'Jamaica', :alpha3 => 'JAM', :numeric => '388' },
165
+ { :alpha2 => 'JP', :name => 'Japan', :alpha3 => 'JPN', :numeric => '392' },
166
+ { :alpha2 => 'JE', :name => 'Jersey', :alpha3 => 'JEY', :numeric => '832' },
167
+ { :alpha2 => 'JO', :name => 'Jordan', :alpha3 => 'JOR', :numeric => '400' },
168
+ { :alpha2 => 'KZ', :name => 'Kazakhstan', :alpha3 => 'KAZ', :numeric => '398' },
169
+ { :alpha2 => 'KE', :name => 'Kenya', :alpha3 => 'KEN', :numeric => '404' },
170
+ { :alpha2 => 'KI', :name => 'Kiribati', :alpha3 => 'KIR', :numeric => '296' },
171
+ { :alpha2 => 'KP', :name => 'Korea, Democratic People\'s Republic of', :alpha3 => 'PRK', :numeric => '408' },
172
+ { :alpha2 => 'KR', :name => 'Korea, Republic of', :alpha3 => 'KOR', :numeric => '410' },
173
+ { :alpha2 => 'KW', :name => 'Kuwait', :alpha3 => 'KWT', :numeric => '414' },
174
+ { :alpha2 => 'KG', :name => 'Kyrgyzstan', :alpha3 => 'KGZ', :numeric => '417' },
175
+ { :alpha2 => 'LA', :name => 'Lao People\'s Democratic Republic', :alpha3 => 'LAO', :numeric => '418' },
176
+ { :alpha2 => 'LV', :name => 'Latvia', :alpha3 => 'LVA', :numeric => '428' },
177
+ { :alpha2 => 'LB', :name => 'Lebanon', :alpha3 => 'LBN', :numeric => '422' },
178
+ { :alpha2 => 'LS', :name => 'Lesotho', :alpha3 => 'LSO', :numeric => '426' },
179
+ { :alpha2 => 'LR', :name => 'Liberia', :alpha3 => 'LBR', :numeric => '430' },
180
+ { :alpha2 => 'LY', :name => 'Libyan Arab Jamahiriya', :alpha3 => 'LBY', :numeric => '434' },
181
+ { :alpha2 => 'LI', :name => 'Liechtenstein', :alpha3 => 'LIE', :numeric => '438' },
182
+ { :alpha2 => 'LT', :name => 'Lithuania', :alpha3 => 'LTU', :numeric => '440' },
183
+ { :alpha2 => 'LU', :name => 'Luxembourg', :alpha3 => 'LUX', :numeric => '442' },
184
+ { :alpha2 => 'MO', :name => 'Macao', :alpha3 => 'MAC', :numeric => '446' },
185
+ { :alpha2 => 'MK', :name => 'Macedonia, the Former Yugoslav Republic of', :alpha3 => 'MKD', :numeric => '807' },
186
+ { :alpha2 => 'MG', :name => 'Madagascar', :alpha3 => 'MDG', :numeric => '450' },
187
+ { :alpha2 => 'MW', :name => 'Malawi', :alpha3 => 'MWI', :numeric => '454' },
188
+ { :alpha2 => 'MY', :name => 'Malaysia', :alpha3 => 'MYS', :numeric => '458' },
189
+ { :alpha2 => 'MV', :name => 'Maldives', :alpha3 => 'MDV', :numeric => '462' },
190
+ { :alpha2 => 'ML', :name => 'Mali', :alpha3 => 'MLI', :numeric => '466' },
191
+ { :alpha2 => 'MT', :name => 'Malta', :alpha3 => 'MLT', :numeric => '470' },
192
+ { :alpha2 => 'MH', :name => 'Marshall Islands', :alpha3 => 'MHL', :numeric => '584' },
193
+ { :alpha2 => 'MQ', :name => 'Martinique', :alpha3 => 'MTQ', :numeric => '474' },
194
+ { :alpha2 => 'MR', :name => 'Mauritania', :alpha3 => 'MRT', :numeric => '478' },
195
+ { :alpha2 => 'MU', :name => 'Mauritius', :alpha3 => 'MUS', :numeric => '480' },
196
+ { :alpha2 => 'YT', :name => 'Mayotte', :alpha3 => 'MYT', :numeric => '175' },
197
+ { :alpha2 => 'MX', :name => 'Mexico', :alpha3 => 'MEX', :numeric => '484' },
198
+ { :alpha2 => 'FM', :name => 'Micronesia, Federated States of', :alpha3 => 'FSM', :numeric => '583' },
199
+ { :alpha2 => 'MD', :name => 'Moldova, Republic of', :alpha3 => 'MDA', :numeric => '498' },
200
+ { :alpha2 => 'MC', :name => 'Monaco', :alpha3 => 'MCO', :numeric => '492' },
201
+ { :alpha2 => 'MN', :name => 'Mongolia', :alpha3 => 'MNG', :numeric => '496' },
202
+ { :alpha2 => 'ME', :name => 'Montenegro', :alpha3 => 'MNE', :numeric => '499' },
203
+ { :alpha2 => 'MS', :name => 'Montserrat', :alpha3 => 'MSR', :numeric => '500' },
204
+ { :alpha2 => 'MA', :name => 'Morocco', :alpha3 => 'MAR', :numeric => '504' },
205
+ { :alpha2 => 'MZ', :name => 'Mozambique', :alpha3 => 'MOZ', :numeric => '508' },
206
+ { :alpha2 => 'MM', :name => 'Myanmar', :alpha3 => 'MMR', :numeric => '104' },
207
+ { :alpha2 => 'NA', :name => 'Namibia', :alpha3 => 'NAM', :numeric => '516' },
208
+ { :alpha2 => 'NR', :name => 'Nauru', :alpha3 => 'NRU', :numeric => '520' },
209
+ { :alpha2 => 'NP', :name => 'Nepal', :alpha3 => 'NPL', :numeric => '524' },
210
+ { :alpha2 => 'NL', :name => 'Netherlands', :alpha3 => 'NLD', :numeric => '528' },
211
+ { :alpha2 => 'AN', :name => 'Netherlands Antilles', :alpha3 => 'ANT', :numeric => '530' },
212
+ { :alpha2 => 'NC', :name => 'New Caledonia', :alpha3 => 'NCL', :numeric => '540' },
213
+ { :alpha2 => 'NZ', :name => 'New Zealand', :alpha3 => 'NZL', :numeric => '554' },
214
+ { :alpha2 => 'NI', :name => 'Nicaragua', :alpha3 => 'NIC', :numeric => '558' },
215
+ { :alpha2 => 'NE', :name => 'Niger', :alpha3 => 'NER', :numeric => '562' },
216
+ { :alpha2 => 'NG', :name => 'Nigeria', :alpha3 => 'NGA', :numeric => '566' },
217
+ { :alpha2 => 'NU', :name => 'Niue', :alpha3 => 'NIU', :numeric => '570' },
218
+ { :alpha2 => 'NF', :name => 'Norfolk Island', :alpha3 => 'NFK', :numeric => '574' },
219
+ { :alpha2 => 'MP', :name => 'Northern Mariana Islands', :alpha3 => 'MNP', :numeric => '580' },
220
+ { :alpha2 => 'NO', :name => 'Norway', :alpha3 => 'NOR', :numeric => '578' },
221
+ { :alpha2 => 'OM', :name => 'Oman', :alpha3 => 'OMN', :numeric => '512' },
222
+ { :alpha2 => 'PK', :name => 'Pakistan', :alpha3 => 'PAK', :numeric => '586' },
223
+ { :alpha2 => 'PW', :name => 'Palau', :alpha3 => 'PLW', :numeric => '585' },
224
+ { :alpha2 => 'PS', :name => 'Palestinian Territory, Occupied', :alpha3 => 'PSE', :numeric => '275' },
225
+ { :alpha2 => 'PA', :name => 'Panama', :alpha3 => 'PAN', :numeric => '591' },
226
+ { :alpha2 => 'PG', :name => 'Papua New Guinea', :alpha3 => 'PNG', :numeric => '598' },
227
+ { :alpha2 => 'PY', :name => 'Paraguay', :alpha3 => 'PRY', :numeric => '600' },
228
+ { :alpha2 => 'PE', :name => 'Peru', :alpha3 => 'PER', :numeric => '604' },
229
+ { :alpha2 => 'PH', :name => 'Philippines', :alpha3 => 'PHL', :numeric => '608' },
230
+ { :alpha2 => 'PN', :name => 'Pitcairn', :alpha3 => 'PCN', :numeric => '612' },
231
+ { :alpha2 => 'PL', :name => 'Poland', :alpha3 => 'POL', :numeric => '616' },
232
+ { :alpha2 => 'PT', :name => 'Portugal', :alpha3 => 'PRT', :numeric => '620' },
233
+ { :alpha2 => 'PR', :name => 'Puerto Rico', :alpha3 => 'PRI', :numeric => '630' },
234
+ { :alpha2 => 'QA', :name => 'Qatar', :alpha3 => 'QAT', :numeric => '634' },
235
+ { :alpha2 => 'RE', :name => 'Reunion', :alpha3 => 'REU', :numeric => '638' },
236
+ { :alpha2 => 'RO', :name => 'Romania', :alpha3 => 'ROM', :numeric => '642' },
237
+ { :alpha2 => 'RU', :name => 'Russian Federation', :alpha3 => 'RUS', :numeric => '643' },
238
+ { :alpha2 => 'RW', :name => 'Rwanda', :alpha3 => 'RWA', :numeric => '646' },
239
+ { :alpha2 => 'BL', :name => 'Saint Barthélemy', :alpha3 => 'BLM', :numeric => '652' },
240
+ { :alpha2 => 'SH', :name => 'Saint Helena', :alpha3 => 'SHN', :numeric => '654' },
241
+ { :alpha2 => 'KN', :name => 'Saint Kitts and Nevis', :alpha3 => 'KNA', :numeric => '659' },
242
+ { :alpha2 => 'LC', :name => 'Saint Lucia', :alpha3 => 'LCA', :numeric => '662' },
243
+ { :alpha2 => 'MF', :name => 'Saint Martin (French part)', :alpha3 => 'MAF', :numeric => '663' },
244
+ { :alpha2 => 'PM', :name => 'Saint Pierre and Miquelon', :alpha3 => 'SPM', :numeric => '666' },
245
+ { :alpha2 => 'VC', :name => 'Saint Vincent and the Grenadines', :alpha3 => 'VCT', :numeric => '670' },
246
+ { :alpha2 => 'WS', :name => 'Samoa', :alpha3 => 'WSM', :numeric => '882' },
247
+ { :alpha2 => 'SM', :name => 'San Marino', :alpha3 => 'SMR', :numeric => '674' },
248
+ { :alpha2 => 'ST', :name => 'Sao Tome and Principe', :alpha3 => 'STP', :numeric => '678' },
249
+ { :alpha2 => 'SA', :name => 'Saudi Arabia', :alpha3 => 'SAU', :numeric => '682' },
250
+ { :alpha2 => 'SN', :name => 'Senegal', :alpha3 => 'SEN', :numeric => '686' },
251
+ { :alpha2 => 'RS', :name => 'Serbia', :alpha3 => 'SRB', :numeric => '688' },
252
+ { :alpha2 => 'SC', :name => 'Seychelles', :alpha3 => 'SYC', :numeric => '690' },
253
+ { :alpha2 => 'SL', :name => 'Sierra Leone', :alpha3 => 'SLE', :numeric => '694' },
254
+ { :alpha2 => 'SG', :name => 'Singapore', :alpha3 => 'SGP', :numeric => '702' },
255
+ { :alpha2 => 'SK', :name => 'Slovakia', :alpha3 => 'SVK', :numeric => '703' },
256
+ { :alpha2 => 'SI', :name => 'Slovenia', :alpha3 => 'SVN', :numeric => '705' },
257
+ { :alpha2 => 'SB', :name => 'Solomon Islands', :alpha3 => 'SLB', :numeric => '090' },
258
+ { :alpha2 => 'SO', :name => 'Somalia', :alpha3 => 'SOM', :numeric => '706' },
259
+ { :alpha2 => 'ZA', :name => 'South Africa', :alpha3 => 'ZAF', :numeric => '710' },
260
+ { :alpha2 => 'GS', :name => 'South Georgia and the South Sandwich Islands', :alpha3 => 'SGS', :numeric => '239' },
261
+ { :alpha2 => 'ES', :name => 'Spain', :alpha3 => 'ESP', :numeric => '724' },
262
+ { :alpha2 => 'LK', :name => 'Sri Lanka', :alpha3 => 'LKA', :numeric => '144' },
263
+ { :alpha2 => 'SD', :name => 'Sudan', :alpha3 => 'SDN', :numeric => '736' },
264
+ { :alpha2 => 'SR', :name => 'Suriname', :alpha3 => 'SUR', :numeric => '740' },
265
+ { :alpha2 => 'SJ', :name => 'Svalbard and Jan Mayen', :alpha3 => 'SJM', :numeric => '744' },
266
+ { :alpha2 => 'SZ', :name => 'Swaziland', :alpha3 => 'SWZ', :numeric => '748' },
267
+ { :alpha2 => 'SE', :name => 'Sweden', :alpha3 => 'SWE', :numeric => '752' },
268
+ { :alpha2 => 'CH', :name => 'Switzerland', :alpha3 => 'CHE', :numeric => '756' },
269
+ { :alpha2 => 'SY', :name => 'Syrian Arab Republic', :alpha3 => 'SYR', :numeric => '760' },
270
+ { :alpha2 => 'TW', :name => 'Taiwan, Province of China', :alpha3 => 'TWN', :numeric => '158' },
271
+ { :alpha2 => 'TJ', :name => 'Tajikistan', :alpha3 => 'TJK', :numeric => '762' },
272
+ { :alpha2 => 'TZ', :name => 'Tanzania, United Republic of', :alpha3 => 'TZA', :numeric => '834' },
273
+ { :alpha2 => 'TH', :name => 'Thailand', :alpha3 => 'THA', :numeric => '764' },
274
+ { :alpha2 => 'TL', :name => 'Timor Leste', :alpha3 => 'TLS', :numeric => '626' },
275
+ { :alpha2 => 'TG', :name => 'Togo', :alpha3 => 'TGO', :numeric => '768' },
276
+ { :alpha2 => 'TK', :name => 'Tokelau', :alpha3 => 'TKL', :numeric => '772' },
277
+ { :alpha2 => 'TO', :name => 'Tonga', :alpha3 => 'TON', :numeric => '776' },
278
+ { :alpha2 => 'TT', :name => 'Trinidad and Tobago', :alpha3 => 'TTO', :numeric => '780' },
279
+ { :alpha2 => 'TN', :name => 'Tunisia', :alpha3 => 'TUN', :numeric => '788' },
280
+ { :alpha2 => 'TR', :name => 'Turkey', :alpha3 => 'TUR', :numeric => '792' },
281
+ { :alpha2 => 'TM', :name => 'Turkmenistan', :alpha3 => 'TKM', :numeric => '795' },
282
+ { :alpha2 => 'TC', :name => 'Turks and Caicos Islands', :alpha3 => 'TCA', :numeric => '796' },
283
+ { :alpha2 => 'TV', :name => 'Tuvalu', :alpha3 => 'TUV', :numeric => '798' },
284
+ { :alpha2 => 'UG', :name => 'Uganda', :alpha3 => 'UGA', :numeric => '800' },
285
+ { :alpha2 => 'UA', :name => 'Ukraine', :alpha3 => 'UKR', :numeric => '804' },
286
+ { :alpha2 => 'AE', :name => 'United Arab Emirates', :alpha3 => 'ARE', :numeric => '784' },
287
+ { :alpha2 => 'GB', :name => 'United Kingdom', :alpha3 => 'GBR', :numeric => '826' },
288
+ { :alpha2 => 'US', :name => 'United States', :alpha3 => 'USA', :numeric => '840' },
289
+ { :alpha2 => 'UM', :name => 'United States Minor Outlying Islands', :alpha3 => 'UMI', :numeric => '581' },
290
+ { :alpha2 => 'UY', :name => 'Uruguay', :alpha3 => 'URY', :numeric => '858' },
291
+ { :alpha2 => 'UZ', :name => 'Uzbekistan', :alpha3 => 'UZB', :numeric => '860' },
292
+ { :alpha2 => 'VU', :name => 'Vanuatu', :alpha3 => 'VUT', :numeric => '548' },
293
+ { :alpha2 => 'VE', :name => 'Venezuela', :alpha3 => 'VEN', :numeric => '862' },
294
+ { :alpha2 => 'VN', :name => 'Viet Nam', :alpha3 => 'VNM', :numeric => '704' },
295
+ { :alpha2 => 'VG', :name => 'Virgin Islands, British', :alpha3 => 'VGB', :numeric => '092' },
296
+ { :alpha2 => 'VI', :name => 'Virgin Islands, U.S.', :alpha3 => 'VIR', :numeric => '850' },
297
+ { :alpha2 => 'WF', :name => 'Wallis and Futuna', :alpha3 => 'WLF', :numeric => '876' },
298
+ { :alpha2 => 'EH', :name => 'Western Sahara', :alpha3 => 'ESH', :numeric => '732' },
299
+ { :alpha2 => 'YE', :name => 'Yemen', :alpha3 => 'YEM', :numeric => '887' },
300
+ { :alpha2 => 'ZM', :name => 'Zambia', :alpha3 => 'ZMB', :numeric => '894' },
301
+ { :alpha2 => 'ZW', :name => 'Zimbabwe', :alpha3 => 'ZWE', :numeric => '716' }
302
+ ]
303
+
304
+ def self.find(name)
305
+ raise InvalidCountryCodeError, "Cannot lookup country for an empty name" if name.blank?
306
+
307
+ case name.length
308
+ when 2, 3
309
+ upcase_name = name.upcase
310
+ country_code = CountryCode.new(name)
311
+ country = COUNTRIES.detect{|c| c[country_code.format] == upcase_name }
312
+ else
313
+ country = COUNTRIES.detect{|c| c[:name] == name }
314
+ end
315
+ raise InvalidCountryCodeError, "No country could be found for the country #{name}" if country.nil?
316
+ Country.new(country.dup)
317
+ end
318
+ end
319
+ end
@@ -0,0 +1,26 @@
1
+ module ActiveMerchant #:nodoc:
2
+ class ActiveMerchantError < StandardError #:nodoc:
3
+ end
4
+
5
+ class ConnectionError < ActiveMerchantError # :nodoc:
6
+ end
7
+
8
+ class RetriableConnectionError < ConnectionError # :nodoc:
9
+ end
10
+
11
+ class ResponseError < ActiveMerchantError # :nodoc:
12
+ attr_reader :response
13
+
14
+ def initialize(response, message = nil)
15
+ @response = response
16
+ @message = message
17
+ end
18
+
19
+ def to_s
20
+ "Failed with #{response.code} #{response.message if response.respond_to?(:message)}"
21
+ end
22
+ end
23
+
24
+ class ClientCertificateError < ActiveMerchantError # :nodoc
25
+ end
26
+ end
@@ -0,0 +1,24 @@
1
+ require 'cgi'
2
+
3
+ module ActiveMerchant
4
+ class PostData < Hash
5
+ class_inheritable_accessor :required_fields, :instance_writer => false
6
+ self.required_fields = []
7
+
8
+ def []=(key, value)
9
+ return if value.blank? && !required?(key)
10
+ super
11
+ end
12
+
13
+ def to_post_data
14
+ collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
15
+ end
16
+
17
+ alias_method :to_s, :to_post_data
18
+
19
+ private
20
+ def required?(key)
21
+ required_fields.include?(key)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,47 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module PostsData #:nodoc:
3
+
4
+ def self.included(base)
5
+ base.superclass_delegating_accessor :ssl_strict
6
+ base.ssl_strict = true
7
+
8
+ base.class_inheritable_accessor :retry_safe
9
+ base.retry_safe = false
10
+
11
+ base.superclass_delegating_accessor :open_timeout
12
+ base.open_timeout = 60
13
+
14
+ base.superclass_delegating_accessor :read_timeout
15
+ base.read_timeout = 60
16
+
17
+ base.superclass_delegating_accessor :logger
18
+ base.superclass_delegating_accessor :wiredump_device
19
+ end
20
+
21
+ def ssl_get(endpoint, headers={})
22
+ ssl_request(:get, endpoint, nil, headers)
23
+ end
24
+
25
+ def ssl_post(endpoint, data, headers = {})
26
+ ssl_request(:post, endpoint, data, headers)
27
+ end
28
+
29
+ private
30
+ def ssl_request(method, endpoint, data, headers = {})
31
+ connection = Connection.new(endpoint)
32
+ connection.open_timeout = open_timeout
33
+ connection.read_timeout = read_timeout
34
+ connection.retry_safe = retry_safe
35
+ connection.verify_peer = ssl_strict
36
+ connection.logger = logger
37
+ connection.tag = self.class.name
38
+ connection.wiredump_device = wiredump_device
39
+
40
+ connection.pem = @options[:pem] if @options
41
+ connection.pem_password = @options[:pem_password] if @options
42
+
43
+ connection.request(method, data, headers)
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,16 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module RequiresParameters #:nodoc:
3
+ def requires!(hash, *params)
4
+ params.each do |param|
5
+ if param.is_a?(Array)
6
+ raise ArgumentError.new("Missing required parameter: #{param.first}") unless hash.has_key?(param.first)
7
+
8
+ valid_options = param[1..-1]
9
+ raise ArgumentError.new("Parameter: #{param.first} must be one of #{valid_options.to_sentence(:words_connector => 'or')}") unless valid_options.include?(hash[param.first])
10
+ else
11
+ raise ArgumentError.new("Missing required parameter: #{param}") unless hash.has_key?(param)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ require 'digest/md5'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Utils #:nodoc:
5
+ def generate_unique_id
6
+ md5 = Digest::MD5.new
7
+ now = Time.now
8
+ md5 << now.to_s
9
+ md5 << String(now.usec)
10
+ md5 << String(rand(0))
11
+ md5 << String($$)
12
+ md5 << self.class.name
13
+ md5.hexdigest
14
+ end
15
+
16
+ module_function :generate_unique_id
17
+ end
18
+ end
@@ -0,0 +1,76 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Validateable #:nodoc:
3
+ def valid?
4
+ errors.clear
5
+
6
+ before_validate if respond_to?(:before_validate, true)
7
+ validate if respond_to?(:validate, true)
8
+
9
+ errors.empty?
10
+ end
11
+
12
+ def initialize(attributes = {})
13
+ self.attributes = attributes
14
+ end
15
+
16
+ def errors
17
+ @errors ||= Errors.new(self)
18
+ end
19
+
20
+ private
21
+
22
+ def attributes=(attributes)
23
+ unless attributes.nil?
24
+ for key, value in attributes
25
+ send("#{key}=", value )
26
+ end
27
+ end
28
+ end
29
+
30
+ # This hash keeps the errors of the object
31
+ class Errors < HashWithIndifferentAccess
32
+
33
+ def initialize(base)
34
+ @base = base
35
+ end
36
+
37
+ def count
38
+ size
39
+ end
40
+
41
+ # returns a specific fields error message.
42
+ # if more than one error is available we will only return the first. If no error is available
43
+ # we return an empty string
44
+ def on(field)
45
+ self[field].to_a.first
46
+ end
47
+
48
+ def add(field, error)
49
+ self[field] ||= []
50
+ self[field] << error
51
+ end
52
+
53
+ def add_to_base(error)
54
+ add(:base, error)
55
+ end
56
+
57
+ def each_full
58
+ full_messages.each { |msg| yield msg }
59
+ end
60
+
61
+ def full_messages
62
+ result = []
63
+
64
+ self.each do |key, messages|
65
+ if key == 'base'
66
+ result << "#{messages.first}"
67
+ else
68
+ result << "#{key.to_s.humanize} #{messages.first}"
69
+ end
70
+ end
71
+
72
+ result
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,14 @@
1
+ module ActiveMerchant
2
+ autoload :Connection, 'active_merchant/common/connection'
3
+ autoload :Country, 'active_merchant/common/country'
4
+ autoload :ActiveMerchantError, 'active_merchant/common/error'
5
+ autoload :ConnectionError, 'active_merchant/common/error'
6
+ autoload :RetriableConnectionError, 'active_merchant/common/error'
7
+ autoload :ResponseError, 'active_merchant/common/error'
8
+ autoload :ClientCertificateError, 'active_merchant/common/error'
9
+ autoload :PostData, 'active_merchant/common/post_data'
10
+ autoload :PostsData, 'active_merchant/common/posts_data'
11
+ autoload :RequiresParameters, 'active_merchant/common/requires_parameters'
12
+ autoload :Utils, 'active_merchant/common/utils'
13
+ autoload :Validateable, 'active_merchant/common/validateable'
14
+ end
@@ -0,0 +1,38 @@
1
+ #--
2
+ # Copyright (c) 2005-2010 Tobias Luetke
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+
24
+ $:.unshift File.dirname(__FILE__)
25
+
26
+ require 'active_support'
27
+ require 'builder'
28
+ require 'cgi'
29
+ require 'rexml/document'
30
+
31
+ require 'active_merchant/common'
32
+ require 'active_merchant/billing'
33
+
34
+ module ActiveMerchant #:nodoc:
35
+ module Billing #:nodoc:
36
+ autoload :Integrations, 'active_merchant/billing/integrations'
37
+ end
38
+ end
@@ -0,0 +1 @@
1
+ require 'active_merchant'