Class: NedbankApi::PaymentsApi

Inherits:
ApiWrapper show all
Defined in:
lib/nedbank_api/payments_api.rb

Constant Summary collapse

API_PATHS =
{
  payments: 'open-banking/payments',
  payment_submissions: 'open-banking/payment-submissions'
}

Class Method Summary collapse

Methods inherited from ApiWrapper

auth_headers, endpoint, idempotency_key, json_to_object

Class Method Details

.create_intent(request_body: {}, headers: {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/nedbank_api/payments_api.rb', line 10

def create_intent(request_body: {}, headers: {})
  http = Http.new(url: endpoint(API_PATHS[:payments]))

  response = http.post(
    headers: auth_headers,
    body: request_body.to_json
  )

  return Models::Payment.new(json_to_object(response.body))
end

.get_payment_submission(payment_submission_id:, headers: {}) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/nedbank_api/payments_api.rb', line 32

def get_payment_submission(payment_submission_id:, headers: {})
  http = Http.new(url: endpoint(API_PATHS[:payment_submissions], suffix: payment_submission_id))

  response = http.get(
    headers: auth_headers
  )

  return Models::PaymentSubmission.new(json_to_object(response.body))
end

.submit_payment(request_body: {}, headers: {}) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/nedbank_api/payments_api.rb', line 21

def submit_payment(request_body: {}, headers: {})
  http = Http.new(url: endpoint(API_PATHS[:payment_submissions]))

  response = http.post(
    headers: auth_headers,
    body: request_body.to_json
  )

  return Models::PaymentSubmission.new(json_to_object(response.body))
end