virtual_merchant 0.3.5 → 0.3.6

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: f6ca7cbb9d65a0a2a00731c69a236d6494acdd23
4
- data.tar.gz: fe1c36484a1773707966d174e7f47056d4f39bc2
3
+ metadata.gz: e254a4ac57dd98de1815472d1917cb35880faa4c
4
+ data.tar.gz: 901f1cd93d01ff0486f87ebab0dcf7b09658120d
5
5
  SHA512:
6
- metadata.gz: 5fcc4f723fe2dda3c59202c0ad7be37dd126070e1ab7a32b69ef6610f5b60a2ee9e7435992c81118dfa8fe6c574c8507c489878a1d8d8ac6b17d4570d56a4891
7
- data.tar.gz: 306247aa0420dcf3fe86d3e1be29ea41dab737830ce93e32bfb4dc170a996c36d0595f1c2fa47cb3a7234f0c93109e86cc9a4ff4ab0ab06904cf1eebc9c24b19
6
+ metadata.gz: a29c5b03dc6621083d98d9ea4f5ab39200510a2e7938fbc0d1284cf1c8b7c566428fcfa1090edc3949ff643c04ff603371701dfc4219d8f29382b16e8f3b748a
7
+ data.tar.gz: 13038ff17dcf6d4a2a1952b70604dae4565300894dec0ed3c64f85c2d7a2ab8c205fcd85bbecee4e076d4d9c883a38775cdd1cd4f39c8b40e80807be25d18e8d
@@ -3,15 +3,15 @@ module VirtualMerchant
3
3
  attr_accessor :account_id, :user_id, :pin, :referer, :demo, :source, :ksn,
4
4
  :device_type, :vendor_id
5
5
  def initialize(info)
6
- @account_id = info[:account_id].to_s
7
- @user_id = info[:user_id].to_s
8
- @pin = info[:pin].to_s
9
- @source = info[:source].to_s
10
- @ksn = info[:ksn].to_s
11
- @vendor_id = info[:vendor_id].to_s
12
- @device_type = info[:device_type].to_s
13
- @referer = info[:referer].to_s
14
- @demo = info[:demo] || false
6
+ @account_id = info[:account_id].to_s
7
+ @user_id = info[:user_id].to_s
8
+ @pin = info[:pin].to_s
9
+ @source = info[:source].to_s
10
+ @ksn = info[:ksn].to_s
11
+ @vendor_id = info[:vendor_id].to_s
12
+ @device_type = info[:device_type].to_s
13
+ @referer = info[:referer].to_s
14
+ @demo = info[:demo] || false
15
15
  end
16
16
  end
17
17
  end
@@ -11,6 +11,22 @@ class Gateway
11
11
  process(xml, amount)
12
12
  end
13
13
 
14
+ def ccauth(card, amount)
15
+ xml = VirtualMerchant::XMLGenerator.generate(card, amount, creds, "ccauthonly")
16
+ process(xml, amount)
17
+ end
18
+
19
+ def cccomplete(amount, transaction_id)
20
+ xml = VirtualMerchant::XMLGenerator.modify(creds, "cccomplete",
21
+ transaction_id, amount)
22
+ process(xml, amount)
23
+ end
24
+
25
+ def ccdelete(transaction_id)
26
+ xml = VirtualMerchant::XMLGenerator.modify(creds, "ccdelete", transaction_id)
27
+ process(xml)
28
+ end
29
+
14
30
  def ccaddrecurring(card, amount)
15
31
  xml = VirtualMerchant::XMLGenerator.generate(card, amount, creds, "ccaddrecurring")
16
32
  process(xml, amount)
@@ -61,8 +61,8 @@ module VirtualMerchant
61
61
 
62
62
  def normal_approval(xml)
63
63
  @result = xml.elements["ssl_result"].text
64
- @approval_code = xml.elements["ssl_approval_code"].text
65
- @cvv2_response = xml.elements["ssl_cvv2_response"].text
64
+ @approval_code = xml.elements["ssl_approval_code"].text if xml.elements["ssl_approval_code"]
65
+ @cvv2_response = xml.elements["ssl_cvv2_response"].text if xml.elements["ssl_cvv2_response"]
66
66
  @transaction_id = xml.elements["ssl_txn_id"].text
67
67
  @transaction_time = xml.elements["ssl_txn_time"].text
68
68
  end
@@ -13,7 +13,8 @@ module VirtualMerchant
13
13
 
14
14
  def self.generate(card, amount, creds, transaction_type)
15
15
  xml = "xmldata=<txn>"
16
- xml += basic(card, creds, transaction_type, amount)
16
+ xml += credentials(creds)
17
+ xml += basic(card, transaction_type, amount)
17
18
  xml += for_recurring(amount) if transaction_type == 'ccaddrecurring'
18
19
  if card.encrypted?
19
20
  xml += for_encrypted(card, creds)
@@ -24,12 +25,27 @@ module VirtualMerchant
24
25
  xml
25
26
  end
26
27
 
28
+ def self.modify(creds, transaction_type, transaction_id, amount=0)
29
+ xml = "xmldata=<txn>"
30
+ xml += credentials(creds)
31
+ xml += "<ssl_transaction_type>#{transaction_type}</ssl_transaction_type>
32
+ <ssl_txn_id>#{transaction_id}</ssl_txn_id>"
33
+ if transaction_type == 'cccomplete'
34
+ xml += "<ssl_amount>#{amount.total}</ssl_amount>"
35
+ end
36
+ xml += "</txn>"
37
+ xml
38
+ end
39
+
27
40
  private
28
- def self.basic(card, creds, transaction_type, amount)
41
+ def self.credentials(creds)
29
42
  "<ssl_merchant_id>#{creds.account_id}</ssl_merchant_id>
30
43
  <ssl_user_id>#{creds.user_id}</ssl_user_id>
31
- <ssl_pin>#{creds.pin}</ssl_pin>
32
- <ssl_transaction_type>#{transaction_type}</ssl_transaction_type>
44
+ <ssl_pin>#{creds.pin}</ssl_pin>"
45
+ end
46
+
47
+ def self.basic(card, transaction_type, amount)
48
+ "<ssl_transaction_type>#{transaction_type}</ssl_transaction_type>
33
49
  <ssl_amount>#{amount.total}</ssl_amount>
34
50
  <ssl_salestax>#{amount.tax}</ssl_salestax>
35
51
  <ssl_customer_code>#{card.last_four}</ssl_customer_code>
@@ -12,6 +12,18 @@ module VirtualMerchant
12
12
  gateway.ccsale(card, amount)
13
13
  end
14
14
 
15
+ def self.authorize(card, amount, creds, gateway=Gateway.new(creds))
16
+ gateway.ccauth(card, amount)
17
+ end
18
+
19
+ def self.complete(amount, creds, transaction_id, gateway=Gateway.new(creds))
20
+ gateway.cccomplete(amount, transaction_id)
21
+ end
22
+
23
+ def self.delete(creds, transaction_id, gateway=Gateway.new(creds))
24
+ gateway.ccdelete(transaction_id)
25
+ end
26
+
15
27
  def self.add_recurring(card, amount, creds, gateway=Gateway.new(creds))
16
28
  gateway.ccaddrecurring(card, amount)
17
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: virtual_merchant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Quarella