Class: AbacatePay::Clients::TransparentClient
- Defined in:
- lib/abacate_pay/clients/transparent_client.rb
Overview
Client for transparent PIX checkout in the AbacatePay API.
Transparent checkout returns the QR code and copy-and-paste payload directly, so the payment stays inside your own UI.
Constant Summary collapse
- URI =
"transparents"
Constants inherited from Client
Client::RETRIABLE_EXCEPTIONS, Client::RETRIABLE_METHODS, Client::RETRIABLE_STATUSES
Instance Method Summary collapse
- #check(id) ⇒ Resources::Transparents
-
#create(data, method: Enums::Billings::Methods::PIX) ⇒ Resources::Transparents
Creates a transparent charge.
-
#initialize(client = nil) ⇒ TransparentClient
constructor
A new instance of TransparentClient.
- #list(**params) ⇒ Array<Resources::Transparents>
-
#refund(id) ⇒ Resources::Transparents
Refunds a transparent payment in full.
- #simulate_payment(id) ⇒ Resources::Transparents
Methods inherited from Client
Constructor Details
#initialize(client = nil) ⇒ TransparentClient
Returns a new instance of TransparentClient.
12 13 14 |
# File 'lib/abacate_pay/clients/transparent_client.rb', line 12 def initialize(client = nil) super(URI, client) end |
Instance Method Details
#check(id) ⇒ Resources::Transparents
40 41 42 43 |
# File 'lib/abacate_pay/clients/transparent_client.rb', line 40 def check(id) response = request("GET", "check", params: { id: id }) Resources::Transparents.new(response) end |
#create(data, method: Enums::Billings::Methods::PIX) ⇒ Resources::Transparents
Creates a transparent charge.
30 31 32 33 34 35 36 |
# File 'lib/abacate_pay/clients/transparent_client.rb', line 30 def create(data, method: Enums::Billings::Methods::PIX) validate_transparent_method!(method) validate_boleto_payer!(data) if method == Enums::Billings::Methods::BOLETO response = request("POST", "create", json: build_create_payload(data, method)) Resources::Transparents.new(response) end |
#list(**params) ⇒ Array<Resources::Transparents>
18 19 20 21 |
# File 'lib/abacate_pay/clients/transparent_client.rb', line 18 def list(**params) response = request("GET", "list", params: params.empty? ? nil : params) build_list(response, Resources::Transparents) end |
#refund(id) ⇒ Resources::Transparents
Refunds a transparent payment in full. AbacatePay does not support partial refunds, the original amount is always returned.
59 60 61 62 |
# File 'lib/abacate_pay/clients/transparent_client.rb', line 59 def refund(id) response = request("POST", "refund", json: { id: id }) Resources::Transparents.new(response) end |
#simulate_payment(id) ⇒ Resources::Transparents
47 48 49 50 51 52 |
# File 'lib/abacate_pay/clients/transparent_client.rb', line 47 def simulate_payment(id) # The API reads the id from the query string here, like #check. Sending # it only in the body fails with "Expected property 'id'". response = request("POST", "simulate-payment", params: { id: id }, json: {}) Resources::Transparents.new(response) end |