Class: DkPaymentGateway::PullPayment
- Inherits:
-
Object
- Object
- DkPaymentGateway::PullPayment
- Defined in:
- lib/dk_payment_gateway/pull_payment.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Class Method Summary collapse
-
.generate_stan(source_app_suffix, transaction_identifier = nil) ⇒ String
Generate STAN number.
Instance Method Summary collapse
-
#authorize(params) ⇒ Hash
Payment Gateway Authorization (Account inquiry and OTP request).
-
#debit(params) ⇒ Hash
Payment Gateway Debit Request Completes a previously authorized payment by verifying OTP.
-
#initialize(client) ⇒ PullPayment
constructor
A new instance of PullPayment.
Constructor Details
#initialize(client) ⇒ PullPayment
Returns a new instance of PullPayment.
7 8 9 |
# File 'lib/dk_payment_gateway/pull_payment.rb', line 7 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/dk_payment_gateway/pull_payment.rb', line 5 def client @client end |
Class Method Details
.generate_stan(source_app_suffix, transaction_identifier = nil) ⇒ String
Generate STAN number
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/dk_payment_gateway/pull_payment.rb', line 74 def self.generate_stan(source_app_suffix, transaction_identifier = nil) suffix = source_app_suffix.to_s[-4..] identifier = if transaction_identifier transaction_identifier.to_s[-8..] else # Generate from current timestamp (HHMMSSMS format) time = Time.now format('%02d%02d%02d%02d', time.hour, time.min, time.sec, time.usec / 10_000) end "#{suffix}#{identifier}" end |
Instance Method Details
#authorize(params) ⇒ Hash
Payment Gateway Authorization (Account inquiry and OTP request)
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/dk_payment_gateway/pull_payment.rb', line 28 def (params) (params) request_body = (params) signature_headers = generate_signature_headers(request_body) response = client.post( '/v1/account_auth/pull-payment', body: request_body.to_json, headers: signature_headers ) validate_response!(response, 'Authorization') response['response_data'] end |
#debit(params) ⇒ Hash
Payment Gateway Debit Request Completes a previously authorized payment by verifying OTP
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/dk_payment_gateway/pull_payment.rb', line 54 def debit(params) validate_debit_params!(params) request_body = build_debit_body(params) signature_headers = generate_signature_headers(request_body) response = client.post( '/v1/debit_request/pull-payment', body: request_body.to_json, headers: signature_headers ) validate_response!(response, 'Debit') response['response_data'] end |