cic_payment 0.4 → 0.4.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.
- checksums.yaml +4 -4
- data/cic_payment.gemspec +1 -1
- data/lib/cic_payment.rb +35 -33
- data/lib/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8871afe40aa1ae38a2866977e68de252f4f82a45
|
4
|
+
data.tar.gz: 53ffbc797742f39cf8967de16437a93df3fd8878
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c253796bf67f908754ec5c71e9b2232362ff6719f8b1318dbdccf3ec520edcd3d9136d94dbd868ce9edb9e561dd7687dcdb32d84086bee33c1bb4eb7304a883
|
7
|
+
data.tar.gz: ed603293928cbba1a1350898e6750472de42a6db0c58404348cce327774c079e0642204206c9b43eaf601164bbaf8c575aa5c63b5d25f27219627d7776f8d105
|
data/cic_payment.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "cic_payment"
|
6
|
-
s.version = "0.4"
|
6
|
+
s.version = "0.4.1"
|
7
7
|
s.date = "2014-03-18"
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ["Novelys Team", 'Guillaume Barillot', 'Regis Millet (aka Kulgar)']
|
data/lib/cic_payment.rb
CHANGED
@@ -51,44 +51,44 @@ class CicPayment < PaymentSettings
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def response(params)
|
54
|
-
|
55
54
|
if verify_hmac(params)
|
56
|
-
|
57
|
-
|
55
|
+
case params['code-retour']
|
56
|
+
when "Annulation"
|
58
57
|
params.update(:success => false)
|
59
|
-
|
60
|
-
elsif params['code-retour'] == "payetest"
|
61
|
-
params.update(:success => true)
|
62
|
-
|
63
|
-
elsif params['code-retour'] == "paiement"
|
58
|
+
when "payetest", "paiement"
|
64
59
|
params.update(:success => true)
|
60
|
+
else
|
61
|
+
params.update(:success => false)
|
65
62
|
end
|
66
|
-
|
67
63
|
else
|
68
64
|
params.update(:success => false)
|
69
65
|
end
|
70
|
-
|
71
66
|
end
|
72
67
|
|
73
|
-
|
74
|
-
|
75
|
-
|
68
|
+
# Use this function for your tests to create the mac properly
|
69
|
+
def response_mac params
|
70
|
+
# The HMAC returned by the bank uses this chain:
|
71
|
+
# <TPE>*<date>*<montant>*<reference>*<texte-libre>*3.0*<code-retour>*
|
72
|
+
# <cvx>*<vld>*<brand>*<status3ds>*<numauto>*<motifrefus>*<originecb>*
|
73
|
+
# <bincb>*<hpancb>*<ipclient>*<originetr>*<veres>*<pares>*
|
74
|
+
chain = [
|
75
|
+
self.tpe, params['date'], params['montant'], params['reference'], params['texte-libre'], self.version, params['code-retour'],
|
76
|
+
params['cvx'], params['vld'], params['brand'], params['status3ds'], params["numauto"], params['motifrefus'], params['originecb'],
|
77
|
+
params['bincb'], params['hpancb'], params['ipclient'], params['originetr'], params['veres'], params['pares'], ""
|
78
|
+
].join('*')
|
79
|
+
|
80
|
+
hmac_token(false, chain)
|
76
81
|
end
|
77
82
|
|
78
83
|
def verify_hmac params
|
79
|
-
mac_string = [self.tpe, params['date'], params['montant'], params['reference'], params['texte-libre'], self.version, params['code-retour'], params['cvx'], params['vld'], params['brand'], params['status3ds'], params['numauto'], params['motifrefus'], params['originecb'], params['bincb'], params['hpancb'], params['ipclient'], params['originetr'], params['veres'], params['pares']].join('*') + "*"
|
80
|
-
|
81
84
|
params['MAC'] ? hmac = params['MAC'] : hmac = ""
|
82
|
-
self.valid_hmac?(hmac)
|
83
|
-
end
|
84
85
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
end
|
86
|
+
# Check if the HMAC matches the HMAC of the data string
|
87
|
+
response_mac(params) == hmac
|
88
|
+
end
|
89
89
|
|
90
90
|
# Return the HMAC for a data string
|
91
|
-
def hmac_token
|
91
|
+
def hmac_token(form_hmac = true, chain = nil)
|
92
92
|
# This chain must contains:
|
93
93
|
# <TPE>*<date>*<montant>*<reference>*<texte-libre>*<version>*<lgue>*<societe>*<mail>*
|
94
94
|
# <nbrech>*<dateech1>*<montantech1>*<dateech2>*<montantech2>*<dateech3>*<montantech3>*
|
@@ -103,17 +103,19 @@ class CicPayment < PaymentSettings
|
|
103
103
|
# For a fragmented payment:
|
104
104
|
# 1234567*05/12/2006:11:55:23*62.73EUR*ABERTYP00145*ExempleTexteLibre*3.0*FR*monSite1*internaute@sonemail.fr*
|
105
105
|
# 4*05/12/2006*16.23EUR*05/01/2007*15.5EUR*05/02/2007*15.5EUR*05/03/2007*15.5EUR*
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
106
|
+
if form_hmac && chain.blank?
|
107
|
+
chain = [self.tpe,
|
108
|
+
self.date,
|
109
|
+
self.montant,
|
110
|
+
self.reference,
|
111
|
+
self.texte_libre,
|
112
|
+
self.version,
|
113
|
+
self.lgue,
|
114
|
+
self.societe,
|
115
|
+
self.mail,
|
116
|
+
"", "", "", "", "", "", "", "", "", "" # 10 stars: 9 for fragmented unfilled params + 1 final star
|
117
|
+
].join("*")
|
118
|
+
end
|
117
119
|
|
118
120
|
hmac_sha1(usable_key(self.hmac_key), chain).downcase
|
119
121
|
end
|
data/lib/version.rb
CHANGED