creative-paypal-express 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/.gitignore +22 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +6 -0
  6. data/Gemfile +7 -0
  7. data/LICENSE +20 -0
  8. data/README.rdoc +34 -0
  9. data/Rakefile +19 -0
  10. data/VERSION +1 -0
  11. data/lib/paypal.rb +84 -0
  12. data/lib/paypal/base.rb +19 -0
  13. data/lib/paypal/exception.rb +4 -0
  14. data/lib/paypal/exception/api_error.rb +94 -0
  15. data/lib/paypal/exception/http_error.rb +12 -0
  16. data/lib/paypal/express.rb +1 -0
  17. data/lib/paypal/express/request.rb +195 -0
  18. data/lib/paypal/express/response.rb +35 -0
  19. data/lib/paypal/ipn.rb +23 -0
  20. data/lib/paypal/nvp/request.rb +64 -0
  21. data/lib/paypal/nvp/response.rb +233 -0
  22. data/lib/paypal/payment/common/amount.rb +13 -0
  23. data/lib/paypal/payment/recurring.rb +43 -0
  24. data/lib/paypal/payment/recurring/activation.rb +14 -0
  25. data/lib/paypal/payment/recurring/billing.rb +39 -0
  26. data/lib/paypal/payment/recurring/summary.rb +11 -0
  27. data/lib/paypal/payment/request.rb +67 -0
  28. data/lib/paypal/payment/request/item.rb +26 -0
  29. data/lib/paypal/payment/response.rb +73 -0
  30. data/lib/paypal/payment/response/address.rb +7 -0
  31. data/lib/paypal/payment/response/info.rb +45 -0
  32. data/lib/paypal/payment/response/item.rb +41 -0
  33. data/lib/paypal/payment/response/payer.rb +7 -0
  34. data/lib/paypal/payment/response/reference.rb +9 -0
  35. data/lib/paypal/payment/response/refund.rb +13 -0
  36. data/lib/paypal/util.rb +28 -0
  37. data/paypal-express.gemspec +23 -0
  38. data/spec/fake_response/BillAgreementUpdate/fetch.txt +1 -0
  39. data/spec/fake_response/BillAgreementUpdate/revoke.txt +1 -0
  40. data/spec/fake_response/CreateBillingAgreement/success.txt +1 -0
  41. data/spec/fake_response/CreateRecurringPaymentsProfile/failure.txt +1 -0
  42. data/spec/fake_response/CreateRecurringPaymentsProfile/success.txt +1 -0
  43. data/spec/fake_response/DoCapture/failure.txt +1 -0
  44. data/spec/fake_response/DoCapture/success.txt +1 -0
  45. data/spec/fake_response/DoExpressCheckoutPayment/failure.txt +1 -0
  46. data/spec/fake_response/DoExpressCheckoutPayment/success.txt +1 -0
  47. data/spec/fake_response/DoExpressCheckoutPayment/success_with_billing_agreement.txt +1 -0
  48. data/spec/fake_response/DoExpressCheckoutPayment/success_with_many_items.txt +1 -0
  49. data/spec/fake_response/DoReferenceTransaction/failure.txt +1 -0
  50. data/spec/fake_response/DoReferenceTransaction/success.txt +1 -0
  51. data/spec/fake_response/DoVoid/success.txt +1 -0
  52. data/spec/fake_response/GetExpressCheckoutDetails/failure.txt +1 -0
  53. data/spec/fake_response/GetExpressCheckoutDetails/success.txt +1 -0
  54. data/spec/fake_response/GetExpressCheckoutDetails/with_billing_accepted_status.txt +1 -0
  55. data/spec/fake_response/GetRecurringPaymentsProfileDetails/failure.txt +1 -0
  56. data/spec/fake_response/GetRecurringPaymentsProfileDetails/success.txt +1 -0
  57. data/spec/fake_response/GetTransactionDetails/failure.txt +1 -0
  58. data/spec/fake_response/GetTransactionDetails/success.txt +1 -0
  59. data/spec/fake_response/IPN/invalid.txt +1 -0
  60. data/spec/fake_response/IPN/valid.txt +1 -0
  61. data/spec/fake_response/ManageRecurringPaymentsProfileStatus/failure.txt +1 -0
  62. data/spec/fake_response/ManageRecurringPaymentsProfileStatus/success.txt +1 -0
  63. data/spec/fake_response/RefundTransaction/full.txt +1 -0
  64. data/spec/fake_response/SetExpressCheckout/failure.txt +1 -0
  65. data/spec/fake_response/SetExpressCheckout/success.txt +1 -0
  66. data/spec/helpers/fake_response_helper.rb +33 -0
  67. data/spec/paypal/exception/api_error_spec.rb +78 -0
  68. data/spec/paypal/exception/http_error_spec.rb +8 -0
  69. data/spec/paypal/express/request_spec.rb +584 -0
  70. data/spec/paypal/express/response_spec.rb +80 -0
  71. data/spec/paypal/ipn_spec.rb +19 -0
  72. data/spec/paypal/nvp/request_spec.rb +116 -0
  73. data/spec/paypal/nvp/response_spec.rb +146 -0
  74. data/spec/paypal/payment/common/amount_spec.rb +36 -0
  75. data/spec/paypal/payment/recurring/activation_spec.rb +19 -0
  76. data/spec/paypal/payment/recurring_spec.rb +170 -0
  77. data/spec/paypal/payment/request/item_spec.rb +27 -0
  78. data/spec/paypal/payment/request_spec.rb +136 -0
  79. data/spec/paypal/payment/response/address_spec.rb +26 -0
  80. data/spec/paypal/payment/response/info_spec.rb +93 -0
  81. data/spec/paypal/payment/response/item_spec.rb +42 -0
  82. data/spec/paypal/payment/response/payer_spec.rb +26 -0
  83. data/spec/paypal/payment/response_spec.rb +16 -0
  84. data/spec/paypal/util_spec.rb +32 -0
  85. data/spec/spec_helper.rb +25 -0
  86. metadata +278 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4a60a5012c7f59770f868f0e5eb80f321baa383b
