adyen-cse-ruby 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/README.md +66 -0
- data/lib/adyen_cse/encrypter.rb +8 -3
- data/lib/adyen_cse/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 782ff730d1ac1d0476cba0dbefc6be067b728b1b
|
4
|
+
data.tar.gz: 7bbce7b21d58a8036efae5332882cdd4ccf4a6ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e191247e97b161da4d1eef3cc24c319a10118d6ec38b8b1bca29634d5957120447f47944dcdd13417390b93bd230fc81896d0434f84a2c0c058d3acb701a2c2f
|
7
|
+
data.tar.gz: 08aab6a28c4aa756ae744af7a3493e469a5461c8aa0535a22603bb15b1a2e66743dff1313e49cebf7484b830fbfc99267211bcf114c5120d02d9a037ebe4c4f7
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -48,3 +48,69 @@ encrypted_card = cse.encrypt!(
|
|
48
48
|
generation_time: Time.new(2015, 10, 21)
|
49
49
|
)
|
50
50
|
```
|
51
|
+
|
52
|
+
## factory_bot integration
|
53
|
+
Example of an `:adyen_test_card` factory with [factory_bot](https://github.com/thoughtbot/factory_bot).
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
# ./spec/factories/adyen_test_card.rb
|
57
|
+
|
58
|
+
require 'adyen_cse'
|
59
|
+
|
60
|
+
class AdyenTestCard
|
61
|
+
attr_reader :holder_name, :number, :expiry_month, :expiry_year, :cvc, :nonce
|
62
|
+
|
63
|
+
def initialize(params = {})
|
64
|
+
@holder_name = params[:holder_name]
|
65
|
+
@number = params[:number]
|
66
|
+
@expiry_month = params[:expiry_month]
|
67
|
+
@expiry_year = params[:expiry_year]
|
68
|
+
@cvc = params[:cvc]
|
69
|
+
@nonce = params[:nonce]
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.public_key
|
73
|
+
"your_public_key_here"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
FactoryBot.define do
|
78
|
+
factory :adyen_test_card do
|
79
|
+
sequence(:holder_name) { |n| "Shopper #{n}" }
|
80
|
+
number { 4111_1111_1111_1111.to_s }
|
81
|
+
expiry_month { '08' }
|
82
|
+
expiry_year { '2018' }
|
83
|
+
cvc { '737' }
|
84
|
+
|
85
|
+
nonce do
|
86
|
+
AdyenCse::Encrypter.new(AdyenTestCard.public_key).encrypt!(
|
87
|
+
holder_name: holder_name,
|
88
|
+
number: number,
|
89
|
+
expiry_month: expiry_month,
|
90
|
+
expiry_year: expiry_year,
|
91
|
+
cvc: cvc
|
92
|
+
)
|
93
|
+
end
|
94
|
+
|
95
|
+
trait :mastercard do
|
96
|
+
number { 5555_5555_5555_4444.to_s }
|
97
|
+
end
|
98
|
+
|
99
|
+
trait :amex do
|
100
|
+
number { 3451_779254_88348.to_s }
|
101
|
+
cvc { '7373' }
|
102
|
+
end
|
103
|
+
|
104
|
+
skip_create
|
105
|
+
initialize_with { new(attributes) }
|
106
|
+
end
|
107
|
+
end
|
108
|
+
```
|
109
|
+
|
110
|
+
Example usage:
|
111
|
+
```ruby
|
112
|
+
RSpec.describe ExamplePaymentService do
|
113
|
+
let(:credit_card) { FactoryBot.build(:adyen_test_card) }
|
114
|
+
...
|
115
|
+
end
|
116
|
+
```
|
data/lib/adyen_cse/encrypter.rb
CHANGED
@@ -45,9 +45,14 @@ module AdyenCse
|
|
45
45
|
def self.parse_public_key(public_key)
|
46
46
|
exponent, modulus = public_key.split("|").map { |n| n.to_i(16) }
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
if RUBY_VERSION <= "2.3.1"
|
49
|
+
OpenSSL::PKey::RSA.new.tap do |rsa|
|
50
|
+
rsa.e = OpenSSL::BN.new(exponent)
|
51
|
+
rsa.n = OpenSSL::BN.new(modulus)
|
52
|
+
end
|
53
|
+
else
|
54
|
+
rsa = OpenSSL::PKey::RSA.new
|
55
|
+
rsa.set_key(OpenSSL::BN.new(modulus), OpenSSL::BN.new(exponent), nil)
|
51
56
|
end
|
52
57
|
end
|
53
58
|
|
data/lib/adyen_cse/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adyen-cse-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joey Cheng
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: openssl-ccm
|