Class: CryptomateApi::Payment

Inherits:
Base
  • Object
show all
Defined in:
lib/cryptomate_api/payment.rb

Overview

Once the customer has completed the payment, you will receive a webhook notification (configurable in Management API). This notification will contain the status of the payment.

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from CryptomateApi::Base

Instance Method Details

#create_payments_request(token_address, amount, blockchain) ⇒ Object

Creates a new payment request. cryptomate.me/docs/payments#create-payments-request Response:

"id": "String",
"token_address": "String",
"wallet_address": "String",
"amount": "Decimal",

Parameters:

  • token_address (String)

    (Address of the contract from the token to transfer.)

  • amount (double)

    (Amount of the selected asset to be payed.)

  • blockchain (String)

    (Blockchain to create the payment.)



31
32
33
# File 'lib/cryptomate_api/payment.rb', line 31

def create_payments_request(token_address, amount, blockchain)
  self.class.post('/commerce/payments/create', body: { token_address:, amount:, blockchain: }.to_json)
end

#get_listed_tokens(blockchain) ⇒ Object

Retrieves all the listed tokens to create payments. In the response you will see the token name and it’s address on the blockchain. cryptomate.me/docs/payments#get-listed-tokens Response:

"Token name 1": "String",
"Token name 2": "String",

Parameters:

  • blockchain (String)

    (Blockchain to get the listed tokens.)



58
59
60
# File 'lib/cryptomate_api/payment.rb', line 58

def get_listed_tokens(blockchain)
  self.class.get("/commerce/payments/#{blockchain}/tokens")
end

#pending_paymentsObject

Returns all the pending payments. cryptomate.me/docs/payments#pending-payments Response: [

{
  "id": "String",
  "token_address": "String",
  "wallet_address": "String",
  "amount": "Decimal",
}

]



46
47
48
# File 'lib/cryptomate_api/payment.rb', line 46

def pending_payments
  self.class.get('/commerce/payments/list')
end