six_saferpay 2.1.1 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.test.env +1 -1
- data/Gemfile.lock +1 -1
- data/README.md +17 -0
- data/lib/six_saferpay/api.rb +1 -1
- data/lib/six_saferpay/api/six_secure_pay_gate_offer/requests/create_offer.rb +61 -0
- data/lib/six_saferpay/api/six_secure_pay_gate_offer/responses/create_offer_response.rb +26 -0
- data/lib/six_saferpay/client.rb +8 -2
- data/lib/six_saferpay/clients/secure_pay_gate_api/client.rb +23 -0
- data/lib/six_saferpay/models/request_payment_means.rb +6 -2
- data/lib/six_saferpay/models/saferpay_fields.rb +18 -0
- data/lib/six_saferpay/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e778cad093369c363bebe5c4c0ce5242ac291ca5008bb5c59f965c3c65a4acc
|
4
|
+
data.tar.gz: f34b4aad57145c97b5a401363d3121f0124a201713c58ca948a35adbb118bc5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f0ec0b7c13ec5ec55a832a55875fc77bec867f93697ae5de60c59711ce5f47280a2333e4971d29dedc2a2c72e158addbaf719096a540da26a8ca63bc5e64bc0
|
7
|
+
data.tar.gz: 852315203df9b3db10f95feb85aa6ee755f35a025c7c5bfbea1c2d5d904e4ef0b0290ca49fd10be5a2755a0fcda5bf8a5f0c5d4417540882645ea92b268d514a
|
data/.test.env
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,6 +4,10 @@
|
|
4
4
|
|
5
5
|
# SixSaferpay
|
6
6
|
|
7
|
+
## Current API Version
|
8
|
+
|
9
|
+
This gem is compatible with the SIX API version: `1.14`
|
10
|
+
|
7
11
|
## Installation
|
8
12
|
|
9
13
|
Add this line to your application's Gemfile:
|
@@ -79,6 +83,15 @@ You will find for all the other requests an predefined object. Feel free to use
|
|
79
83
|
|
80
84
|
TODO
|
81
85
|
|
86
|
+
#### SIX Secure PayGate API
|
87
|
+
|
88
|
+
If you want to use the SIX Secure PayGate API, you have to use an other Client:
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
create_offer_request = SixSaferpay::SecurePayGateOffer.new(...)
|
92
|
+
create_offer_response = SixSaferpay::SecurePayGateApi::Client.new(create_offer_request)
|
93
|
+
```
|
94
|
+
|
82
95
|
## Documentation
|
83
96
|
|
84
97
|
[SIX Saferpay JSON API](https://saferpay.github.io/jsonapi)
|
@@ -136,6 +149,10 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERN
|
|
136
149
|
- [x] InsertAlias
|
137
150
|
- [x] AcquireTransaction
|
138
151
|
|
152
|
+
#### Secure PayGate API
|
153
|
+
|
154
|
+
- [x] CreateOffer
|
155
|
+
|
139
156
|
## License
|
140
157
|
|
141
158
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/six_saferpay/api.rb
CHANGED
@@ -0,0 +1,61 @@
|
|
1
|
+
module SixSaferpay
|
2
|
+
module SixSecurePayGateOffer
|
3
|
+
class CreateOffer
|
4
|
+
|
5
|
+
attr_accessor(:payment,
|
6
|
+
:expiration_date,
|
7
|
+
:config_set,
|
8
|
+
:payer,
|
9
|
+
:billing_address_form
|
10
|
+
)
|
11
|
+
|
12
|
+
def initialize(payment: ,
|
13
|
+
expiration_date: ,
|
14
|
+
config_set: nil,
|
15
|
+
payer: ,
|
16
|
+
billing_address_form: nil
|
17
|
+
)
|
18
|
+
|
19
|
+
@payment = SixSaferpay::Payment.new(payment.to_h) if payment
|
20
|
+
@expiration_date = expiration_date
|
21
|
+
@config_set = config_set
|
22
|
+
@payer = SixSaferpay::Payer.new(payer.to_h) if payer
|
23
|
+
@billing_address_form =
|
24
|
+
SixSaferpay::BillingAddressForm.new(billing_address_form) if billing_address_form
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_hash
|
28
|
+
hash = Hash.new
|
29
|
+
hash.merge!(payment: @payment.to_h) if @payment
|
30
|
+
hash.merge!(expiration_date: @expiration_date) if @expiration_date
|
31
|
+
hash.merge!(config_set: @config_set) if @config_set
|
32
|
+
hash.merge!(payer: @payer.to_h) if @payer
|
33
|
+
hash.merge!(billing_address_form: @billing_address_form.to_h) if @billing_address_form
|
34
|
+
hash
|
35
|
+
end
|
36
|
+
alias_method :to_h, :to_hash
|
37
|
+
|
38
|
+
def to_json
|
39
|
+
to_hash.to_json
|
40
|
+
end
|
41
|
+
|
42
|
+
def url
|
43
|
+
"/rest/customers/#{customer_id}/terminals/#{terminal_id}/spg-offers"
|
44
|
+
end
|
45
|
+
|
46
|
+
def response_class
|
47
|
+
SixSaferpay::SixSecurePayGateOffer::CreateOfferResponse
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def customer_id
|
53
|
+
SixSaferpay.config.customer_id
|
54
|
+
end
|
55
|
+
|
56
|
+
def terminal_id
|
57
|
+
SixSaferpay.config.terminal_id
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module SixSaferpay
|
2
|
+
module SixSecurePayGateOffer
|
3
|
+
class CreateOfferResponse
|
4
|
+
|
5
|
+
attr_accessor(:offer_id,
|
6
|
+
:payment_link
|
7
|
+
)
|
8
|
+
|
9
|
+
def initialize(offer_id:,
|
10
|
+
payment_link: )
|
11
|
+
|
12
|
+
@offer_id = offer_id if offer_id
|
13
|
+
@payment_link = payment_link if payment_link
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_hash
|
17
|
+
hash = Hash.new
|
18
|
+
hash.merge!(offer_id: @offer_id) if @offer_id
|
19
|
+
hash.merge!(payment_link: @payment_link) if @payment_link
|
20
|
+
hash
|
21
|
+
end
|
22
|
+
alias_method :to_h, :to_hash
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/six_saferpay/client.rb
CHANGED
@@ -17,17 +17,23 @@ module SixSaferpay
|
|
17
17
|
hash = @response.body
|
18
18
|
hash = JSON.parse(hash, symbolize_names: true)
|
19
19
|
hash = transform_response_hash(hash)
|
20
|
-
if @response.code ==
|
20
|
+
if @response.code == '200'
|
21
21
|
@object.response_class.new(hash)
|
22
22
|
else
|
23
23
|
raise SixSaferpay::Error.new(hash)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
protected
|
28
|
+
|
29
|
+
def header
|
30
|
+
{"Content-Type" => 'application/json'}
|
31
|
+
end
|
32
|
+
|
27
33
|
private
|
28
34
|
|
29
35
|
def request
|
30
|
-
request = Net::HTTP::Post.new(uri.path,
|
36
|
+
request = Net::HTTP::Post.new(uri.path, header)
|
31
37
|
hash = @object.to_h
|
32
38
|
hash = transform_request_hash(hash)
|
33
39
|
hash = hash.to_json
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module SixSaferpay
|
2
|
+
module SecurePayGateApi
|
3
|
+
class Client < SixSaferpay::Client
|
4
|
+
|
5
|
+
protected
|
6
|
+
|
7
|
+
def header
|
8
|
+
super.merge!(
|
9
|
+
{
|
10
|
+
'Saferpay-ApiVersion' => SixSaferpay::API::VERSION,
|
11
|
+
'Saferpay-RequestId' => request_id()
|
12
|
+
}
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def request_id
|
19
|
+
@request_id ||= SecureRandom.uuid
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -3,16 +3,19 @@ module SixSaferpay
|
|
3
3
|
|
4
4
|
attr_accessor(:card,
|
5
5
|
:bank_account,
|
6
|
-
:fd_alias
|
6
|
+
:fd_alias,
|
7
|
+
:saferpay_fields
|
7
8
|
)
|
8
9
|
|
9
10
|
def initialize(card: nil,
|
10
11
|
bank_account: nil,
|
11
|
-
fd_alias: nil
|
12
|
+
fd_alias: nil,
|
13
|
+
saferpay_fields: nil
|
12
14
|
)
|
13
15
|
@card = SixSaferpay::RequestCard.new(card.to_h) if card
|
14
16
|
@bank_account = SixSaferpay::BankAccount.new(bank_account.to_h) if bank_account
|
15
17
|
@fd_alias = SixSaferpay::PaymentMeansAlias.new(fd_alias.to_h) if fd_alias
|
18
|
+
@saferpay_fields = SixSaferpay::SaferpayFields.new(saferpay_fields.to_h) if saferpay_fields
|
16
19
|
end
|
17
20
|
|
18
21
|
def to_hash
|
@@ -20,6 +23,7 @@ module SixSaferpay
|
|
20
23
|
hash.merge!(card: @card.to_h) if @card
|
21
24
|
hash.merge!(bank_account: @bank_account.to_h) if @bank_account
|
22
25
|
hash.merge!(fd_alias: @fd_alias.to_h) if @fd_alias
|
26
|
+
hash.merge!(saferpay_fields: @saferpay_fields.to_h) if @saferpay_fields
|
23
27
|
hash
|
24
28
|
end
|
25
29
|
alias_method :to_h, :to_hash
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module SixSaferpay
|
2
|
+
class SaferpayFields
|
3
|
+
|
4
|
+
attr_accessor :token
|
5
|
+
|
6
|
+
def initialize(token: )
|
7
|
+
@token = token
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_hash
|
11
|
+
hash = Hash.new
|
12
|
+
hash.merge!(token: @token) if @token
|
13
|
+
hash
|
14
|
+
end
|
15
|
+
alias_method :to_h, :to_hash
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
data/lib/six_saferpay/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: six_saferpay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fadendaten GmbH
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-11-
|
12
|
+
date: 2019-11-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -232,6 +232,8 @@ files:
|
|
232
232
|
- lib/six_saferpay/api/six_secure_card_data/responses/insert_direct_response.rb
|
233
233
|
- lib/six_saferpay/api/six_secure_card_data/responses/insert_response.rb
|
234
234
|
- lib/six_saferpay/api/six_secure_card_data/responses/update_response.rb
|
235
|
+
- lib/six_saferpay/api/six_secure_pay_gate_offer/requests/create_offer.rb
|
236
|
+
- lib/six_saferpay/api/six_secure_pay_gate_offer/responses/create_offer_response.rb
|
235
237
|
- lib/six_saferpay/api/six_transaction/requests/adjust_amount.rb
|
236
238
|
- lib/six_saferpay/api/six_transaction/requests/alternative_payment.rb
|
237
239
|
- lib/six_saferpay/api/six_transaction/requests/assert_capture.rb
|
@@ -267,6 +269,7 @@ files:
|
|
267
269
|
- lib/six_saferpay/api/six_transaction/responses/refund_direct_response.rb
|
268
270
|
- lib/six_saferpay/api/six_transaction/responses/refund_response.rb
|
269
271
|
- lib/six_saferpay/client.rb
|
272
|
+
- lib/six_saferpay/clients/secure_pay_gate_api/client.rb
|
270
273
|
- lib/six_saferpay/errors/error.rb
|
271
274
|
- lib/six_saferpay/models/address.rb
|
272
275
|
- lib/six_saferpay/models/address_form.rb
|
@@ -323,6 +326,7 @@ files:
|
|
323
326
|
- lib/six_saferpay/models/response_header.rb
|
324
327
|
- lib/six_saferpay/models/response_payment_means.rb
|
325
328
|
- lib/six_saferpay/models/return_urls.rb
|
329
|
+
- lib/six_saferpay/models/saferpay_fields.rb
|
326
330
|
- lib/six_saferpay/models/six_transaction.rb
|
327
331
|
- lib/six_saferpay/models/styling.rb
|
328
332
|
- lib/six_saferpay/models/three_ds.rb
|