six_saferpay 2.1.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.test.env +1 -1
- data/.travis.yml +4 -2
- data/Gemfile.lock +70 -85
- data/README.md +18 -0
- data/lib/six_saferpay/api.rb +1 -1
- data/lib/six_saferpay/api/six_payment_page/requests/initialize.rb +4 -0
- data/lib/six_saferpay/api/six_payment_page/responses/assert_response.rb +11 -2
- 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/api/six_transaction/requests/authorize_direct.rb +4 -0
- data/lib/six_saferpay/api/six_transaction/requests/authorize_referenced.rb +4 -0
- data/lib/six_saferpay/api/six_transaction/requests/capture.rb +11 -2
- data/lib/six_saferpay/api/six_transaction/requests/initialize.rb +4 -0
- data/lib/six_saferpay/api/six_transaction/responses/authorize_direct_response.rb +11 -2
- data/lib/six_saferpay/api/six_transaction/responses/authorize_response.rb +11 -3
- 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/address.rb +4 -4
- data/lib/six_saferpay/models/authentication.rb +36 -0
- data/lib/six_saferpay/models/authentication_result.rb +20 -0
- data/lib/six_saferpay/models/check_result.rb +6 -2
- data/lib/six_saferpay/models/chosen_plan.rb +62 -0
- data/lib/six_saferpay/models/custom_plan.rb +4 -0
- data/lib/six_saferpay/models/first_installment_amount.rb +4 -0
- data/lib/six_saferpay/models/ideal.rb +18 -0
- data/lib/six_saferpay/models/installment_fee.rb +4 -0
- data/lib/six_saferpay/models/installment_plans.rb +73 -0
- data/lib/six_saferpay/models/mastercard_issuer_installments.rb +49 -0
- data/lib/six_saferpay/models/payment_methods_options.rb +4 -2
- data/lib/six_saferpay/models/registration_result.rb +11 -2
- 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/models/subsequent_installment_amount.rb +4 -0
- data/lib/six_saferpay/models/total_amont_due.rb +4 -0
- data/lib/six_saferpay/version.rb +1 -1
- data/six_saferpay.gemspec +8 -8
- metadata +38 -24
@@ -6,6 +6,7 @@ module SixSaferpay
|
|
6
6
|
:terminal_id,
|
7
7
|
:payment,
|
8
8
|
:transaction_reference,
|
9
|
+
:authentication,
|
9
10
|
:suppress_dcc
|
10
11
|
)
|
11
12
|
|
@@ -14,12 +15,14 @@ module SixSaferpay
|
|
14
15
|
terminal_id: nil,
|
15
16
|
payment:,
|
16
17
|
transaction_reference:,
|
18
|
+
authentication: nil,
|
17
19
|
suppress_dcc:
|
18
20
|
)
|
19
21
|
@request_header = request_header || SixSaferpay::RequestHeader.new()
|
20
22
|
@terminal_id = terminal_id || SixSaferpay.config.terminal_id
|
21
23
|
@payment = SixSaferpay::Payment.new(payment.to_h) if payment
|
22
24
|
@transaction_reference = SixSaferpay::TransactionReference.new(transaction_reference.to_h) if transaction_reference
|
25
|
+
@authentication = SixSaferpay::Authentication.new(authentication.to_h) if authentication
|
23
26
|
@suppress_dcc = suppress_dcc
|
24
27
|
end
|
25
28
|
|
@@ -29,6 +32,7 @@ module SixSaferpay
|
|
29
32
|
hash.merge!(terminal_id: @terminal_id) if @terminal_id
|
30
33
|
hash.merge!(payment: @payment.to_h) if @payment
|
31
34
|
hash.merge!(transaction_reference: @transaction_reference.to_h) if @transaction_reference
|
35
|
+
hash.merge!(authentication: @authentication.to_h) if @authentication
|
32
36
|
hash.merge!(suppress_dcc: @suppress_dcc) if !@suppress_dcc.nil?
|
33
37
|
hash
|
34
38
|
end
|
@@ -7,7 +7,8 @@ module SixSaferpay
|
|
7
7
|
:amount,
|
8
8
|
:billpay,
|
9
9
|
:pending_notification,
|
10
|
-
:marketplace
|
10
|
+
:marketplace,
|
11
|
+
:mastercard_issuer_installments
|
11
12
|
)
|
12
13
|
|
13
14
|
|
@@ -16,7 +17,8 @@ module SixSaferpay
|
|
16
17
|
amount: nil,
|
17
18
|
billpay: nil,
|
18
19
|
pending_notification: nil,
|
19
|
-
marketplace: nil
|
20
|
+
marketplace: nil,
|
21
|
+
mastercard_issuer_installments: nil
|
20
22
|
)
|
21
23
|
@request_header = request_header || SixSaferpay::RequestHeader.new()
|
22
24
|
@transaction_reference = SixSaferpay::TransactionReference.new(transaction_reference.to_h) if transaction_reference
|
@@ -24,6 +26,10 @@ module SixSaferpay
|
|
24
26
|
@billpay = SixSaferpay::Billpay.new(billpay.to_h) if billpay
|
25
27
|
@pending_notification = SixSaferpay::PendingNotification.new(pending_notification.to_h) if pending_notification
|
26
28
|
@marketplace = SixSaferpay::Marketplace.new(marketplace.to_h) if marketplace
|
29
|
+
if mastercard_issuer_installments
|
30
|
+
@mastercard_issuer_installments = SixSaferpay::MastercardIssuerInstallments
|
31
|
+
.new(mastercard_issuer_installments.to_h)
|
32
|
+
end
|
27
33
|
end
|
28
34
|
|
29
35
|
def to_hash
|
@@ -34,6 +40,9 @@ module SixSaferpay
|
|
34
40
|
hash.merge!(billpay: @billpay.to_h) if @billpay
|
35
41
|
hash.merge!(pending_notification: @pending_notification.to_h) if @pending_notification
|
36
42
|
hash.merge!(marketplace: @marketplace.to_h) if @marketplace
|
43
|
+
if @mastercard_issuer_installments
|
44
|
+
hash.merge!(mastercard_issuer_installments: mastercard_issuer_installments.to_h)
|
45
|
+
end
|
37
46
|
hash
|
38
47
|
end
|
39
48
|
alias_method :to_h, :to_hash
|
@@ -8,6 +8,7 @@ module SixSaferpay
|
|
8
8
|
:terminal_id,
|
9
9
|
:payment,
|
10
10
|
:payment_means,
|
11
|
+
:authentication,
|
11
12
|
:payer,
|
12
13
|
:return_urls,
|
13
14
|
:styling,
|
@@ -22,6 +23,7 @@ module SixSaferpay
|
|
22
23
|
terminal_id: nil,
|
23
24
|
payment:,
|
24
25
|
payment_means: nil,
|
26
|
+
authentication: nil,
|
25
27
|
payer: nil,
|
26
28
|
return_urls: nil,
|
27
29
|
styling: nil,
|
@@ -34,6 +36,7 @@ module SixSaferpay
|
|
34
36
|
@terminal_id = terminal_id || SixSaferpay.config.terminal_id
|
35
37
|
@payment = SixSaferpay::Payment.new(payment.to_h) if payment
|
36
38
|
@payment_means = SixSaferpay::RequestPaymentMeans.new(payment_means.to_h) if payment_means
|
39
|
+
@authentication = SixSaferpay::Authentication.new(authentication.to_h) if authentication
|
37
40
|
@payer = SixSaferpay::Payer.new(payer.to_h) if payer
|
38
41
|
@return_urls = return_urls || SixSaferpay::ReturnUrls.new()
|
39
42
|
@styling = SixSaferpay::Styling.new(styling.to_h) if styling
|
@@ -49,6 +52,7 @@ module SixSaferpay
|
|
49
52
|
hash.merge!(terminal_id: @terminal_id) if @terminal_id
|
50
53
|
hash.merge!(payment: @payment.to_h) if @payment
|
51
54
|
hash.merge!(payment_means: @payment_means.to_h) if @payment_means
|
55
|
+
hash.merge!(authentication: @authentication.to_h) if @authentication
|
52
56
|
hash.merge!(payer: @payer.to_h) if @payer
|
53
57
|
hash.merge!(return_urls: @return_urls.to_h ) if @return_urls
|
54
58
|
hash.merge!(styling: @styling.to_h) if @styling
|
@@ -6,7 +6,8 @@ module SixSaferpay
|
|
6
6
|
:transaction,
|
7
7
|
:payment_means,
|
8
8
|
:payer,
|
9
|
-
:registration_result
|
9
|
+
:registration_result,
|
10
|
+
:mastercard_issuer_installments
|
10
11
|
)
|
11
12
|
|
12
13
|
|
@@ -14,13 +15,18 @@ module SixSaferpay
|
|
14
15
|
transaction:,
|
15
16
|
payment_means:,
|
16
17
|
payer: nil,
|
17
|
-
registration_result: nil
|
18
|
+
registration_result: nil,
|
19
|
+
mastercard_issuer_installments: nil
|
18
20
|
)
|
19
21
|
@response_header = SixSaferpay::ResponseHeader.new(response_header.to_h) if response_header
|
20
22
|
@transaction = SixSaferpay::Transaction.new(transaction.to_h) if transaction
|
21
23
|
@payment_means = SixSaferpay::ResponsePaymentMeans.new(payment_means.to_h) if payment_means
|
22
24
|
@payer = SixSaferpay::Payer.new(payer.to_h) if payer
|
23
25
|
@registration_result = SixSaferpay::RegistrationResult.new(registration_result.to_h) if registration_result
|
26
|
+
if mastercard_issuer_installments
|
27
|
+
@mastercard_issuer_installments = SixSaferpay::MastercardIssuerInstallments
|
28
|
+
.new(mastercard_issuer_installments.to_h)
|
29
|
+
end
|
24
30
|
end
|
25
31
|
|
26
32
|
def to_hash
|
@@ -30,6 +36,9 @@ module SixSaferpay
|
|
30
36
|
hash.merge!(payment_means: @payment_means.to_h) if @payment_means
|
31
37
|
hash.merge!(payer: @payer.to_h) if @payer
|
32
38
|
hash.merge!(registration_result: @registration_result.to_h) if @registration_result
|
39
|
+
if @mastercard_issuer_installments
|
40
|
+
hash.merge!(mastercard_issuer_installments: mastercard_issuer_installments.to_h)
|
41
|
+
end
|
33
42
|
hash
|
34
43
|
end
|
35
44
|
alias_method :to_h, :to_hash
|
@@ -8,7 +8,8 @@ module SixSaferpay
|
|
8
8
|
:payer,
|
9
9
|
:registration_result,
|
10
10
|
:liability,
|
11
|
-
:dcc
|
11
|
+
:dcc,
|
12
|
+
:mastercard_issuer_installments
|
12
13
|
)
|
13
14
|
|
14
15
|
|
@@ -18,8 +19,8 @@ module SixSaferpay
|
|
18
19
|
payer: nil,
|
19
20
|
registration_result: nil,
|
20
21
|
liability: nil,
|
21
|
-
dcc: nil
|
22
|
-
|
22
|
+
dcc: nil,
|
23
|
+
mastercard_issuer_installments: nil
|
23
24
|
)
|
24
25
|
@response_header = SixSaferpay::ResponseHeader.new(response_header.to_h) if response_header
|
25
26
|
@transaction = SixSaferpay::Transaction.new(transaction.to_h) if transaction
|
@@ -28,6 +29,10 @@ module SixSaferpay
|
|
28
29
|
@registration_result = SixSaferpay::RegistrationResult.new(registration_result.to_h) if registration_result
|
29
30
|
@liability = SixSaferpay::Liability.new(liability.to_h) if liability
|
30
31
|
@dcc = SixSaferpay::Dcc.new(dcc.to_h) if dcc
|
32
|
+
if mastercard_issuer_installments
|
33
|
+
@mastercard_issuer_installments = SixSaferpay::MastercardIssuerInstallments
|
34
|
+
.new(mastercard_issuer_installments.to_h)
|
35
|
+
end
|
31
36
|
end
|
32
37
|
|
33
38
|
def to_hash
|
@@ -39,6 +44,9 @@ module SixSaferpay
|
|
39
44
|
hash.merge!(registration_result: @registration_result.to_h) if @registration_result
|
40
45
|
hash.merge!(liability: @liability.to_h) if @liability
|
41
46
|
hash.merge!(dcc: @dcc.to_h) if @dcc
|
47
|
+
if @mastercard_issuer_installments
|
48
|
+
hash.merge!(mastercard_issuer_installments: mastercard_issuer_installments.to_h)
|
49
|
+
end
|
42
50
|
hash
|
43
51
|
end
|
44
52
|
alias_method :to_h, :to_hash
|
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
|
@@ -8,7 +8,7 @@ module SixSaferpay
|
|
8
8
|
:gender,
|
9
9
|
:legal_form,
|
10
10
|
:street,
|
11
|
-
:
|
11
|
+
:street2,
|
12
12
|
:zip,
|
13
13
|
:city,
|
14
14
|
:country_subdevision_code,
|
@@ -25,7 +25,7 @@ module SixSaferpay
|
|
25
25
|
gender: nil,
|
26
26
|
legal_form: nil,
|
27
27
|
street: nil,
|
28
|
-
|
28
|
+
street2: nil,
|
29
29
|
zip: nil,
|
30
30
|
city: nil,
|
31
31
|
country_subdevision_code: nil,
|
@@ -40,7 +40,7 @@ module SixSaferpay
|
|
40
40
|
@gender = gender
|
41
41
|
@legal_form = legal_form
|
42
42
|
@street = street
|
43
|
-
@
|
43
|
+
@street2 = street2
|
44
44
|
@zip = zip
|
45
45
|
@city = city
|
46
46
|
@country_subdevision_code = country_subdevision_code
|
@@ -58,7 +58,7 @@ module SixSaferpay
|
|
58
58
|
hash.merge!(gender: @gender) if @gender
|
59
59
|
hash.merge!(legal_form: @legal_form) if @legal_form
|
60
60
|
hash.merge!(street: @street) if @street
|
61
|
-
hash.merge!(
|
61
|
+
hash.merge!(street2: @street2) if @street2.present?
|
62
62
|
hash.merge!(zip: @zip) if @zip
|
63
63
|
hash.merge!(city: @city) if @city
|
64
64
|
hash.merge!(country_subdevision_code: @country_subdevision_code) if @country_subdevision_code
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module SixSaferpay
|
2
|
+
class Authentication
|
3
|
+
|
4
|
+
attr_accessor(
|
5
|
+
:result,
|
6
|
+
:message,
|
7
|
+
:xid,
|
8
|
+
:exemption,
|
9
|
+
:three_ds_challenge
|
10
|
+
)
|
11
|
+
|
12
|
+
def initialize(result: nil, # ATTENTION: This is in some case mandatory
|
13
|
+
message: nil, # ATTENTION: This is in some case mandatory
|
14
|
+
xid: nil,
|
15
|
+
exemption: nil,
|
16
|
+
three_ds_challenge: nil)
|
17
|
+
@result = result
|
18
|
+
@message = message
|
19
|
+
@xid = xid
|
20
|
+
@exemption = exemption
|
21
|
+
@three_ds_challenge = three_ds_challenge
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_hash
|
25
|
+
hash = Hash.new
|
26
|
+
hash.merge!(result: @result) if @result
|
27
|
+
hash.merge!(message: @message) if @message
|
28
|
+
hash.merge!(xid: @xid) if @xid
|
29
|
+
hash.merge!(exemption: @exemption) if @exemption
|
30
|
+
hash.merge!(three_ds_challenge: @three_ds_challenge) if @three_ds_challenge
|
31
|
+
hash
|
32
|
+
end
|
33
|
+
alias_method :to_h, :to_hash
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module SixSaferpay
|
2
|
+
class AuthenticationResult
|
3
|
+
|
4
|
+
attr_accessor :result, :message
|
5
|
+
|
6
|
+
def initialize(result:, message:)
|
7
|
+
@result = result
|
8
|
+
@message = message
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_hash
|
12
|
+
hash = Hash.new
|
13
|
+
hash.merge!(result: @result)
|
14
|
+
hash.merge!(message: @message)
|
15
|
+
hash
|
16
|
+
end
|
17
|
+
alias_method :to_h, :to_hash
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -2,19 +2,23 @@ module SixSaferpay
|
|
2
2
|
class CheckResult
|
3
3
|
|
4
4
|
attr_accessor(:result,
|
5
|
-
:message
|
5
|
+
:message,
|
6
|
+
:authentication
|
6
7
|
)
|
7
8
|
|
8
9
|
def initialize(result:,
|
9
|
-
message:
|
10
|
+
message: ,
|
11
|
+
authentication: nil)
|
10
12
|
@result = result
|
11
13
|
@message = message
|
14
|
+
@authentication = authentication
|
12
15
|
end
|
13
16
|
|
14
17
|
def to_hash
|
15
18
|
hash = Hash.new
|
16
19
|
hash.merge!(result: @result) if @result
|
17
20
|
hash.merge!(message: @message) if @message
|
21
|
+
hash.merge!(authentication: @authentication.to_h) if @authentication
|
18
22
|
hash
|
19
23
|
end
|
20
24
|
alias_method :to_h, :to_hash
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module SixSaferpay
|
2
|
+
class ChosenPlan
|
3
|
+
|
4
|
+
attr_accessor(
|
5
|
+
:minimum_number_of_installments,
|
6
|
+
:maximum_number_of_installments,
|
7
|
+
:interest_rate,
|
8
|
+
:installment_fee,
|
9
|
+
:annual_percentage_rate,
|
10
|
+
:total_amount_due,
|
11
|
+
)
|
12
|
+
|
13
|
+
def initialize(
|
14
|
+
minimum_number_of_installments: ,
|
15
|
+
maximum_number_of_installments: ,
|
16
|
+
interest_rate: nil,
|
17
|
+
installment_fee: nil,
|
18
|
+
annual_percentage_rate: nil,
|
19
|
+
total_amount_due: nil
|
20
|
+
)
|
21
|
+
@minimum_number_of_installments =
|
22
|
+
minimum_number_of_installments
|
23
|
+
@maximum_number_of_installments =
|
24
|
+
maximum_number_of_installments
|
25
|
+
@interest_rate = interest_rate
|
26
|
+
if installment_fee
|
27
|
+
@installment_fee = SixSaferpay::InstallmentFee
|
28
|
+
.new(installment_fee.to_h)
|
29
|
+
end
|
30
|
+
if annual_percentage_rate
|
31
|
+
@annual_percentage_rate = annual_percentage_rate
|
32
|
+
end
|
33
|
+
if total_amount_due
|
34
|
+
@total_amount_due = SixSaferpay::TotalAmountDue
|
35
|
+
.new(total_amount_due.to_h)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_hash
|
40
|
+
hash = Hash.new
|
41
|
+
hash.merge!(minimum_number_of_installments:
|
42
|
+
@minimum_number_of_installments)
|
43
|
+
hash.merge!(maximum_number_of_installments:
|
44
|
+
@maximum_number_of_installments)
|
45
|
+
if @interest_rate
|
46
|
+
hash.merge!(interest_rate: @interest_rate)
|
47
|
+
end
|
48
|
+
if @installment_fee
|
49
|
+
hash.merge!(installment_fee: @installment_fee.to_h)
|
50
|
+
end
|
51
|
+
if @annual_percentage_rate
|
52
|
+
hash.merge!(annual_percentage_rate: @annual_percentage_rate)
|
53
|
+
end
|
54
|
+
if @total_amount_due
|
55
|
+
hash.merge!(total_amount_due: @total_amount_due.to_h)
|
56
|
+
end
|
57
|
+
hash
|
58
|
+
end
|
59
|
+
alias_method :to_h, :to_hash
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module SixSaferpay
|
2
|
+
class Ideal
|
3
|
+
|
4
|
+
attr_accessor(:issuer_id)
|
5
|
+
|
6
|
+
def initialize(issuer_id:)
|
7
|
+
@issuer_id = issuer_id
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_hash
|
11
|
+
hash = Hash.new
|
12
|
+
hash.merge!(issuer_id: @issuer_id) if @issuer_id
|
13
|
+
hash
|
14
|
+
end
|
15
|
+
alias_method :to_h, :to_hash
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|