Class: ShopeePayService::Base

Inherits:
Object
  • Object
show all
Defined in:
app/services/shopee_pay_service/base.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/services/shopee_pay_service/base.rb', line 23

def execute
  resp = api_call
  raise Error, { 'debug_msg' => 'invalid_signature' } unless valid_signature?(resp)

  parsed_body = JSON.parse(resp.body).with_indifferent_access
  raise Error, parsed_body if parsed_body['errcode'] != 0

  parsed_body

rescue Faraday::TimeoutError, Faraday::ConnectionFailed
  @reservation.errors.add(:base, 'Connection time out, please try again')
  false
end