Class: AbacatePay::Clients::PaymentLinkClient

Inherits:
Client
  • Object
show all
Defined in:
lib/abacate_pay/clients/payment_link_client.rb

Overview

Client for reusable payment links in the AbacatePay API.

A payment link can be paid by many customers independently — mass sales, raffles, sign-up forms — without creating one checkout per customer. Use CheckoutClient when each customer needs their own charge.

Constant Summary collapse

URI =
"payment-links"
FREQUENCY =

Payment links are always multi-payment by definition; the API rejects any other frequency on this endpoint.

"MULTIPLE_PAYMENTS"

Constants inherited from Client

Client::RETRIABLE_EXCEPTIONS, Client::RETRIABLE_METHODS, Client::RETRIABLE_STATUSES

Instance Method Summary collapse

Methods inherited from Client

#auto_paging_each, #each_page

Constructor Details

#initialize(client = nil) ⇒ PaymentLinkClient

Returns a new instance of PaymentLinkClient.

Parameters:

  • client (Faraday::Connection, nil) (defaults to: nil)

    Optional Faraday client



18
19
20
# File 'lib/abacate_pay/clients/payment_link_client.rb', line 18

def initialize(client = nil)
  super(URI, client)
end

Instance Method Details

#create(data) ⇒ Resources::Checkouts

Creates a reusable payment link.

Parameters:

Returns:



40
41
42
43
# File 'lib/abacate_pay/clients/payment_link_client.rb', line 40

def create(data)
  response = request("POST", "create", json: build_create_payload(data))
  Resources::Checkouts.new(response)
end

#get(id) ⇒ Resources::Checkouts

Parameters:

  • id (String)

    The payment link ID

Returns:



31
32
33
34
# File 'lib/abacate_pay/clients/payment_link_client.rb', line 31

def get(id)
  response = request("GET", "get", params: { id: id })
  Resources::Checkouts.new(response)
end

#list(**params) ⇒ Array<Resources::Checkouts>

Parameters:

  • params (Hash)

    Optional pagination params (after, before, limit)

Returns:



24
25
26
27
# File 'lib/abacate_pay/clients/payment_link_client.rb', line 24

def list(**params)
  response = request("GET", "list", params: params.empty? ? nil : params)
  build_list(response, Resources::Checkouts)
end

#refund(id) ⇒ Resources::Checkouts

Refunds a payment made through the link.

Parameters:

  • id (String)

    Public charge ID

Returns:



49
50
51
52
# File 'lib/abacate_pay/clients/payment_link_client.rb', line 49

def refund(id)
  response = request("POST", "refund", json: { id: id })
  Resources::Checkouts.new(response)
end