promise_pay 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4373889188b8b2e732056ea576cac6f99f6555a3
4
- data.tar.gz: 1c6d260ac346d047c2c5268cf627651b8b874bb8
3
+ metadata.gz: 11cc8172e38524f490b7439bfe2eba1d12457bbf
4
+ data.tar.gz: 91413d34c70ac75ac3372378506f563fe1d28c9f
5
5
  SHA512:
6
- metadata.gz: 2ebd242425d43e05f54da87d5a8cc0662f48db1b80c30a03aaa7b0d4ef5ba0dc728d219e9c949dab44cc978c35c52d285372ee1f15fb2bf0707ef902dc83da6e
7
- data.tar.gz: bf7ae8865690dfa07f2f59fd3f7cd7618db48595215eae4455acbd913fe5b6c2cf0ae37b1ee5caa26d1d8214e5a3eee18d9b2b09a111d7753d6f7de5dfc44b94
6
+ metadata.gz: a30a2e9ae6654d0694f5349044c19c088cd4b2709ffe216bb61be21ef043ef37cea5cfe281df5e0b75a71a42356b3ad14779d95931dd47b0627c55d46297edb6
7
+ data.tar.gz: 73977a309758002e9237039226586195cdd8482d37f95343f9c79c259a428d97a0e5e969858a18030351da498b0b52b24c3ed1075028c1373ade07e62bd75010
@@ -0,0 +1,250 @@
1
+ module PromisePay
2
+ class Country
3
+ MAP = {
4
+ 'AF' => 'AFG',
5
+ 'AL' => 'ALB',
6
+ 'DZ' => 'DZA',
7
+ 'AS' => 'ASM',
8
+ 'AD' => 'AND',
9
+ 'AO' => 'AGO',
10
+ 'AI' => 'AIA',
11
+ 'AQ' => 'ATA',
12
+ 'AG' => 'ATG',
13
+ 'AR' => 'ARG',
14
+ 'AM' => 'ARM',
15
+ 'AW' => 'ABW',
16
+ 'AU' => 'AUS',
17
+ 'AT' => 'AUT',
18
+ 'AZ' => 'AZE',
19
+ 'BS' => 'BHS',
20
+ 'BH' => 'BHR',
21
+ 'BD' => 'BGD',
22
+ 'BB' => 'BRB',
23
+ 'BY' => 'BLR',
24
+ 'BE' => 'BEL',
25
+ 'BZ' => 'BLZ',
26
+ 'BJ' => 'BEN',
27
+ 'BM' => 'BMU',
28
+ 'BT' => 'BTN',
29
+ 'BO' => 'BOL',
30
+ 'BA' => 'BIH',
31
+ 'BW' => 'BWA',
32
+ 'BR' => 'BRA',
33
+ 'IO' => 'IOT',
34
+ 'VG' => 'BVN',
35
+ 'BN' => 'BRN',
36
+ 'BG' => 'BGR',
37
+ 'BF' => 'BFA',
38
+ 'BI' => 'BDI',
39
+ 'KH' => 'KHM',
40
+ 'CM' => 'CMR',
41
+ 'CA' => 'CAN',
42
+ 'IC' => 'CNR',
43
+ 'CV' => 'CPV',
44
+ 'KY' => 'CYM',
45
+ 'CF' => 'CAF',
46
+ 'TD' => 'TCD',
47
+ 'CL' => 'CHL',
48
+ 'CN' => 'CHN',
49
+ 'CX' => 'CXR',
50
+ 'CC' => 'CCK',
51
+ 'CO' => 'COL',
52
+ 'KM' => 'COM',
53
+ 'CD' => 'COD',
54
+ 'CG' => 'COG',
55
+ 'CK' => 'COK',
56
+ 'CR' => 'CRI',
57
+ 'CI' => 'CIV',
58
+ 'HR' => 'HRV',
59
+ 'CU' => 'CUB',
60
+ 'CY' => 'CYP',
61
+ 'CZ' => 'CZE',
62
+ 'DK' => 'DNK',
63
+ 'DJ' => 'DJI',
64
+ 'DM' => 'DMA',
65
+ 'DO' => 'DOM',
66
+ 'EC' => 'ECU',
67
+ 'EG' => 'EGY',
68
+ 'SV' => 'SLV',
69
+ 'GQ' => 'GNQ',
70
+ 'ER' => 'ERI',
71
+ 'EE' => 'EST',
72
+ 'ET' => 'ETH',
73
+ 'FO' => 'FRO',
74
+ 'FK' => 'FLK',
75
+ 'FJ' => 'FJI',
76
+ 'FI' => 'FIN',
77
+ 'FR' => 'FRA',
78
+ 'GF' => 'GUF',
79
+ 'PF' => 'PYF',
80
+ 'GA' => 'GAB',
81
+ 'GM' => 'GMB',
82
+ 'GE' => 'GEO',
83
+ 'DE' => 'DEU',
84
+ 'GH' => 'GHA',
85
+ 'GI' => 'GIB',
86
+ 'GR' => 'GRC',
87
+ 'GL' => 'GRL',
88
+ 'GD' => 'GRD',
89
+ 'GP' => 'GLP',
90
+ 'GU' => 'GUM',
91
+ 'GT' => 'GTM',
92
+ 'GG' => 'GGY',
93
+ 'GN' => 'GIN',
94
+ 'GW' => 'GNB',
95
+ 'GY' => 'GUY',
96
+ 'HT' => 'HTI',
97
+ 'VA' => 'VAT',
98
+ 'HN' => 'HND',
99
+ 'HK' => 'HKG',
100
+ 'HR' => 'HRV',
101
+ 'HU' => 'HUN',
102
+ 'IS' => 'ISL',
103
+ 'IN' => 'IND',
104
+ 'ID' => 'IDN',
105
+ 'IR' => 'IRN',
106
+ 'IQ' => 'IRQ',
107
+ 'IE' => 'IRL',
108
+ 'IM' => 'IMN',
109
+ 'IL' => 'ISR',
110
+ 'IT' => 'ITA',
111
+ 'JM' => 'JAM',
112
+ 'JP' => 'JPN',
113
+ 'JE' => 'JEY',
114
+ 'JO' => 'JOR',
115
+ 'KZ' => 'KAZ',
116
+ 'KE' => 'KEN',
117
+ 'KI' => 'KIR',
118
+ 'KP' => 'PRK',
119
+ 'KR' => 'KOR',
120
+ 'KW' => 'KWT',
121
+ 'KG' => 'KGZ',
122
+ 'LA' => 'LAO',
123
+ 'LV' => 'LVA',
124
+ 'LB' => 'LBN',
125
+ 'LS' => 'LSO',
126
+ 'LR' => 'LBR',
127
+ 'LY' => 'LBY',
128
+ 'LI' => 'LIE',
129
+ 'LT' => 'LTU',
130
+ 'LU' => 'LUX',
131
+ 'MO' => 'MAC',
132
+ 'MK' => 'MKD',
133
+ 'MG' => 'MDG',
134
+ 'MW' => 'MWI',
135
+ 'MY' => 'MYS',
136
+ 'MV' => 'MDV',
137
+ 'ML' => 'MLI',
138
+ 'MT' => 'MLT',
139
+ 'MH' => 'MHL',
140
+ 'MQ' => 'MTQ',
141
+ 'MR' => 'MRT',
142
+ 'MU' => 'MUS',
143
+ 'YT' => 'MYT',
144
+ 'MX' => 'MEX',
145
+ 'FM' => 'FSM',
146
+ 'MD' => 'MDA',
147
+ 'MC' => 'MCO',
148
+ 'MN' => 'MNG',
149
+ 'MS' => 'MSR',
150
+ 'MA' => 'MAR',
151
+ 'MZ' => 'MOZ',
152
+ 'MM' => 'MMR',
153
+ 'NA' => 'NAM',
154
+ 'NR' => 'NRU',
155
+ 'NP' => 'NPL',
156
+ 'AN' => 'ATN',
157
+ 'NL' => 'NLD',
158
+ 'NC' => 'NCL',
159
+ 'NZ' => 'NZL',
160
+ 'NI' => 'NIC',
161
+ 'NE' => 'NER',
162
+ 'NG' => 'NGA',
163
+ 'NU' => 'NIU',
164
+ 'NF' => 'NFK',
165
+ 'MP' => 'MNP',
166
+ 'NO' => 'NOR',
167
+ 'OM' => 'OMN',
168
+ 'PK' => 'PAK',
169
+ 'PW' => 'PLW',
170
+ 'PS' => 'PSE',
171
+ 'PA' => 'PAN',
172
+ 'PG' => 'PNG',
173
+ 'PY' => 'PRY',
174
+ 'PE' => 'PER',
175
+ 'PH' => 'PHL',
176
+ 'PL' => 'POL',
177
+ 'PT' => 'PRT',
178
+ 'PR' => 'PRI',
179
+ 'QA' => 'QAT',
180
+ 'RE' => 'REU',
181
+ 'RO' => 'ROU',
182
+ 'RU' => 'RUS',
183
+ 'RW' => 'RWA',
184
+ 'SH' => 'SHN',
185
+ 'KN' => 'KNA',
186
+ 'LC' => 'LCA',
187
+ 'PM' => 'SPM',
188
+ 'VC' => 'VCT',
189
+ 'WS' => 'WSM',
190
+ 'SM' => 'SMR',
191
+ 'ST' => 'STP',
192
+ 'SA' => 'SAU',
193
+ 'SN' => 'SEN',
194
+ 'RS' => 'SRB',
195
+ 'ME' => 'MNE',
196
+ 'SC' => 'SYC',
197
+ 'SL' => 'SLE',
198
+ 'SG' => 'SGP',
199
+ 'SX' => 'SXM',
200
+ 'SI' => 'SVN',
201
+ 'SB' => 'SLB',
202
+ 'SO' => 'SOM',
203
+ 'ZA' => 'ZAF',
204
+ 'ES' => 'ESP',
205
+ 'LK' => 'LKA',
206
+ 'SD' => 'SDN',
207
+ 'SR' => 'SUR',
208
+ 'SJ' => 'SJM',
209
+ 'SZ' => 'SWZ',
210
+ 'SE' => 'SWE',
211
+ 'CH' => 'CHE',
212
+ 'SY' => 'SYR',
213
+ 'TW' => 'TWN',
214
+ 'TJ' => 'TJK',
215
+ 'TZ' => 'TZA',
216
+ 'TH' => 'THA',
217
+ 'TL' => 'TLS',
218
+ 'TG' => 'TGO',
219
+ 'TK' => 'TKL',
220
+ 'TO' => 'TON',
221
+ 'TT' => 'TTO',
222
+ 'TN' => 'TUN',
223
+ 'TR' => 'TUR',
224
+ 'TM' => 'TKM',
225
+ 'TC' => 'TCA',
226
+ 'TV' => 'TUV',
227
+ 'VI' => 'VIR',
228
+ 'UG' => 'UGA',
229
+ 'UA' => 'UKR',
230
+ 'AE' => 'ARE',
231
+ 'GB' => 'GBR',
232
+ 'UM' => 'UMI',
233
+ 'US' => 'USA',
234
+ 'UY' => 'URY',
235
+ 'UZ' => 'UZB',
236
+ 'VU' => 'VUT',
237
+ 'VE' => 'VEN',
238
+ 'VN' => 'VNM',
239
+ 'WF' => 'WLF',
240
+ 'EH' => 'ESH',
241
+ 'YE' => 'YEM',
242
+ 'ZM' => 'ZMB',
243
+ 'ZW' => 'ZWE'
244
+ }
245
+
246
+ def self.code_for(code)
247
+ MAP[code] || code
248
+ end
249
+ end
250
+ end
@@ -73,8 +73,8 @@ module PromisePay
73
73
  external_buyer_id: external_buyer_id,
