nfg-client 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDhhZGYxODA1OTNjMTcwNWJiMDVjMzUwOTE5NTgzNzEwOGQ3NDY5Mg==
4
+ YzY4OGY4MGQ0ZTRhY2FkYzQ5NTU0MTdlODE3YWY1YjkwOWViM2JiNw==
5
5
  data.tar.gz: !binary |-
6
- ZmVjOTFiMWM5ZTA2NGQwMzc5NjNmYWZjNTBlYjllYjlkNDllNmNlMw==
6
+ MWZkMzFiZTQ0N2E4ZGYxN2VhMjI0NmJjN2Y5MmY4M2NhODJmMGE4ZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OTU5ZjhlZTQ1NGNlNDNiNDY0MDI1OTI2ODA1N2JhZDk5NGJlNzgxYWQ0Njgy
10
- YzRlZGRlOWY0MjA0MmMyYTY4MGE1NDg4ZTk3NmJmNjQ5ODA5MTg3M2U4OThl
11
- ODYyODRlNGNjNjQ1ZGI3MjJkZTc0ZGEwNmExZjhiMzBhMzA4YmE=
9
+ MTZhOGFkMTZlMjM0MThhY2EyNzgzMTMzZTQyYTgyYTU5YWJiNDg4Mzk1OWY0
10
+ N2MwYzhhZjBlNWQ0YjNlYTkxMzA5NGFjMmQ1N2FiZDJkZjNjZDg5MDYwMzE5
11
+ NjRlZDQwZjJjZmJhMTYxMGFlMTY5YzQ2MWVjZDU0YTc4MjJlNTk=
12
12
  data.tar.gz: !binary |-
13
- ODc3MTViZmU1YzBmNzI2NjMwMGVhNWQ5OGRkNzg0MTliNzcyYjc2N2M1NzM2
14
- ZTczOTMzYWE1YzQyNTgyNzA0MGE4ODMyMGFiNzc1ZjMxNGNhYmJmZTE1OGVm
15
- NTM3NWY3MzAxMTFmZjNjOTA2ZDY2NGJjMDQ0Yjg4ZTk4ZWU2Mzc=
13
+ NDBmOTJkMjA1OWE4NjU3NTVjZDdmNDNmYzQ2NWMyZGIyNGQ5NjBjNjYzZThi
14
+ Yjc5OGJhOWExM2YxNGE4YmFmNThhYzM5MmY4YjkyNDZlMzI4ZTI5MTljYjZi
15
+ YzEwZDhjNjAzMDZmZDVkNDhhMGM2NzBkNTFmYmM1MDQxNTZkNWM=
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2014 Antonio Ruano Cuesta
3
+ Copyright (c) 2014 by Antonio Ruano Cuesta
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -358,3 +358,13 @@ When a call fails (i.e. the "StatusCode" is different than "Success"), it's usua
358
358
  "CallDuration" => "x.x",
359
359
  ...
360
360
  }
