lib/fawry.rb in fawry-0.2.0 vs lib/fawry.rb in fawry-0.3.0
- old
+ new
@@ -1,12 +1,14 @@
# frozen_string_literal: true
require 'fawry/version'
require 'fawry/connection'
require 'fawry/errors'
+require 'fawry/utils'
require 'fawry/fawry_request'
require 'fawry/fawry_response'
+require 'fawry/fawry_callback'
require 'fawry/requests/charge_request'
require 'fawry/requests/refund_request'
require 'fawry/requests/payment_status_request'
require 'fawry/contracts/charge_request_contract'
require 'fawry/contracts/refund_request_contract'
@@ -43,11 +45,11 @@
# @option opts :sandbox [Boolean] whether to
# send the request to fawry sandbox env or not
# false by default
# Example: `Fawry.charge(params, sandbox: true)`
#
- # @raise [Fawry::InvalidFawryRequest] raised when one
+ # @raise [Fawry::InvalidFawryRequestError] raised when one
# or more of the params are invalid. the message
# specifices which params and why are they invalid
#
# @return [Fawry::FawryResponse] an object that
# has Fawry API response keys as instance methods
@@ -71,11 +73,11 @@
# configure the request
# @option opts :sandbox [Boolean] whether to
# send the request to fawry sandbox env or not
# false by default
#
- # @raise [Fawry::InvalidFawryRequest] raised when one
+ # @raise [Fawry::InvalidFawryRequestError] raised when one
# or more of the params are invalid. the message
# specifices which params and why are they invalid
#
# @return [Fawry::FawryResponse] an object that
# has Fawry API response keys as instance methods
@@ -97,17 +99,37 @@
# configure the request
# @option opts :sandbox [Boolean] whether to
# send the request to fawry sandbox env or not
# false by default
#
- # @raise [Fawry::InvalidFawryRequest] raised when one
+ # @raise [Fawry::InvalidFawryRequestError] raised when one
# or more of the params are invalid. the message
# specifices which params and why are they invalid
#
# @return [Fawry::FawryResponse] an object that
# has Fawry API response keys as instance methods
# plus some convenience methods e.g. success?
def payment_status(params, opts = {})
FawryRequest.new('payment_status', params, opts).fire_payment_status_request
+ end
+
+ # Parses Fawry callback v2 into
+ # FawryCallback object with callback
+ # params as instance methods
+ #
+ # @param params [Hash] list of params sent
+ # from fawry server callback
+ #
+ # @param opts [Hash] list of options to
+ # configure the request. currently no
+ # options available
+ #
+ # @raise [Fawry::InvalidSignatureError] raised when
+ # request signature cannot be verified
+ #
+ # @return [Fawry::FawryCallback] an object that
+ # has Fawry server callback params' keys as instance methods
+ def parse_callback(params, fawry_secure_key, opts = {})
+ FawryCallback.new(params, fawry_secure_key, opts).parse
end
end
end