74
74
  fee_ids: fee_ids,
75
75
  payment_type_id: payment_type_id,
76
- seller_country: seller_country,
77
- buyer_country: buyer_country
76
+ seller_country: PromisePay::Country.code_for(seller_country),
77
+ buyer_country: PromisePay::Country.code_for(buyer_country)
78
78
  }.reject { |k,v| v.nil? }.to_param
79
79
  end
80
80
 
@@ -1,3 +1,3 @@
1
1
  module PromisePay
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/promise_pay.rb CHANGED
@@ -5,6 +5,7 @@ require "promise_pay/session"
5
5
  require "promise_pay/user"
6
6
  require "promise_pay/version"
7
7
  require "promise_pay/collection"
8
+ require "promise_pay/country"
8
9
 
9
10
  module PromisePay
10
11
  API_HOST = "https://secure.api.promisepay.com/"
@@ -0,0 +1,11 @@
1
+ require "spec_helper"
2
+
3
+ describe PromisePay::Country do
4
+ it "converts a two letter country code to three letters" do
5
+ expect(PromisePay::Country.code_for('AU')).to eq 'AUS'
6
+ end
7
+
8
+ it "leaves three letter codes unchanged" do
9
+ expect(PromisePay::Country.code_for('BEL')).to eq 'BEL'
10
+ end
11
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: promise_pay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liam Norton
@@ -82,6 +82,7 @@ files:
82
82
  - lib/generators/templates/promise_pay_initializer.rb
83
83
  - lib/promise_pay.rb
84
84
  - lib/promise_pay/collection.rb
85
+ - lib/promise_pay/country.rb
85
86
  - lib/promise_pay/item.rb
86
87
  - lib/promise_pay/lib/dynamic_accessors.rb
87
88
  - lib/promise_pay/marketplace.rb
@@ -90,6 +91,7 @@ files:
90
91
  - lib/promise_pay/user.rb
91
92
  - lib/promise_pay/version.rb
92
93
  - promise_pay.gemspec
94
+ - spec/promise_pay/country_spec.rb
93
95
  - spec/promise_pay/item_spec.rb
94
96
  - spec/promise_pay/marketplace_spec.rb
95
97
  - spec/promise_pay/request_spec.rb
@@ -126,6 +128,7 @@ signing_key:
126
128
  specification_version: 4
127
129
  summary: PromisePay gem
128
130
  test_files:
131
+ - spec/promise_pay/country_spec.rb
129
132
  - spec/promise_pay/item_spec.rb
130
133
  - spec/promise_pay/marketplace_spec.rb
131
134
  - spec/promise_pay/request_spec.rb