Module: Justifi::Payment

Defined in:
lib/justifi/payment.rb

Class Method Summary collapse

Class Method Details

.balance_transactions(payment_id:, params: {}, headers: {}) ⇒ Object



56
57
58
59
60
# File 'lib/justifi/payment.rb', line 56

def balance_transactions(payment_id:, params: {}, headers: {})
  Justifi::ListObject.list("/v1/payments/#{payment_id}/payment_balance_transactions",
    params,
    headers)
end

.capture(payment_id:, amount: nil, headers: {}, idempotency_key: nil) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/justifi/payment.rb', line 47

def capture(payment_id:, amount: nil, headers: {}, idempotency_key: nil)
  params = amount.nil? ? {} : {amount: amount}
  JustifiOperations.idempotently_request("/v1/payments/#{payment_id}/capture",
    method: :post,
    params: params,
    headers: {},
    idempotency_key: idempotency_key)
end

.create(params: {}, headers: {}, idempotency_key: nil, seller_account_id: nil, sub_account_id: nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/justifi/payment.rb', line 6

def create(params: {}, headers: {}, idempotency_key: nil, seller_account_id: nil, sub_account_id: nil)
  Justifi. if 
  headers[:sub_account] =  ||  if  || 

  JustifiOperations.idempotently_request("/v1/payments",
    method: :post,
    params: params,
    headers: headers,
    idempotency_key: idempotency_key)
end

.create_refund(amount:, payment_id:, reason: nil, description: nil, metadata: nil, idempotency_key: nil) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/justifi/payment.rb', line 17

def create_refund(amount:, payment_id:, reason: nil, description: nil, metadata: nil, idempotency_key: nil)
  refund_params = {amount: amount, description: description, reason: reason, metadata: }
  JustifiOperations.idempotently_request("/v1/payments/#{payment_id}/refunds",
    method: :post,
    params: refund_params,
    headers: {},
    idempotency_key: idempotency_key)
end

.get(payment_id:, headers: {}) ⇒ Object



33
34
35
36
37
# File 'lib/justifi/payment.rb', line 33

def get(payment_id:, headers: {})
  JustifiOperations.execute_get_request("/v1/payments/#{payment_id}",
    {},
    headers)
end

.list(params: {}, headers: {}, seller_account_id: nil, sub_account_id: nil) ⇒ Object



26
27
28
29
30
31
# File 'lib/justifi/payment.rb', line 26

def list(params: {}, headers: {}, seller_account_id: nil, sub_account_id: nil)
  Justifi. if 
  headers[:sub_account] =  ||  if  || 

  Justifi::ListObject.list("/v1/payments", params, headers)
end

.update(payment_id:, params: {}, headers: {}, idempotency_key: nil) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/justifi/payment.rb', line 39

def update(payment_id:, params: {}, headers: {}, idempotency_key: nil)
  JustifiOperations.idempotently_request("/v1/payments/#{payment_id}",
    method: :patch,
    params: params,
    headers: {},
    idempotency_key: idempotency_key)
end