4
+ data.tar.gz: 3f575e72e74fe5bfca2b89f64ab56e5e3491dd88
5
+ SHA512:
6
+ metadata.gz: 5d89fbfdb8e7f775d85211b112494039fe7e0b9016eaa209eade91eefec9f130b08e6520a4894a85aaab27b684a54579ddc985166b632dffe362be1be7c058e8
7
+ data.tar.gz: a36e5d31b80502dacab788bfd6b8c969d5ca96452544c46bc2bdeb11aeca4692fec32a684fc9aaeb60651eeaf4d45d902b5f155ef92aebe4bbd860e859838061
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,22 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage*
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
22
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format=documentation
@@ -0,0 +1,6 @@
1
+ before_install:
2
+ - gem install bundler
3
+
4
+ rvm:
5
+ - 2.0.0
6
+ - 2.1.2
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'http://rubygems.org'
2
+
3
+ platform :jruby do
4
+ gem 'jruby-openssl', '>= 0.7'
5
+ end
6
+
7
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 nov matake
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,34 @@
1
+ = paypal-express
2
+
3
+ Handle PayPal Express Checkout.
4
+ Both Instance Payment and Recurring Payment are supported.
5
+ Express Checkout for Digital Goods is also supported.
6
+
7
+ {<img src="https://secure.travis-ci.org/nov/paypal-express.png" />}[http://travis-ci.org/nov/paypal-express]
8
+
9
+ == Installation
10
+
11
+ gem install paypal-express
12
+
13
+ == Usage
14
+
15
+ See Wiki on Github
16
+ https://github.com/nov/paypal-express/wiki
17
+
18
+ Play with Sample Rails App
19
+ https://github.com/nov/paypal-express-sample
20
+ https://paypal-express-sample.heroku.com
21
+
22
+ == Note on Patches/Pull Requests
23
+
24
+ * Fork the project.
25
+ * Make your feature addition or bug fix.
26
+ * Add tests for it. This is important so I don't break it in a
27
+ future version unintentionally.
28
+ * Commit, do not mess with rakefile, version, or history.
29
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
30
+ * Send me a pull request. Bonus points for topic branches.
31
+
32
+ == Copyright
33
+
34
+ Copyright (c) 2011 nov matake. See LICENSE for details.
@@ -0,0 +1,19 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ namespace :coverage do
8
+ desc "Open coverage report"
9
+ task :report do
10
+ require 'simplecov'
11
+ `open "#{File.join SimpleCov.coverage_path, 'index.html'}"`
12
+ end
13
+ end
14
+
15
+ task :spec do
16
+ Rake::Task[:'coverage:report'].invoke unless ENV['TRAVIS_RUBY_VERSION']
17
+ end
18
+
19
+ task :default => :spec
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.8.1
@@ -0,0 +1,84 @@
1
+ require 'logger'
2
+ require 'active_support'
3
+ require 'active_support/core_ext'
4
+ require 'attr_required'
5
+ require 'attr_optional'
6
+ require 'rest_client'
7
+
8
+ module Paypal
9
+ mattr_accessor :api_version
10
+ self.api_version = '88.0'
11
+
12
+ ENDPOINT = {
13
+ :production => 'https://www.paypal.com/cgi-bin/webscr',
14
+ :sandbox => 'https://www.sandbox.paypal.com/cgi-bin/webscr'
15
+ }
16
+ POPUP_ENDPOINT = {
17
+ :production => 'https://www.paypal.com/incontext',
18
+ :sandbox => 'https://www.sandbox.paypal.com/incontext'
19
+ }
20
+
21
+ def self.endpoint
22
+ if sandbox?
23
+ Paypal::ENDPOINT[:sandbox]
24
+ else
25
+ Paypal::ENDPOINT[:production]
26
+ end
27
+ end
28
+ def self.popup_endpoint
29
+ if sandbox?
30
+ Paypal::POPUP_ENDPOINT[:sandbox]
31
+ else
32
+ Paypal::POPUP_ENDPOINT[:production]
33
+ end
34
+ end
35
+
36
+ def self.log(message, mode = :info)
37
+ self.logger.send mode, message
38
+ end
39
+ def self.logger
40
+ @@logger
41
+ end
42
+ def self.logger=(logger)
43
+ @@logger = logger
44
+ end
45
+ @@logger = Logger.new(STDERR)
46
+ @@logger.progname = 'Paypal::Express'
47
+
48
+ def self.sandbox?
49
+ @@sandbox
50
+ end
51
+ def self.sandbox!
52
+ self.sandbox = true
53
+ end
54
+ def self.sandbox=(boolean)
55
+ @@sandbox = boolean
56
+ end
57
+ self.sandbox = false
58
+
59
+ end
60
+
61
+ require 'paypal/util'
62
+ require 'paypal/exception'
63
+ require 'paypal/exception/http_error'
64
+ require 'paypal/exception/api_error'
65
+ require 'paypal/base'
66
+ require 'paypal/ipn'
67
+ require 'paypal/nvp/request'
68
+ require 'paypal/nvp/response'
69
+ require 'paypal/payment/common/amount'
70
+ require 'paypal/express/request'
71
+ require 'paypal/express/response'
72
+ require 'paypal/payment/request'
73
+ require 'paypal/payment/request/item'
74
+ require 'paypal/payment/response'
75
+ require 'paypal/payment/response/info'
76
+ require 'paypal/payment/response/item'
77
+ require 'paypal/payment/response/payer'
78
+ require 'paypal/payment/response/reference'
79
+ require 'paypal/payment/response/refund'
80
+ require 'paypal/payment/response/address'
81
+ require 'paypal/payment/recurring'
82
+ require 'paypal/payment/recurring/activation'
83
+ require 'paypal/payment/recurring/billing'
84
+ require 'paypal/payment/recurring/summary'
@@ -0,0 +1,19 @@
1
+ module Paypal
2
+ class Base
3
+ include AttrRequired, AttrOptional, Util
4
+
5
+ def initialize(attributes = {})
6
+ if attributes.is_a?(Hash)
7
+ (required_attributes + optional_attributes).each do |key|
8
+ value = if numeric_attribute?(key)
9
+ Util.to_numeric(attributes[key])
10
+ else
11
+ attributes[key]
12
+ end
13
+ self.send "#{key}=", value
14
+ end
15
+ end
16
+ attr_missing!
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,4 @@
1
+ module Paypal
2
+ class Exception < StandardError
3
+ end
4
+ end
@@ -0,0 +1,94 @@
1
+ module Paypal
2
+ class Exception
3
+ class APIError < Exception
4
+ attr_accessor :response
5
+ def initialize(response = {})
6
+ @response = if response.is_a?(Hash)
7
+ Response.new response
8
+ else
9
+ response
10
+ end
11
+ end
12
+
13
+ def message
14
+ if response.respond_to?(:short_messages) && response.short_messages.any?
15
+ "PayPal API Error: " <<
16
+ response.short_messages.map{ |m| "'#{m}'" }.join(", ")
17
+ else
18
+ "PayPal API Error"
19
+ end
20
+ end
21
+
22
+ class Response
23
+ cattr_reader :attribute_mapping
24
+ @@attribute_mapping = {
25
+ :ACK => :ack,
26
+ :BUILD => :build,
27
+ :CORRELATIONID => :correlation_id,
28
+ :TIMESTAMP => :timestamp,
29
+ :VERSION => :version,
30
+ :ORDERTIME => :order_time,
31
+ :PENDINGREASON => :pending_reason,
32
+ :PAYMENTSTATUS => :payment_status,
33
+ :PAYMENTTYPE => :payment_type,
34
+ :REASONCODE => :reason_code,
35
+ :TRANSACTIONTYPE => :transaction_type
36
+ }
37
+ attr_accessor *@@attribute_mapping.values
38
+ attr_accessor :raw, :details
39
+ alias_method :colleration_id, :correlation_id # NOTE: I made a typo :p
40
+
41
+ class Detail
42
+ cattr_reader :attribute_mapping
43
+ @@attribute_mapping = {
44
+ :ERRORCODE => :error_code,
45
+ :SEVERITYCODE => :severity_code,
46
+ :LONGMESSAGE => :long_message,
47
+ :SHORTMESSAGE => :short_message
48
+ }
49
+ attr_accessor *@@attribute_mapping.values
50
+
51
+ def initialize(attributes = {})
52
+ @raw = attributes
53
+ attrs = attributes.dup
54
+ @@attribute_mapping.each do |key, value|
55
+ self.send "#{value}=", attrs.delete(key)
56
+ end
57
+
58
+ # warn ignored params
59
+ attrs.each do |key, value|
60
+ Paypal.log "Ignored Parameter (#{self.class}): #{key}=#{value}", :warn
61
+ end
62
+ end
63
+ end
64
+
65
+ def initialize(attributes = {})
66
+ attrs = attributes.dup
67
+ @raw = attributes
68
+ @@attribute_mapping.each do |key, value|
69
+ self.send "#{value}=", attrs.delete(key)
70
+ end
71
+ details = []
72
+ attrs.keys.each do |attribute|
73
+ key, index = attribute.to_s.scan(/^L_(\S+)(\d+)$/).first
74
+ next if [key, index].any?(&:blank?)
75
+ details[index.to_i] ||= {}
76
+ details[index.to_i][key.to_sym] = attrs.delete(attribute)
77
+ end
78
+ @details = details.collect do |_attrs_|
79
+ Detail.new _attrs_
80
+ end
81
+
82
+ # warn ignored params
83
+ attrs.each do |key, value|
84
+ Paypal.log "Ignored Parameter (#{self.class}): #{key}=#{value}", :warn
85
+ end
86
+ end
87
+
88
+ def short_messages
89
+ details.map(&:short_message).compact
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,12 @@
1
+ module Paypal
2
+ class Exception
3
+ class HttpError < Exception
4
+ attr_accessor :code, :message, :body
5
+ def initialize(code, message, body = '')
6
+ @code = code
7
+ @message = message
8
+ @body = body
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1 @@
1
+ require 'paypal'
@@ -0,0 +1,195 @@
1
+ module Paypal
2
+ module Express
3
+ class Request < NVP::Request
4
+
5
+ # Common
6
+
7
+ def setup(payment_requests, return_url, cancel_url, options = {})
8
+ params = {
9
+ :RETURNURL => return_url,
10
+ :CANCELURL => cancel_url
11
+ }
12
+ if options[:no_shipping]
13
+ params[:REQCONFIRMSHIPPING] = 0
14
+ params[:NOSHIPPING] = 1
15
+ end
16
+
17
+ params[:ALLOWNOTE] = 0 if options[:allow_note] == false
18
+
19
+ {
20
+ :solution_type => :SOLUTIONTYPE,
21
+ :landing_page => :LANDINGPAGE,
22
+ :email => :EMAIL,
23
+ :brand => :BRANDNAME,
24
+ :locale => :LOCALECODE,
25
+ :logo => :LOGOIMG,
26
+ :cart_border_color => :CARTBORDERCOLOR,
27
+ :payflow_color => :PAYFLOWCOLOR,
28
+ :receiver_email => :PAYMENTREQUEST_0_SELLERPAYPALACCOUNTID
29
+ }.each do |option_key, param_key|
30
+ params[param_key] = options[option_key] if options[option_key]
31
+ end
32
+ Array(payment_requests).each_with_index do |payment_request, index|
33
+ params.merge! payment_request.to_params(index)
34
+ end
35
+ response = self.request :SetExpressCheckout, params
36
+ Response.new response, options
37
+ end
38
+
39
+ def details(token)
40
+ response = self.request :GetExpressCheckoutDetails, {:TOKEN => token}
41
+ Response.new response
42
+ end
43
+
44
+ def transaction_details(transaction_id)
45
+ response = self.request :GetTransactionDetails, {:TRANSACTIONID=> transaction_id}
46
+ Response.new response
47
+ end
48
+
49
+ def checkout!(token, payer_id, payment_requests)
50
+ params = {
51
+ :TOKEN => token,
52
+ :PAYERID => payer_id
53
+ }
54
+ Array(payment_requests).each_with_index do |payment_request, index|
55
+ params.merge! payment_request.to_params(index)
56
+ end
57
+ response = self.request :DoExpressCheckoutPayment, params
58
+ Response.new response
59
+ end
60
+
61
+ def capture!(authorization_id, amount, currency_code, complete_type = 'Complete')
62
+ params = {
63
+ :AUTHORIZATIONID => authorization_id,
64
+ :COMPLETETYPE => complete_type,
65
+ :AMT => amount,
66
+ :CURRENCYCODE => currency_code
67
+ }
68
+
69
+ response = self.request :DoCapture, params
70
+ Response.new response
71
+ end
72
+
73
+ def void!(authorization_id, params={})
74
+ params = {
75
+ :AUTHORIZATIONID => authorization_id,
76
+ :NOTE => params[:note]
77
+ }
78
+
79
+ response = self.request :DoVoid, params
80
+ Response.new response
81
+ end
82
+
83
+ # Recurring Payment Specific
84
+
85
+ def subscribe!(token, recurring_profile)
86
+ params = {
87
+ :TOKEN => token
88
+ }
89
+ params.merge! recurring_profile.to_params
90
+ response = self.request :CreateRecurringPaymentsProfile, params
91
+ Response.new response
92
+ end
93
+
94
+ def subscription(profile_id)
95
+ params = {
96
+ :PROFILEID => profile_id
97
+ }
98
+ response = self.request :GetRecurringPaymentsProfileDetails, params
99
+ Response.new response
100
+ end
101
+
102
+ def renew!(profile_id, action, options = {})
103
+ params = {
104
+ :PROFILEID => profile_id,
105
+ :ACTION => action
106
+ }
107
+ if options[:note]
108
+ params[:NOTE] = options[:note]
109
+ end
110
+ response = self.request :ManageRecurringPaymentsProfileStatus, params
111
+ Response.new response
112
+ end
113
+
114
+ def suspend!(profile_id, options = {})
115
+ renew!(profile_id, :Suspend, options)
116
+ end
117
+
118
+ def cancel!(profile_id, options = {})
119
+ renew!(profile_id, :Cancel, options)
120
+ end
121
+
122
+ def reactivate!(profile_id, options = {})
123
+ renew!(profile_id, :Reactivate, options)
124
+ end
125
+
126
+
127
+ # Reference Transaction Specific
128
+
129
+ def agree!(token, options = {})
130
+ params = {
131
+ :TOKEN => token
132
+ }
133
+ if options[:max_amount]
134
+ params[:MAXAMT] = Util.formatted_amount options[:max_amount]
135
+ end
136
+ response = self.request :CreateBillingAgreement, params
137
+ Response.new response
138
+ end
139
+
140
+ def agreement(reference_id)
141
+ params = {
142
+ :REFERENCEID => reference_id
143
+ }
144
+ response = self.request :BillAgreementUpdate, params
145
+ Response.new response
146
+ end
147
+
148
+ def charge!(reference_id, amount, options = {})
149
+ params = {
150
+ :REFERENCEID => reference_id,
151
+ :AMT => Util.formatted_amount(amount),
152
+ :PAYMENTACTION => options[:payment_action] || :Sale
153
+ }
154
+ if options[:currency_code]
155
+ params[:CURRENCYCODE] = options[:currency_code]
156
+ end
157
+ response = self.request :DoReferenceTransaction, params
158
+ Response.new response
159
+ end
160
+
161
+ def revoke!(reference_id)
162
+ params = {
163
+ :REFERENCEID => reference_id,
164
+ :BillingAgreementStatus => :Canceled
165
+ }
166
+ response = self.request :BillAgreementUpdate, params
167
+ Response.new response
168
+ end
169
+
170
+
171
+ # Refund Specific
172
+
173
+ def refund!(transaction_id, options = {})
174
+ params = {
175
+ :TRANSACTIONID => transaction_id,
176
+ :REFUNDTYPE => :Full
177
+ }
178
+ if options[:invoice_id]
179
+ params[:INVOICEID] = options[:invoice_id]
180
+ end
181
+ if options[:type]
182
+ params[:REFUNDTYPE] = options[:type]
183
+ params[:AMT] = options[:amount]
184
+ params[:CURRENCYCODE] = options[:currency_code]
185
+ end
186
+ if options[:note]
187
+ params[:NOTE] = options[:note]
188
+ end
189
+ response = self.request :RefundTransaction, params
190
+ Response.new response
191
+ end
192
+
193
+ end
194
+ end
195
+ end