adyen-cse-ruby 1.0.0 → 1.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: de9816514bfde8a7e82bc80437fadc0ebc0bd8b6
4
- data.tar.gz: 7cd1f25ceeba3b576e42bdbd78949c30312583c6
3
+ metadata.gz: 782ff730d1ac1d0476cba0dbefc6be067b728b1b
4
+ data.tar.gz: 7bbce7b21d58a8036efae5332882cdd4ccf4a6ae
5
5
  SHA512:
6
- metadata.gz: 476aa8acce591d1db06253e9c3579775a520d5343b32b4f51422d0ed6587b0853285316d72828429afe8e7284775a51b8e653af4d35d61884f0e94aedb6afe10
7
- data.tar.gz: 0c695bf5902c7d6323b49f6f4e6bc23b4c03e54033e97e6ab3987a9cd6479e92cb3c3d4966f336340501ea0e9f05b4be2695d2d7efe0af72154c96842ca971b1
6
+ metadata.gz: e191247e97b161da4d1eef3cc24c319a10118d6ec38b8b1bca29634d5957120447f47944dcdd13417390b93bd230fc81896d0434f84a2c0c058d3acb701a2c2f
7
+ data.tar.gz: 08aab6a28c4aa756ae744af7a3493e469a5461c8aa0535a22603bb15b1a2e66743dff1313e49cebf7484b830fbfc99267211bcf114c5120d02d9a037ebe4c4f7
@@ -2,4 +2,6 @@ sudo: false
2
2
  language: ruby
3
3
  rvm:
4
4
  - 2.3.1
5
+ - 2.4.4
6
+ - 2.5.1
5
7
  before_install: gem install bundler -v 1.14.6
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
+ ```
@@ -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
- OpenSSL::PKey::RSA.new.tap do |rsa|
49
- rsa.e = OpenSSL::BN.new(exponent)
50
- rsa.n = OpenSSL::BN.new(modulus)
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
 
@@ -1,3 +1,3 @@
1
1
  module AdyenCse
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
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.0.0
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-03-09 00:00:00.000000000 Z
11
+ date: 2018-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: openssl-ccm