Module: Prodamus
- Defined in:
- lib/prodamus.rb,
lib/helper.rb,
lib/entities/product.rb,
lib/prodamus/version.rb,
lib/services/verifier.rb,
lib/services/link_config.rb
Overview
Main settings
Defined Under Namespace
Classes: LinkConfig, Product, Verifier
Constant Summary collapse
- NON_INSTALLMENTS_PAYMENT_METHODS =
%w[ AC ACkz ACkztjp ACf ACeuruk ACusduk ACEURNMBX ACUSDNMBX SBP PC QW GP sbol invoice ].freeze
- INSTALLMENTS_PAYMENT_METHODS =
%w[ installment installment_5_21 installment_6_28 installment_10_28 installment_12_28 installment_0_0_3 installment_0_0_4 installment_0_0_6 installment_0_0_10 installment_0_0_12 installment_0_0_24 credit vsegdada_installment_0_0_4 vsegdada_installment_0_0_6 vsegdada_installment_0_0_10 vsegdada_installment_0_0_12 vsegdada_installment_0_0_24 ].freeze
- ALL_AVAIBLE_PAYMENT_METHODS =
NON_INSTALLMENTS_PAYMENT_METHODS + INSTALLMENTS_PAYMENT_METHODS
- VERSION =
'1.0.1'
Class Attribute Summary collapse
-
.main_payment_form_url ⇒ Object
payment form provided by prodamus.
-
.secret_key ⇒ Object
key from main form settings.
Class Method Summary collapse
- .config {|_self| ... } ⇒ Object
-
.link ⇒ Object
get link to payment form.
-
.link_config(&block) ⇒ Object
configure the payload to receive the payment form.
- .verifier(data, algorithm = 'sha256') ⇒ Object
-
.verify(data, sign) ⇒ Object
verify signatured data.
Class Attribute Details
.main_payment_form_url ⇒ Object
payment form provided by prodamus
13 14 15 |
# File 'lib/prodamus.rb', line 13 def main_payment_form_url @main_payment_form_url end |
.secret_key ⇒ Object
key from main form settings
16 17 18 |
# File 'lib/prodamus.rb', line 16 def secret_key @secret_key end |
Class Method Details
.config {|_self| ... } ⇒ Object
18 19 20 |
# File 'lib/prodamus.rb', line 18 def config yield self if block_given? end |
.link ⇒ Object
get link to payment form
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/prodamus.rb', line 28 def link response = Faraday.new( url: @main_payment_form_url, params: @link_config.format_result, headers: { 'Content-Type' => 'text/plain', 'charset' => 'utf-8' }, request: { timeout: 5 } ).get raise response.body.force_encoding('utf-8') if response.status != 200 response.body end |
.link_config(&block) ⇒ Object
configure the payload to receive the payment form
42 43 44 |
# File 'lib/prodamus.rb', line 42 def link_config(&block) @link_config = LinkConfig.new(&block) end |
.verifier(data, algorithm = 'sha256') ⇒ Object
46 47 48 49 50 |
# File 'lib/prodamus.rb', line 46 def verifier(data, algorithm = 'sha256') raise 'Missing secret_key.' if @secret_key.nil? @verifier = Verifier.new(data, @secret_key, algorithm) end |
.verify(data, sign) ⇒ Object
verify signatured data
23 24 25 |
# File 'lib/prodamus.rb', line 23 def verify(data, sign) verifier(data).verify(sign) end |