Class: MaliPoPay::Resources::Payments

Inherits:
Object
  • Object
show all
Defined in:
lib/malipopay/resources/payments.rb

Instance Method Summary collapse

Constructor Details

#initialize(http_client) ⇒ Payments

Returns a new instance of Payments.



6
7
8
# File 'lib/malipopay/resources/payments.rb', line 6

def initialize(http_client)
  @http = http_client
end

Instance Method Details

#approve(params) ⇒ Hash

Approve a pending payment

Parameters:

  • params (Hash)

    Approval parameters (reference, etc.)

Returns:

  • (Hash)

    Approval response



69
70
71
# File 'lib/malipopay/resources/payments.rb', line 69

def approve(params)
  @http.post("/api/v1/payment/approve", body: params)
end

#collect(params) ⇒ Hash

Initiate a mobile money collection

Parameters:

  • params (Hash)

    Collection parameters (amount, phone, provider, reference, etc.)

Returns:

  • (Hash)

    Collection response



20
21
22
# File 'lib/malipopay/resources/payments.rb', line 20

def collect(params)
  @http.post("/api/v1/payment/collection", body: params)
end

Create a payment link

Parameters:

  • params (Hash)

    Payment link parameters

Returns:

  • (Hash)

    Payment link response



83
84
85
# File 'lib/malipopay/resources/payments.rb', line 83

def create_link(params)
  @http.post("/api/v1/pay", body: params)
end

#disburse(params) ⇒ Hash

Initiate a disbursement (send money)

Parameters:

  • params (Hash)

    Disbursement parameters

Returns:

  • (Hash)

    Disbursement response



27
28
29
# File 'lib/malipopay/resources/payments.rb', line 27

def disburse(params)
  @http.post("/api/v1/payment/disbursement", body: params)
end

#get(reference) ⇒ Hash

Get a payment by reference

Parameters:

  • reference (String)

    Payment reference

Returns:

  • (Hash)

    Payment details



48
49
50
# File 'lib/malipopay/resources/payments.rb', line 48

def get(reference)
  @http.get("/api/v1/payment/reference/#{reference}")
end

#initiate(params) ⇒ Hash

Initiate a payment (collection or disbursement)

Parameters:

  • params (Hash)

    Payment parameters

Returns:

  • (Hash)

    Payment response



13
14
15
# File 'lib/malipopay/resources/payments.rb', line 13

def initiate(params)
  @http.post("/api/v1/payment", body: params)
end

#list(params = {}) ⇒ Hash

List all payments

Parameters:

  • params (Hash) (defaults to: {})

    Query parameters (page, limit, etc.)

Returns:

  • (Hash)

    Paginated list of payments



55
56
57
# File 'lib/malipopay/resources/payments.rb', line 55

def list(params = {})
  @http.get("/api/v1/payment", params: params)
end

#pay_now(params) ⇒ Hash

Process an instant payment

Parameters:

  • params (Hash)

    Payment parameters

Returns:

  • (Hash)

    Payment response



34
35
36
# File 'lib/malipopay/resources/payments.rb', line 34

def pay_now(params)
  @http.post("/api/v1/payment/now", body: params)
end

#retry_collection(reference) ⇒ Hash

Retry a failed collection

Parameters:

  • reference (String)

    Payment reference to retry

Returns:

  • (Hash)

    Retry response



76
77
78
# File 'lib/malipopay/resources/payments.rb', line 76

def retry_collection(reference)
  @http.get("/api/v1/payment/retry/#{reference}")
end

#search(params = {}) ⇒ Hash

Search payments

Parameters:

  • params (Hash) (defaults to: {})

    Search parameters

Returns:

  • (Hash)

    Search results



62
63
64
# File 'lib/malipopay/resources/payments.rb', line 62

def search(params = {})
  @http.get("/api/v1/payment/search", params: params)
end

#verify(reference) ⇒ Hash

Verify a payment by reference

Parameters:

  • reference (String)

    Payment reference

Returns:

  • (Hash)

    Payment verification details



41
42
43
# File 'lib/malipopay/resources/payments.rb', line 41

def verify(reference)
  @http.get("/api/v1/payment/verify/#{reference}")
end