361
+
362
+ # Contributors
363
+
364
+ Special thanks to:
365
+
366
+ - [Tom Hoen](https://github.com/hoenth), for the addition of the test suite and code refactoring.
367
+
368
+ # Copyright
369
+
370
+ Copyright (c) 2014 by [Antonio Ruano Cuesta](https://github.com/aruanoc). See [LICENSE](https://github.com/aruanoc/nfg-client/blob/master/LICENSE.md) for details.
data/Rakefile CHANGED
@@ -6,3 +6,9 @@ RSpec::Core::RakeTask.new(:spec)
6
6
 
7
7
  desc 'Default: run specs.'
8
8
  task :default => :spec
9
+
10
+
11
+ desc "Open an irb session preloaded with this library"
12
+ task :console do
13
+ sh "irb -rubygems -I lib -r nfg-client.rb"
14
+ end
@@ -20,8 +20,9 @@ module NFGClient
20
20
  # Arguments:
21
21
  # params: (Hash)
22
22
  def create_cof(params)
23
+ requires!(params, :DonorToken, :DonorFirstName, :DonorLastName, :DonorEmail, :DonorAddress1, :DonorAddress2, :DonorCity, :DonorState, :DonorZip, :DonorCountry, :DonorPhone, :CardType, :NameOnCard, :CardNumber, :ExpMonth, :ExpYear, :CSC)
23
24
  call_params = add_credentials_to_params(params)
24
- response = nfg_soap_request('CreateCOF', call_params, @use_sandbox)
25
+ response = nfg_soap_request('CreateCOF', call_params)
25
26
  if response.is_a? REXML::Element
26
27
  {
27
28
  'StatusCode' => response.elements['StatusCode'].get_text.to_s,
@@ -41,8 +42,9 @@ module NFGClient
41
42
  # Arguments:
42
43
  # params: (Hash)
43
44
  def delete_donor_cof(params)
45
+ requires!(params, :DonorToken, :COFId)
44
46
  call_params = add_credentials_to_params(params)
45
- response = nfg_soap_request('DeleteDonorCOF', call_params, @use_sandbox)
47
+ response = nfg_soap_request('DeleteDonorCOF', call_params)
46
48
  if response.is_a? REXML::Element
47
49
  if response.elements['StatusCode'].get_text.to_s == 'Success'
48
50
  {
@@ -74,8 +76,9 @@ module NFGClient
74
76
  # Arguments:
75
77
  # params: (Hash)
76
78
  def get_donor_cofs(params)
79
+ requires!(params, :DonorToken)
77
80
  call_params = add_credentials_to_params(params)
78
- response = nfg_soap_request('GetDonorCOFs', call_params, @use_sandbox)
81
+ response = nfg_soap_request('GetDonorCOFs', call_params)
79
82
  if response.is_a? REXML::Element
80
83
  response_hash = {
81
84
  'StatusCode' => response.elements['StatusCode'].get_text.to_s,
@@ -107,11 +110,13 @@ module NFGClient
107
110
  # Arguments:
108
111
  # params: (Hash)
109
112
  def get_fee(params)
113
+ requires!(params, :DonationLineItems, :TipAmount, :CardType)
110
114
  call_params = add_credentials_to_params(params)
111
- response = nfg_soap_request('GetFee', call_params, @use_sandbox)
115
+ response = nfg_soap_request('GetFee', call_params)
112
116
  if response.is_a? REXML::Element
113
117
  if response.elements['ErrorDetails'].elements['ErrorInfo'].nil?
114
118
  {
119
+ 'StatusCode' => 'Success',
115
120
  'Message' => response.elements['Message'].get_text.to_s,
116
121
  'ErrorDetails' => response.elements['ErrorDetails'].get_text.to_s,
117
122
  'CallDuration' => response.elements['CallDuration'].get_text.to_s,
@@ -122,6 +127,7 @@ module NFGClient
122
127
  }
123
128
  else
124
129
  {
130
+ 'StatusCode' => 'ValidationFailed',
125
131
  'Message' => response.elements['Message'].get_text.to_s,
126
132
  'ErrorDetails' => {
127
133
  'ErrorInfo' => {
@@ -140,14 +146,14 @@ module NFGClient
140
146
  response
141
147
  end
142
148
  end
143
-
144
149
  # Makes a donation using the given COF
145
150
  #
146
151
  # Arguments:
147
152
  # params: (Hash)
148
153
  def make_cof_donation(params)
154
+ requires!(params, :DonationLineItems, :TotalAmount, :TipAmount, :DonorIpAddress, :DonorToken, :COFId)
149
155
  call_params = add_credentials_to_params(params)
150
- response = nfg_soap_request('MakeCOFDonation', call_params, @use_sandbox)
156
+ response = nfg_soap_request('MakeCOFDonation', call_params)
151
157
  if response.is_a? REXML::Element
152
158
  if response.elements['StatusCode'].get_text.to_s == 'Success'
153
159
  {
@@ -183,8 +189,9 @@ module NFGClient
183
189
  # Arguments:
184
190
  # params: (Hash)
185
191
  def make_donation_add_cof(params)
192
+ requires!(params, :DonationLineItems, :TotalAmount, :TipAmount, :DonorIpAddress, :DonorToken, :DonorFirstName, :DonorLastName, :DonorEmail, :DonorAddress1, :DonorAddress2, :DonorCity, :DonorState, :DonorZip, :DonorCountry, :DonorPhone, :CardType, :NameOnCard, :CardNumber, :ExpMonth, :ExpYear, :CSC)
186
193
  call_params = add_credentials_to_params(params)
187
- response = nfg_soap_request('MakeDonationAddCOF', call_params, @use_sandbox)
194
+ response = nfg_soap_request('MakeDonationAddCOF', call_params)
188
195
  if response.is_a? REXML::Element
189
196
  if (response.elements['StatusCode'].get_text.to_s == 'Success') || ((response.elements['StatusCode'].get_text.to_s != 'Success') && response.elements['ErrorDetails'].elements['ErrorInfo'].nil?)
190
197
  {
@@ -220,8 +227,9 @@ module NFGClient
220
227
  # Arguments:
221
228
  # params: (Hash)
222
229
  def get_donor_donation_history(params)
230
+ requires!(params, :DonorToken)
223
231
  call_params = add_credentials_to_params(params)
224
- response = nfg_soap_request('GetDonorDonationHistory', call_params, @use_sandbox)
232
+ response = nfg_soap_request('GetDonorDonationHistory', call_params)
225
233
  if response.is_a? REXML::Element
226
234
  response_hash = {
227
235
  'StatusCode' => response.elements['StatusCode'].get_text.to_s,
@@ -254,8 +262,9 @@ module NFGClient
254
262
  # Arguments:
255
263
  # params: (Hash)
256
264
  def get_donation_report(params)
265
+ requires!(params, :StartDate, :EndDate, :DonationReportType)
257
266
  call_params = add_credentials_to_params(params)
258
- response = nfg_soap_request('GetDonationReport', call_params, @use_sandbox)
267
+ response = nfg_soap_request('GetDonationReport', call_params)
259
268
  if response.is_a? REXML::Element
260
269
  response_hash = {
261
270
  'StatusCode' => response.elements['StatusCode'].get_text.to_s,
@@ -21,32 +21,21 @@ module NFGClient
21
21
  # Arguments:
22
22
  # nfg_method: (String)
23
23
  # params: (Hash)
24
- def nfg_soap_request(nfg_method, params, use_sandbox = false)
24
+ def nfg_soap_request(nfg_method, params)
25
25
  if (nfg_method.is_a? String) && (params.is_a? Hash)
26
- # Build SOAP 1.2 request
27
- soap_request = build_nfg_soap_request(nfg_method,params)
28
26
 
29
- # Build request URL & header
30
- host = use_sandbox ? @@nfg_urls['sandbox']['host'] : @@nfg_urls['production']['host']
31
- url = use_sandbox ? @@nfg_urls['sandbox']['url'] : @@nfg_urls['production']['url']
32
- headers = {
33
- 'Host' => host,
34
- 'Content-Type' => 'application/soap+xml; charset=utf-8',
35
- 'Content-Length' => soap_request.length.to_s,
36
- 'SOAPAction' => "#{url}/#{nfg_method}".gsub('.asmx','')
37
- }
27
+ # Build SOAP 1.2 request
28
+ soap_request = build_nfg_soap_request(nfg_method, params)
29
+
30
+ headers = format_headers(nfg_method, soap_request)
38
31
 
39
32
  return_value = Hash.new
40
33
 
41
34
  # Being HTTP Post
42
35
  begin
43
- uri = URI.parse(url)
44
- https_conn = Net::HTTP.new(uri.host, uri.port)
45
- https_conn.use_ssl = true
46
- response = https_conn.post(uri.path, soap_request, headers)
36
+ response = ssl_post(soap_request, headers)
47
37
  if response.code == '200'
48
38
  parsed = REXML::Document.new(response.body)
49
- #return response.body
50
39
  # Build return hash parsing XML response
51
40
  if parsed.root.nil?
52
41
  return_value['StatusCode'] = 'MissingParameter'
@@ -61,6 +50,7 @@ module NFGClient
61
50
  return_value['ErrorDetails'] = response.body
62
51
  end
63
52
  rescue StandardError => e
53
+ p e
64
54
  return_value['StatusCode'] = 'UnexpectedError'
65
55
  return_value['Message'] = e
66
56
  return_value['ErrorDetails'] = e.backtrace.join(' ')
@@ -70,22 +60,85 @@ module NFGClient
70
60
  else
71
61
  raise ArgumentError.new('http_post requires a nfg_method and a hash of params')
72
62
  end
73
- end
63
+ end
74
64
 
65
+ # Returns a complete NFG SOAP request based on the provided target method and params
75
66
  def build_nfg_soap_request(nfg_method, params)
76
67
  get_nfg_soap_request_template.gsub('|body|',"<#{nfg_method} xmlns=\"http://api.networkforgood.org/partnerdonationservice\">#{hash_to_xml(params)}</#{nfg_method}>")
77
68
  end
78
69
 
70
+ # Returns a SOAP template with no body
79
71
  def get_nfg_soap_request_template
80
72
  "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\"><soap12:Body>|body|</soap12:Body></soap12:Envelope>"
81
73
  end
82
74
 
75
+ # Makes HTTPS post request with given body (soap_request) and headers
76
+ #
77
+ # Arguments:
78
+ # soap_request: (String)
79
+ # headers: (Hash)
80
+ def ssl_post(soap_request, headers)
81
+ uri = URI.parse(url)
82
+ https_conn = Net::HTTP.new(uri.host, uri.port)
83
+ https_conn.use_ssl = true
84
+ https_conn.post(uri.path, soap_request, headers)
85
+ end
86
+
87
+ # Returns NFG friendly headers hash for HTTPS post
88
+ #
89
+ # Arguments:
90
+ # nfg_method: (String)
91
+ # soap_request: (String)
92
+ def format_headers(nfg_method, soap_request)
93
+ {
94
+ 'Host' => host,
95
+ 'Content-Type' => 'application/soap+xml; charset=utf-8',
96
+ 'Content-Length' => soap_request.length.to_s,
97
+ 'SOAPAction' => "#{url}/#{nfg_method}".gsub('.asmx','')
98
+ }
99
+ end
100
+
101
+ # Returns NFG target host
102
+ def host
103
+ return @@nfg_urls['sandbox']['host'] if @use_sandbox
104
+ @@nfg_urls['production']['host']
105
+ end
106
+
107
+ # Returns NFG target URL
108
+ def url
109
+ return @@nfg_urls['sandbox']['url'] if @use_sandbox
110
+ @@nfg_urls['production']['url']
111
+ end
112
+
113
+ # Returns a string containing an XML representation of the given hash
114
+ #
115
+ # Arguments:
116
+ # hash: (Hash)
83
117
  def hash_to_xml(hash)
84
118
  hash.map do |k, v|
85
119
  text = (v.is_a? Hash) ? hash_to_xml(v) : v
86
- xml_elem = (v.is_a? Hash) ? k.gsub(/(\d)/, "") : k
120
+ # It removes the digits at the end of each "DonationItem" hash key
121
+ xml_elem = (v.is_a? Hash) ? k.to_s.gsub(/(\d)/, "") : k
87
122
  "<%s>%s</%s>" % [xml_elem, text, xml_elem]
88
123
  end.join
89
124
  end
125
+
126
+ # Raises an exception if the required params are not part of the given hash
127
+ #
128
+ # Arguments:
129
+ # hash: (Hash)
130
+ # *params: (Array or Symbol)
131
+ def requires!(hash, *params)
132
+ params.each do |param|
133
+ if param.is_a?(Array)
134
+ raise ArgumentError.new("Missing required parameter: #{param.first}") unless hash.has_key?(param.first) || hash.has_key?(param.first.to_s)
135
+
136
+ valid_options = param[1..-1]
137
+ raise ArgumentError.new("Parameter: #{param.first} must be one of #{valid_options.to_sentence(:words_connector => 'or')}") unless valid_options.include?(hash[param.first]) || valid_options.include?(hash[param.first.to_s])
138
+ else
139
+ raise ArgumentError.new("Missing required parameter: #{param}") unless hash.has_key?(param) || hash.has_key?(param.to_s)
140
+ end
141
+ end
142
+ end
90
143
  end
91
144
  end
@@ -1,3 +1,3 @@
1
1
  module NFGClient
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -22,4 +22,5 @@ Gem::Specification.new do |gem|
22
22
 
23
23
  gem.add_development_dependency 'rspec', '~> 2.13.0'
24
24
  gem.add_development_dependency 'simplecov'
25
+ gem.add_development_dependency 'mocha'
25
26
  end
@@ -0,0 +1,115 @@
1
+ require 'spec_helper'
2
+
3
+ # Your ip address must be whitelisted at NFG for these tests to work
4
+
5
+
6
+ describe NFGClient do
7
+ let(:nfg_client) { NFGClient.new(PartnerID, PartnerPW, PartnerSource, PartnerCampaign, true) }
8
+ describe "create_cof" do
9
+ context 'with valid information' do
10
+ it "should create a card on file" do
11
+ result = nfg_client.create_cof(create_cof_params)
12
+ expect(result["StatusCode"]).to eql('Success')
13
+ expect(result["DonorToken"]).to eql(create_cof_params[:DonorToken])
14
+ expect(result["COFId"]).to_not eq('0')
15
+ end
16
+ end
17
+
18
+ context "with invalid information" do
19
+ it "should not create a card on file" do
20
+ result = nfg_client.create_cof(create_cof_params.merge({ ExpYear: '14' }))
21
+ expect(result["StatusCode"]).to eql('ValidationFailed')
22
+ expect(result["DonorToken"]).to eql(create_cof_params[:DonorToken])
23
+ expect(result["COFId"]).to eql('0')
24
+ end
25
+ end
26
+ end
27
+
28
+ describe "get_fee" do
29
+ context 'with valid information' do
30
+ it "should be successful" do
31
+ result = nfg_client.get_fee(get_fee_params)
32
+ expect(result["StatusCode"]).to eql('Success')
33
+ expect(result["TotalChargeAmount"]).to eql("100.0")
34
+ end
35
+ end
36
+
37
+ context 'with invalid information' do
38
+ it "should not be successful" do
39
+ result = nfg_client.get_fee(get_fee_params('12-1212121'))
40
+ expect(result["StatusCode"]).to eql('ValidationFailed')
41
+ expect(result["ErrorDetails"]["ErrorInfo"]["ErrCode"]).to eql('NpoNotFound')
42
+ end
43
+ end
44
+ end
45
+
46
+ describe "delete_donor_cof" do
47
+ context "with valid information" do
48
+ it "should remove the cof" do
49
+ result = nfg_client.create_cof(create_cof_params)
50
+ result = nfg_client.delete_donor_cof( { DonorToken: result['DonorToken'], COFId: result['COFId']})
51
+ expect(result["StatusCode"]).to eql('Success')
52
+ end
53
+ end
54
+
55
+ context "with invalid COFId" do
56
+ it "should return an error" do
57
+ result = nfg_client.delete_donor_cof( delete_donor_cof_params )
58
+ expect(result["StatusCode"]).to eql('OtherError')
59
+ end
60
+ end
61
+ end
62
+
63
+ describe "make_cof_donation" do
64
+ context "with valid information" do
65
+ it "should make the donation" do
66
+ result = nfg_client.create_cof(create_cof_params)
67
+ result = nfg_client.make_cof_donation(make_cof_donation_params(result['COFId']))
68
+ expect(result["StatusCode"]).to eql('Success')
69
+ expect(result["ChargeId"]).to_not eq('0')
70
+ end
71
+ end
72
+
73
+ context "with invalid information" do
74
+ it "should not make the donation" do
75
+ result = nfg_client.make_cof_donation(make_cof_donation_params)
76
+ expect(result["StatusCode"]).to eql('ValidationFailed')
77
+ expect(result["ChargeId"]).to eq('0')
78
+ expect(result["ErrorDetails"]["ErrorInfo"]["ErrCode"]).to eql('COFNotFound')
79
+ end
80
+ end
81
+ end
82
+
83
+ describe "make_donation_add_cof" do
84
+ context "with valid information" do
85
+ it "should make the donation" do
86
+ result = nfg_client.make_donation_add_cof(make_donation_add_cof_params)
87
+ expect(result["StatusCode"]).to eql('Success')
88
+ expect(result["ChargeId"]).to_not eq('0')
89
+ expect(result["COFId"]).to_not eq('0')
90
+ end
91
+ end
92
+
93
+ context "with invalid information" do
94
+ it "should not make the donation" do
95
+ result = nfg_client.make_donation_add_cof(make_donation_add_cof_params('444'))
96
+ expect(result["StatusCode"]).to eql('ChargeFailed')
97
+ expect(result["ChargeId"]).to_not eq('0')
98
+ expect(result["COFId"]).to eq('0')
99
+ end
100
+ end
101
+ end
102
+
103
+ describe "get_donor_donation_history" do
104
+ it "should return something" do
105
+ result = nfg_client.create_cof(create_cof_params)
106
+ params = make_donation_add_cof_params
107
+ result = nfg_client.make_donation_add_cof(params)
108
+ result = nfg_client.get_donor_donation_history(DonorToken: params[:DonorToken])
109
+
110
+ expect(result["StatusCode"]).to eql('Success')
111
+ expect(result["Donations"]).to eql('Success')
112
+ end
113
+ end
114
+ end
115
+
@@ -1,6 +1,14 @@
1
1
  require 'simplecov'
2
+ require 'mocha/api'
3
+ require 'andand'
4
+
5
+ require 'nfg-client'
6
+
2
7
  SimpleCov.start
3
8
 
9
+ # load all of the files in the support folder
10
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
11
+
4
12
  # This file was generated by the `rspec --init` command. Conventionally, all
5
13
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
6
14
  # Require this file using `require "spec_helper"` to ensure that it is only
@@ -0,0 +1,134 @@
1
+ def create_cof_params
2
+ {
3
+ DonorIpAddress: '198.168.200.200',
4
+ DonorToken: 'AIH3939',
5
+ DonorFirstName: 'John',
6
+ DonorLastName: 'Smith',
7
+ DonorEmail: 'john@smith.com',
8
+ DonorAddress1: '123 Address Way',
9
+ DonorAddress2: '',
10
+ DonorCity: 'Baltimore',
11
+ DonorState: 'MD',
12
+ DonorZip: '21210',
13
+ DonorCountry: 'US',
14
+ DonorPhone: '410-544-8778',
15
+ CardType: 'Visa',
16
+ NameOnCard: 'John Smith',
17
+ CardNumber: '4111111111111111',
18
+ ExpMonth: '12',
19
+ ExpYear: '2016',
20
+ CSC: '123'
21
+ }
22
+ end
23
+
24
+ def delete_donor_cof_params
25
+ {
26
+ DonorToken: 'AIH3939',
27
+ COFId: '1111111',
28
+ }
29
+ end
30
+
31
+ def get_donation_report_params
32
+ {
33
+ StartDate: '2014-01-01 00:00:00',
34
+ EndDate: '2014-01-01 12:00:00',
35
+ DonationReportType: 'All'
36
+ }
37
+ end
38
+
39
+ def get_donor_cofs_params
40
+ {
41
+ DonorToken: 'AIH3939',
42
+ }
43
+ end
44
+
45
+ def get_donor_donation_history_params
46
+ {
47
+ DonorToken: 239949
48
+ }
49
+ end
50
+
51
+ # default is NFG EIN
52
+ def get_fee_params(npo_ein = '68-0480736')
53
+ {
54
+ DonationLineItems: {
55
+ DonationItem: {
56
+ NpoEin: npo_ein,
57
+ Designation: 'annual_fund',
58
+ Dedication: 'For my grandfather',
59
+ donorVis: 'ProvideAll',
60
+ ItemAmount: 100.00,
61
+ RecurType: 'NotRecurring',
62
+ AddOrDeduct: 'Add',
63
+ TransactionType: 'Donation'
64
+ }
65
+ },
66
+ TipAmount: 3.00,
67
+ CardType: 'Visa'
68
+ }
69
+ end
70
+
71
+ def make_cof_donation_params(cof_id = '11111111')
72
+ {
73
+ DonationLineItems: {
74
+ DonationItem: {
75
+ NpoEin: '68-0480736',
76
+ Designation: 'annual_fund',
77
+ Dedication: 'For my grandfather',
78
+ donorVis: 'ProvideAll',
79
+ ItemAmount: 100.00,
80
+ RecurType: 'NotRecurring',
81
+ AddOrDeduct: 'Add',
82
+ TransactionType: 'Donation'
83
+ }
84
+ },
85
+ TotalAmount: 100.00,
86
+ TipAmount: 3.00,
87
+ PartnerTransactionIdentifier: 'my_order_id',
88
+ DonorIpAddress: '198.168.200.200',
89
+ DonorToken: 'AIH3939',
90
+ COFId: cof_id
91
+ }
92
+ end
93
+
94
+ def make_donation_add_cof_params(csc = '123')
95
+ {
96
+ DonationLineItems: {
97
+ DonationItem: {
98
+ NpoEin: '68-0480736',
99
+ Designation: 'annual_fund',
100
+ Dedication: 'For my grandfather',
101
+ donorVis: 'ProvideAll',
102
+ ItemAmount: 100.00,
103
+ RecurType: 'NotRecurring',
104
+ AddOrDeduct: 'Add',
105
+ TransactionType: 'Donation'
106
+ }
107
+ },
108
+ TotalAmount: 100.00,
109
+ TipAmount: 3.00,
110
+ PartnerTransactionIdentifier: 'my_order_id',
111
+ DonorIpAddress: '198.168.200.200',
112
+ DonorToken: donor_token,
113
+ DonorFirstName: 'John',
114
+ DonorLastName: 'Smith',
115
+ DonorEmail: 'john@smith.com',
116
+ DonorAddress1: '100 Address Way',
117
+ DonorAddress2: '',
118
+ DonorCity: 'Baltimore',
119
+ DonorState: 'MD',
120
+ DonorZip: '21210',
121
+ DonorCountry: 'US',
122
+ DonorPhone: '410-544-8778',
123
+ CardType: 'Visa',
124
+ NameOnCard: 'John Smith',
125
+ CardNumber: '4111111111111111',
126
+ ExpMonth: '12',
127
+ ExpYear: '2015',
128
+ CSC: csc
129
+ }
130
+ end
131
+
132
+ def donor_token
133
+ 'NFG_' + Time.now.strftime("%Y-%m-%d-%H%M%S")
134
+ end