Skip to content
This repository has been archived by the owner on Mar 12, 2021. It is now read-only.

Latest commit

 

History

History
198 lines (141 loc) · 8 KB

HostedCheckoutsApi.md

File metadata and controls

198 lines (141 loc) · 8 KB

BleumiPay::HostedCheckoutsApi

create_checkout_url

CreateCheckoutUrlResponse create_checkout_url(create_checkout_url_request)

This method generates a unique checkout URL to accept payment.

Example

# load the gem
require 'bleumi_pay_sdk_ruby'
# setup authorization
BleumiPay.configure do |config|
  # Configure API key authorization: ApiKeyAuth
  config.api_key['x-api-key'] = '<YOUR_API_KEY>'
end

api_instance = BleumiPay::HostedCheckoutsApi.new
create_checkout_url_request = BleumiPay::CreateCheckoutUrlRequest.new # CreateCheckoutUrlRequest | Specify checkout URL creation parameters.

begin

  create_checkout_url_request = BleumiPay::CreateCheckoutUrlRequest.new # CreatePayoutRequest | Specify payout creation parameters.
  create_checkout_url_request.id = '<ID>' # Eg. 1
  create_checkout_url_request.currency = "<CURRENCY>" # Eg. USD
  create_checkout_url_request.amount = "<AMOUNT>" # Eg. 10
  create_checkout_url_request.success_url = "<SUCCESS_URL>" # Eg. https://demo.store/api/completeOrder
  create_checkout_url_request.cancel_url = "<CANCEL_URL>" # Eg. https://demo.store/api/cancelOrder
  create_checkout_url_request.token = '<TOKEN>' # Replace <TOKEN>  by anyone of the following values: 'ETH' or 'XDAI' or 'XDAIT' or ECR-20 Contract Address or 'RBTC' or RSK ECR-20 Contract Address or 'Asset ID' of Algorand Standard Asset. | Optional
  create_checkout_url_request.chain = BleumiPay::Chain::GOERLI # Replace with any Chain as required

  #Generate a unique checkout URL to accept payment.
  result = api_instance.create_checkout_url(create_checkout_url_request)
  p result
rescue BleumiPay::ApiError => e
  puts "Exception when calling HostedCheckoutsApi->create_checkout_url: #{e}"
end

Parameters

Name Type Description Notes
create_checkout_url_request CreateCheckoutUrlRequest Specify checkout URL creation parameters.

Return type

CreateCheckoutUrlResponse

Field Type Description
id string Unique identifier generated for this checkout URL
url string URL for buyer to complete payment

Format - hmac_input GET parameter passed in successUrl

The hmac_input GET parameter passed to successUrl contains payment parameters as a pipe ('|') separated string in the following order,

  • Chain - Please refer documentation for Supported Networks
  • Wallet Address
  • Token
    ETH - for Ethereum
    XDAI - for xDai
    XDAIT - for xDai Testnet
    ALGO - for Algo
    RBTC - for R-BTC
    <asset id> - for Algorand Standard Asset
    <contract address of ERC-20 token> - for ERC-20; Please refer to ERC-20 Tokens for contract address;
    <contract address of RSK ERC-20 token> - for RSK ERC-20; Please refer to RSK ERC-20 Tokens for contract address;
  • Amount - Token amount for the payment
  • Number of block confirmations
  • Transaction Hash

Call Validate a Checkout Payment method to validate the GET parameters passed in successUrl and then cross-check the payment parameters of hmac.input GET parameter with your database.

400 Errors

The following table is a list of possible error codes that can be returned, along with additional information about how to resolve them for a response with 400 status code.

errorCode
errorMessage
Description
ValidationError
<details>
Details on input which does not conform to the above schema
ValidationError
no_tokens_defined
Please configure tokens for the Hosted Checkout in your account in the Bleumi Pay Dashboard
ValidationError
no_tokens_defined_for_currency
No tokens have been defined in your account for the specified currency
ValidationError
invalid_token
The token provided is not valid for the specified currency

list_tokens

Array<CheckoutToken> list_tokens

Retrieve all tokens configured for the Hosted Checkout in your account in the Bleumi Pay Dashboard.

Example

# load the gem
require 'bleumi_pay_sdk_ruby'
# setup authorization
BleumiPay.configure do |config|
  # Configure API key authorization: ApiKeyAuth
  config.api_key['x-api-key'] = '<YOUR_API_KEY>'
end

api_instance = BleumiPay::HostedCheckoutsApi.new

begin
  #Retrieve all tokens configured for the Hosted Checkout in your account in the [Bleumi Pay Dashboard](https://pay.bleumi.com/app/).
  result = api_instance.list_tokens
  p result
rescue BleumiPay::ApiError => e
  puts "Exception when calling HostedCheckoutsApi->list_tokens: #{e}"
end

Parameters

This endpoint does not need any parameter.

Return type

Array<CheckoutToken>

400 Errors

The following table is a list of possible error codes that can be returned, along with additional information about how to resolve them for a response with 400 status code.

errorCode
errorMessage
Description
ValidationError
no_tokens_defined
No tokens have been defined in your account

validate_checkout_payment

ValidateCheckoutResponse validate_checkout_payment(validate_checkout_request)

Validate the GET parameters passed by Hosted Checkout in successUrl upon successfully completing payment.

Example

# load the gem
require 'bleumi_pay_sdk_ruby'
# setup authorization
BleumiPay.configure do |config|
  # Configure API key authorization: ApiKeyAuth
  config.api_key['x-api-key'] = '<YOUR_API_KEY>'
end

api_instance = BleumiPay::HostedCheckoutsApi.new

begin
  validate_checkout_request = BleumiPay::ValidateCheckoutRequest.new # ValidateCheckoutRequest | Specify validation of checkout parameters.
  validate_checkout_request.hmac_alg = '<ALD>' # Eg. HMAC-SHA256-HEX
  validate_checkout_request.hmac_input = '<INPUT>' # Eg. rsk_testnet|0xbed61c55cc290b55c1c4c327148bdede56a831f4|0xb9f624160bb2755aa25366cc307ed27e39a4f296|10|0|0x16e54beb3ea4b4206b62ca32b1d2cf4ad15d9af2234564c2166ff3ccc817d5c1
  validate_checkout_request.hmac_key_id = '<VER>' # Eg. v1
  validate_checkout_request.hmac_value = '<HMAC_VALUE>' # Eg. c782cbad4394383599b7cf9f9d62990f289649b35edd82cd1c7d58dd65e9fc03
  #Validate the GET parameters passed by Hosted Checkout in successUrl upon successfully completing payment.
  result = api_instance.validate_checkout_payment(validate_checkout_request)
  p result
rescue BleumiPay::ApiError => e
  puts "Exception when calling HostedCheckoutsApi->validate_checkout_payment: #{e}"
end

Parameters

Name Type Description Notes
validate_checkout_request ValidateCheckoutRequest Specify validation of checkout parameters.

Return type

ValidateCheckoutResponse

Field Type Description
valid boolean true - The data has been generated by Bleumi Pay
false - The data has not been generated by Bleumi Pay, the payment must be treated as unpaid

400 Errors

The following table is a list of possible error codes that can be returned, along with additional information about how to resolve them for a response with 400 status code.

errorCode
errorMessage
Description
ValidationError
<details>
Details on input which does not conform to the above schema