activemerchant 1.0.0 → 1.0.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.
data/CHANGELOG CHANGED
@@ -1,5 +1,7 @@
1
1
  # CHANGELOG
2
2
  # ---
3
+ # * Add support for crediting to PayPal [cody, Haig]
4
+ #
3
5
  # * Add discover to list of supported card types for Authorize.net
4
6
  #
5
7
  # * Fix Psigate crediting [sean.alien8@gmail.com]
@@ -37,4 +39,4 @@
37
39
  # * Credit card in memory object resembling a AR object
38
40
  #
39
41
  # * Credit card validation methods as static methods of the credit card object
40
- #
42
+ #
@@ -10,12 +10,15 @@ module ActiveMerchant #:nodoc:
10
10
  TEST_URL = 'https://api.sandbox.paypal.com/2.0/'
11
11
  LIVE_URL = 'https://api-aa.paypal.com/2.0/'
12
12
 
13
+ PAYPAL_NAMESPACE = 'urn:ebay:api:PayPalAPI'
14
+ EBAY_NAMESPACE = 'urn:ebay:apis:eBLBaseComponents'
15
+
13
16
  ENVELOPE_NAMESPACES = { 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
14
- 'xmlns:env' => 'http://schemas.xmlsoap.org/soap/envelope/',
15
- 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance'
16
- }
17
- CREDENTIALS_NAMESPACES = { 'xmlns' => 'urn:ebay:api:PayPalAPI',
18
- 'xmlns:n1' => 'urn:ebay:apis:eBLBaseComponents',
17
+ 'xmlns:env' => 'http://schemas.xmlsoap.org/soap/envelope/',
18
+ 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance'
19
+ }
20
+ CREDENTIALS_NAMESPACES = { 'xmlns' => PAYPAL_NAMESPACE,
21
+ 'xmlns:n1' => EBAY_NAMESPACE,
19
22
  'env:mustUnderstand' => '0'
20
23
  }
21
24
 
@@ -46,14 +49,18 @@ module ActiveMerchant #:nodoc:
46
49
  def void(authorization, options = {})
47
50
  commit 'DoVoid', build_void_request(authorization, options)
48
51
  end
52
+
53
+ def credit(money, identification, options = {})
54
+ commit 'RefundTransaction', build_credit_request(money, identification, options)
55
+ end
49
56
 
50
57
  private
51
58
 
52
59
  def build_capture_request(money, authorization, options)
53
60
  xml = Builder::XmlMarkup.new :indent => 2
54
61
 
55
- xml.tag! 'DoCaptureReq', 'xmlns' => 'urn:ebay:api:PayPalAPI' do
56
- xml.tag! 'DoCaptureRequest', 'xmlns:n2' => 'urn:ebay:apis:eBLBaseComponents' do
62
+ xml.tag! 'DoCaptureReq', 'xmlns' => PAYPAL_NAMESPACE do
63
+ xml.tag! 'DoCaptureRequest', 'xmlns:n2' => EBAY_NAMESPACE do
57
64
  xml.tag! 'n2:Version', '2.0'
58
65
  xml.tag! 'AuthorizationID', authorization
59
66
  xml.tag! 'Amount', amount(money), 'currencyID' => currency(money)
@@ -65,11 +72,27 @@ module ActiveMerchant #:nodoc:
65
72
  xml.target!
66
73
  end
67
74
 
75
+ def build_credit_request(money, identification, options)
76
+ xml = Builder::XmlMarkup.new :indent => 2
77
+
78
+ xml.tag! 'RefundTransactionReq', 'xmlns' => PAYPAL_NAMESPACE do
79
+ xml.tag! 'RefundTransactionRequest', 'xmlns:n2' => EBAY_NAMESPACE do
80
+ xml.tag! 'n2:Version', '2.0'
81
+ xml.tag! 'TransactionID', identification
82
+ xml.tag! 'Amount', amount(money), 'currencyID' => currency(money)
83
+ xml.tag! 'RefundType', 'Partial'
84
+ xml.tag! 'Memo', options[:note] unless options[:note].blank?
85
+ end
86
+ end
87
+
88
+ xml.target!
89
+ end
90
+
68
91
  def build_void_request(authorization, options)
69
92
  xml = Builder::XmlMarkup.new :indent => 2
70
93
 
