Module: Culqi
- Defined in:
- lib/culqi-ruby.rb,
lib/culqi/card.rb,
lib/culqi/iins.rb,
lib/culqi/plan.rb,
lib/culqi/yape.rb,
lib/culqi/event.rb,
lib/culqi/order.rb,
lib/culqi/token.rb,
lib/culqi/charge.rb,
lib/culqi/refund.rb,
lib/util/connect.rb,
lib/culqi/version.rb,
lib/culqi/customer.rb,
lib/culqi/transfer.rb,
lib/culqi/subscription.rb
Defined Under Namespace
Modules: ConfirmType, Delete, Get, List, Post, Update Classes: Card, Charge, Customer, Event, Iins, Order, Plan, Refund, Subscription, Token, Transfer, Yape
Constant Summary collapse
- API_BASE =
'https://api.culqi.com/v2'- API_BASE_SECURE =
'https://secure.culqi.com/v2'- READ_TIMEOUT =
API_BASE = ‘qa-api.culqi.xyz/v2’ API_BASE_SECURE = ‘qa-secure.culqi.xyz/v2’
120- LIST_TIMEOUT =
360- VERSION =
"1.0.2"
Class Attribute Summary collapse
-
.public_key ⇒ Object
Returns the value of attribute public_key.
-
.rsa_id ⇒ Object
Returns the value of attribute rsa_id.
-
.rsa_key ⇒ Object
Returns the value of attribute rsa_key.
-
.secret_key ⇒ Object
Returns the value of attribute secret_key.
Class Method Summary collapse
Class Attribute Details
.public_key ⇒ Object
Returns the value of attribute public_key.
31 32 33 |
# File 'lib/culqi-ruby.rb', line 31 def public_key @public_key end |
.rsa_id ⇒ Object
Returns the value of attribute rsa_id.
31 32 33 |
# File 'lib/culqi-ruby.rb', line 31 def rsa_id @rsa_id end |
.rsa_key ⇒ Object
Returns the value of attribute rsa_key.
31 32 33 |
# File 'lib/culqi-ruby.rb', line 31 def rsa_key @rsa_key end |
.secret_key ⇒ Object
Returns the value of attribute secret_key.
31 32 33 |
# File 'lib/culqi-ruby.rb', line 31 def secret_key @secret_key end |
Class Method Details
.connect(url, api_key, data, type, time_out, secure_url = false, rsa_id = '') ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/util/connect.rb', line 6 def self.connect(url, api_key, data, type, time_out, secure_url = false, rsa_id='') base_url = secure_url ? Culqi::API_BASE_SECURE : Culqi::API_BASE full_url = "#{base_url}#{url}" uri = URI(full_url) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = uri.scheme == 'https' headers = { "Authorization" => "Bearer #{api_key}", "Content-Type" => "application/json", "cache-control" => "no-cache" } headers["x-culqi-rsa-id"] = rsa_id if rsa_id && !rsa_id.empty? case type.upcase when 'GET' request = Net::HTTP::Get.new(uri.request_uri, headers) when 'POST' request = Net::HTTP::Post.new(uri.request_uri, headers) request.body = data.to_json if data when 'DELETE' request = Net::HTTP::Delete.new(uri.request_uri, headers) when 'PATCH' request = Net::HTTP::Patch.new(uri.request_uri, headers) request.body = data.to_json if data else raise ArgumentError, "Unsupported request type: #{type}" end http.read_timeout = time_out response = http.request(request) puts response.body return response.body, response.code.to_i end |