class GmoPayment::Api
Constants
- PREVENT_VARIABLES
Public Class Methods
new(options = {}, type_site = true, logger = nil)
click to toggle source
# File lib/gmo_payment/api.rb, line 5 def initialize(options = {}, type_site = true, logger = nil) @base_params = if type_site { SiteID: GmoPayment::Configurations.all.fetch(:site_id), SitePass: GmoPayment::Configurations.all.fetch(:site_pass) } else { ShopID: GmoPayment::Configurations.all.fetch(:shop_id), ShopPass: GmoPayment::Configurations.all.fetch(:shop_pass) } end @time_out = options.fetch(:time_out, nil) @logger = logger || GmoPayment::Logger end
Public Instance Methods
confirm_transaction(params = {})
click to toggle source
# File lib/gmo_payment/api.rb, line 59 def confirm_transaction(params = {}) api_url = GmoPayment::ApiUrls.all.fetch('TRANSACTION_UPDATE') call_api(api_url, params) end
delete_card(params = {})
click to toggle source
# File lib/gmo_payment/api.rb, line 41 def delete_card(params = {}) api_url = GmoPayment::ApiUrls.all.fetch('CARD_DELETE') call_api(api_url, params) end
delete_member(params = {})
click to toggle source
# File lib/gmo_payment/api.rb, line 26 def delete_member(params = {}) api_url = GmoPayment::ApiUrls.all.fetch('MEMBER_DELETE') call_api(api_url, params) end
inspect()
click to toggle source
Prevent inspection
# File lib/gmo_payment/api.rb, line 70 def inspect "#<GmoPayment::Api:#{object_id}>" end
instance_variable_get(*several_variants)
click to toggle source
Calls superclass method
# File lib/gmo_payment/api.rb, line 74 def instance_variable_get(*several_variants) raise GmoPayment::CustomError, 'Not support this method' if PREVENT_VARIABLES.include?(several_variants[0]) super end
register_member(params = {})
click to toggle source
# File lib/gmo_payment/api.rb, line 21 def register_member(params = {}) api_url = GmoPayment::ApiUrls.all.fetch('MEMBER_REGISTER') call_api(api_url, params) end
register_transaction(params = {})
click to toggle source
Transaction normal flow Register > Submit with :JobCd = 'CAPTURE' Register > Submit > Confirm with :JobCd != 'CAPTURE'
# File lib/gmo_payment/api.rb, line 49 def register_transaction(params = {}) api_url = GmoPayment::ApiUrls.all.fetch('TRANSACTION_REGISTER') call_api(api_url, params) end
save_card(params = {})
click to toggle source
# File lib/gmo_payment/api.rb, line 36 def save_card(params = {}) api_url = GmoPayment::ApiUrls.all.fetch('CARD_SAVE_OR_UPDATE') call_api(api_url, params) end
search_member(params = {})
click to toggle source
# File lib/gmo_payment/api.rb, line 31 def search_member(params = {}) api_url = GmoPayment::ApiUrls.all.fetch('MEMBER_SEARCH') call_api(api_url, params) end
submit_transaction(params = {})
click to toggle source
# File lib/gmo_payment/api.rb, line 54 def submit_transaction(params = {}) api_url = GmoPayment::ApiUrls.all.fetch('TRANSACTION_SUBMIT') call_api(api_url, params) end
transaction_status(params = {})
click to toggle source
# File lib/gmo_payment/api.rb, line 64 def transaction_status(params = {}) api_url = GmoPayment::ApiUrls.all.fetch('TRANSACTION_SEARCH') call_api(api_url, params) end
Protected Instance Methods
call_api(api_url, params = {}, method = 'post')
click to toggle source
# File lib/gmo_payment/api.rb, line 81 def call_api(api_url, params = {}, method = 'post') params.merge!(@base_params) request = GmoPayment::ApiRequest.new(api_url, params, @time_out) write_log('---------- START REQUEST TO GMO PAYMENT --------') write_log("REQUEST URL: --------- #{api_url}") write_log("REQUEST PARAMS: ------ #{request.params2log}") response_raw = request.make_request(method) response = GmoPayment::ApiResponse.new(api_url, response_raw.body, response_raw.code.to_i) write_log("RESPONSE: ------------ HTTP #{response.response_code}: #{response.response2log}") write_log("WITH ERRORS: --------- #{response.full_errors2log}") write_log(%(----------- END REQUEST TO GMO PAYMENT --------\n)) response rescue StandardError => e write_log("gmo_payment INTERNAL ERROR: #{e.message} : #{e.backtrace[0, 5]}") raise GmoPayment::CustomError, "gmo_payment error: #{e.message}" end
Private Instance Methods
write_log(log_msg)
click to toggle source
# File lib/gmo_payment/api.rb, line 100 def write_log(log_msg) @logger.write(log_msg) end