71
- xml.tag! 'DoVoidReq', 'xmlns' => 'urn:ebay:api:PayPalAPI' do
72
- xml.tag! 'DoVoidRequest', 'xmlns:n2' => 'urn:ebay:apis:eBLBaseComponents' do
94
+ xml.tag! 'DoVoidReq', 'xmlns' => PAYPAL_NAMESPACE do
95
+ xml.tag! 'DoVoidRequest', 'xmlns:n2' => EBAY_NAMESPACE do
73
96
  xml.tag! 'n2:Version', '2.0'
74
97
  xml.tag! 'AuthorizationID', authorization
75
98
  xml.tag! 'Note', options[:description]
@@ -161,17 +184,6 @@ module ActiveMerchant #:nodoc:
161
184
  end
162
185
  end
163
186
 
164
- def response_type_for(action)
165
- case action
166
- when 'Authorization', 'Purchase'
167
- 'DoDirectPaymentResponse'
168
- when 'Void'
169
- 'DoVoidResponse'
170
- when 'Capture'
171
- 'DoCaptureResponse'
172
- end
173
- end
174
-
175
187
  def add_address(xml, address)
176
188
  return if address.nil?
177
189
  xml.tag! 'n2:Address' do
@@ -48,8 +48,8 @@ module ActiveMerchant #:nodoc:
48
48
  private
49
49
  def build_get_details_request(token)
50
50
  xml = Builder::XmlMarkup.new :indent => 2
51
- xml.tag! 'GetExpressCheckoutDetailsReq', 'xmlns' => 'urn:ebay:api:PayPalAPI' do
52
- xml.tag! 'GetExpressCheckoutDetailsRequest', 'xmlns:n2' => 'urn:ebay:apis:eBLBaseComponents' do
51
+ xml.tag! 'GetExpressCheckoutDetailsReq', 'xmlns' => PAYPAL_NAMESPACE do
52
+ xml.tag! 'GetExpressCheckoutDetailsRequest', 'xmlns:n2' => EBAY_NAMESPACE do
53
53
  xml.tag! 'n2:Version', '2.0'
54
54
  xml.tag! 'Token', token
55
55
  end
@@ -60,8 +60,8 @@ module ActiveMerchant #:nodoc:
60
60
 
61
61
  def build_sale_or_authorization_request(action, money, options)
62
62
  xml = Builder::XmlMarkup.new :indent => 2
63
- xml.tag! 'DoExpressCheckoutPaymentReq', 'xmlns' => 'urn:ebay:api:PayPalAPI' do
64
- xml.tag! 'DoExpressCheckoutPaymentRequest', 'xmlns:n2' => 'urn:ebay:apis:eBLBaseComponents' do
63
+ xml.tag! 'DoExpressCheckoutPaymentReq', 'xmlns' => PAYPAL_NAMESPACE do
64
+ xml.tag! 'DoExpressCheckoutPaymentRequest', 'xmlns:n2' => EBAY_NAMESPACE do
65
65
  xml.tag! 'n2:Version', '2.0'
66
66
  xml.tag! 'n2:DoExpressCheckoutPaymentRequestDetails' do
67
67
  xml.tag! 'n2:PaymentAction', action
@@ -80,8 +80,8 @@ module ActiveMerchant #:nodoc:
80
80
 
81
81
  def build_setup_request(action, money, options)
82
82
  xml = Builder::XmlMarkup.new :indent => 2
83
- xml.tag! 'SetExpressCheckoutReq', 'xmlns' => 'urn:ebay:api:PayPalAPI' do
84
- xml.tag! 'SetExpressCheckoutRequest', 'xmlns:n2' => 'urn:ebay:apis:eBLBaseComponents' do
83
+ xml.tag! 'SetExpressCheckoutReq', 'xmlns' => PAYPAL_NAMESPACE do
84
+ xml.tag! 'SetExpressCheckoutRequest', 'xmlns:n2' => EBAY_NAMESPACE do
85
85
  xml.tag! 'n2:Version', '2.0'
86
86
  xml.tag! 'n2:SetExpressCheckoutRequestDetails' do
87
87
  xml.tag! 'n2:PaymentAction', action
@@ -162,7 +162,7 @@ module ActiveMerchant #:nodoc:
162
162
  def credit(money, identification, options = {})
163
163
  parameters = {
164
164
  :amount => amount(money),
165
- :transid => identification,
165
+ :transid => identification
166
166
  }
167
167
 
168
168
  commit('credit', parameters)
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: activemerchant
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.0
7
- date: 2007-02-20 00:00:00 -05:00
6
+ version: 1.0.1
7
+ date: 2007-02-21 00:00:00 -05:00
8
8
  summary: Framework and tools for dealing with credit card transactions.
9
9
  require_paths:
10
10
  - lib