Class: Cubepay::Client
- Inherits:
-
Object
- Object
- Cubepay::Client
- Defined in:
- lib/cubepay/client.rb
Instance Attribute Summary collapse
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
Returns the value of attribute client_secret.
-
#http_request ⇒ Object
readonly
Returns the value of attribute http_request.
-
#signature ⇒ Object
readonly
Returns the value of attribute signature.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#do_payment(source_coin_id, source_amount, item_name, merchant_transaction_id, other = "", return_url = "", ipn_url = "", send_coin_id = "", send_amount = "", receive_address = "") ⇒ Object
Render a page(but not initial a payment yet) within these information: - Your shop information - Item name - Payable coin list and corresponding price.
-
#do_payment_by_coin_id(coin_id, source_coin_id, source_amount, item_name, merchant_transaction_id, other = "", return_url = "", ipn_url = "", send_coin_id = "", send_amount = "", receive_address = "") ⇒ Object
Initial order with specific coin.
-
#get_coin ⇒ Object
Get list of available cryptocurrencies.
-
#get_fiat ⇒ Object
Get list of available fiat currenies.
-
#initialize(client_id, client_secret, url) ⇒ Client
constructor
A new instance of Client.
-
#query_payment(cubepay_transaction_id = "", merchant_transaction_id = "") ⇒ Object
Query payment information by specific identity.
Constructor Details
#initialize(client_id, client_secret, url) ⇒ Client
Returns a new instance of Client.
16 17 18 19 |
# File 'lib/cubepay/client.rb', line 16 def initialize(client_id, client_secret, url) @http_request = HttpRequest.new(url) @signature = Signature.new(client_id, client_secret) end |
Instance Attribute Details
#client_id ⇒ Object
Returns the value of attribute client_id.
6 7 8 |
# File 'lib/cubepay/client.rb', line 6 def client_id @client_id end |
#client_secret ⇒ Object
Returns the value of attribute client_secret.
6 7 8 |
# File 'lib/cubepay/client.rb', line 6 def client_secret @client_secret end |
#http_request ⇒ Object (readonly)
Returns the value of attribute http_request.
11 12 13 |
# File 'lib/cubepay/client.rb', line 11 def http_request @http_request end |
#signature ⇒ Object (readonly)
Returns the value of attribute signature.
11 12 13 |
# File 'lib/cubepay/client.rb', line 11 def signature @signature end |
#url ⇒ Object
Returns the value of attribute url.
6 7 8 |
# File 'lib/cubepay/client.rb', line 6 def url @url end |
Instance Method Details
#do_payment(source_coin_id, source_amount, item_name, merchant_transaction_id, other = "", return_url = "", ipn_url = "", send_coin_id = "", send_amount = "", receive_address = "") ⇒ Object
Render a page(but not initial a payment yet) within these information:
-
Your shop information
-
Item name
-
Payable coin list and corresponding price.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/cubepay/client.rb', line 50 def do_payment(source_coin_id, source_amount, item_name, merchant_transaction_id, other = "", return_url = "", ipn_url = "", send_coin_id = "", send_amount = "", receive_address = "") method = "/payment" params = { "source_coin_id" => source_coin_id, "source_amount" => source_amount, "item_name" => item_name, "merchant_transaction_id" => merchant_transaction_id, "other" => other, "return_url" => return_url, "ipn_url" => ipn_url, "send_coin_id" => send_coin_id, "send_amount" => send_amount, "receive_address" => receive_address, } sign_params = self.signature.get_params_with_signature(params) response = self.http_request.get_response(method, sign_params) return response end |
#do_payment_by_coin_id(coin_id, source_coin_id, source_amount, item_name, merchant_transaction_id, other = "", return_url = "", ipn_url = "", send_coin_id = "", send_amount = "", receive_address = "") ⇒ Object
Initial order with specific coin. Order will expire after 6 hours. If you define the parameter send_coin_id, receive_address, send_amount to send back coin to your customer, we’ll lock the amount of send coin and fee temporarily and unlock until payment finish or expired.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/cubepay/client.rb', line 75 def do_payment_by_coin_id(coin_id, source_coin_id, source_amount, item_name, merchant_transaction_id, other = "", return_url = "", ipn_url = "", send_coin_id = "", send_amount = "", receive_address = "") method = "/payment/coin" params = { "coin_id" => coin_id, "source_coin_id" => source_coin_id, "source_amount" => source_amount, "item_name" => item_name, "merchant_transaction_id" => merchant_transaction_id, "other" => other, "return_url" => return_url, "ipn_url" => ipn_url, "send_coin_id" => send_coin_id, "send_amount" => send_amount, "receive_address" => receive_address, } sign_params = self.signature.get_params_with_signature(params) response = self.http_request.get_response(method, sign_params) return response end |
#get_coin ⇒ Object
Get list of available cryptocurrencies. You can use these currencies at payment API for receive/send coin.
23 24 25 26 27 28 29 30 31 |
# File 'lib/cubepay/client.rb', line 23 def get_coin method = "/currency/coin" params = {} sign_params = self.signature.get_params_with_signature(params) response = self.http_request.get_response(method, sign_params) return response end |
#get_fiat ⇒ Object
Get list of available fiat currenies. You can only use these fiat currencies for your product’s original list price, not for receive/send, we’ll convert value by exchange rate between currency of list price and currency of actual paid.
36 37 38 39 40 41 42 43 44 |
# File 'lib/cubepay/client.rb', line 36 def get_fiat method = "/currency/fiat" params = {} sign_params = self.signature.get_params_with_signature(params) response = self.http_request.get_response(method, sign_params) return response end |
#query_payment(cubepay_transaction_id = "", merchant_transaction_id = "") ⇒ Object
Query payment information by specific identity.
99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/cubepay/client.rb', line 99 def query_payment(cubepay_transaction_id = "", merchant_transaction_id = "") method = "/payment/query" params = { "id" => cubepay_transaction_id, "merchant_transaction_id" => merchant_transaction_id, } sign_params = self.signature.get_params_with_signature(params) response = self.http_request.get_response(method, sign_params) return response end |