Module: Fawry

Defined in:
lib/fawry.rb,
lib/fawry/utils.rb,
lib/fawry/config.rb,
lib/fawry/errors.rb,
lib/fawry/version.rb,
lib/fawry/connection.rb,
lib/fawry/fawry_request.rb,
lib/fawry/fawry_callback.rb,
lib/fawry/fawry_response.rb,
lib/fawry/requests/charge_request.rb,
lib/fawry/requests/refund_request.rb,
lib/fawry/requests/list_tokens_request.rb,
lib/fawry/requests/delete_token_request.rb,
lib/fawry/requests/payment_status_request.rb,
lib/fawry/contracts/charge_request_contract.rb,
lib/fawry/contracts/refund_request_contract.rb,
lib/fawry/requests/create_card_token_request.rb,
lib/fawry/contracts/list_tokens_request_contract.rb,
lib/fawry/contracts/delete_token_request_contract.rb,
lib/fawry/contracts/payment_status_request_contract.rb,
lib/fawry/contracts/create_card_token_request_contract.rb

Defined Under Namespace

Modules: Contracts, Requests, Utils Classes: Configuration, Connection, FawryCallback, FawryRequest, FawryResponse, InvalidFawryRequestError, InvalidSignatureError

Constant Summary collapse

VERSION =
'1.4.1'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject

Returns the value of attribute configuration.



5
6
7
# File 'lib/fawry/config.rb', line 5

def configuration
  @configuration
end

Class Method Details

.charge(params, opts = {}) ⇒ Fawry::FawryResponse

Sends a charge request to Fawry API performs param validation and builds the request signature

required(:merchant_ref_num).value(:string) required(:customer_profile_id).value(:string) required(:amount).value(:decimal) required(:description).value(:string) required(:customer_mobile).value(:string) required(:charge_items).array(:hash) do

required(:item_id).value(:string)
required(:description).value(:string)
required(:price).value(:decimal)
required(:quantity).value(:integer)

end optional(:merchant_code).value(:string) optional(:fawry_secure_key).value(:string) optional(:currency_code).value(:string) optional(:card_token).value(:string) optional(:customer_email).value(:string) optional(:payment_method).value(:string) optional(:payment_expiry).value(:integer)

configure the request send the request to fawry sandbox env or not false by default Example: ‘Fawry.charge(params, sandbox: true)`

or more of the params are invalid. the message specifices which params and why are they invalid

has Fawry API response keys as instance methods plus some convenience methods e.g. success?

Parameters:

  • params (Hash)

    list of params to send to fawry

  • opts (Hash) (defaults to: {})

    list of options to

Options Hash (opts):

  • :sandbox (Boolean)

    whether to

Returns:

Raises:



70
71
72
# File 'lib/fawry.rb', line 70

def charge(params, opts = {})
  FawryRequest.new('charge', params, opts).fire_charge_request
end

.configure {|configuration| ... } ⇒ Object

Yields:



7
8
9
10
11
# File 'lib/fawry/config.rb', line 7

def configure
  self.configuration ||= Configuration.new

  yield(configuration)
end

.create_card_token(params, opts = {}) ⇒ Fawry::FawryResponse

Sends a card token request to Fawry API performs param validation and builds the request signature

required(:customer_profile_id).value(:string) required(:customer_mobile).value(:string) required(:merchant_code).value(:string) required(:customer_email).value(:string) required(:card_number).value(:string) required(:expiry_year).value(:string) required(:expiry_month).value(:string) required(:cvv).value(:string)

configure the request send the request to fawry sandbox env or not false by default

or more of the params are invalid. the message specifices which params and why are they invalid

has Fawry API response keys as instance methods plus some convenience methods e.g. success?

Parameters:

  • params (Hash)

    list of params to send to fawry

  • opts (Hash) (defaults to: {})

    list of options to

Options Hash (opts):

  • :sandbox (Boolean)

    whether to

Returns:

Raises:



156
157
158
# File 'lib/fawry.rb', line 156

def create_card_token(params, opts = {})
  FawryRequest.new('create_card_token', params, opts).fire_create_card_token_request
end

.delete_token(params, opts = {}) ⇒ Fawry::FawryResponse

Sends delete token request to Fawry API performs param validation and builds the request signature

required(:customer_profile_id).value(:string) optional(:merchant_code).value(:string) optional(:fawry_secure_key).value(:string)

configure the request send the request to fawry sandbox env or not false by default

or more of the params are invalid. the message specifices which params and why are they invalid

has Fawry API response keys as instance methods plus some convenience methods e.g. success?

Parameters:

  • params (Hash)

    list of params to send to fawry

  • opts (Hash) (defaults to: {})

    list of options to

Options Hash (opts):

  • :sandbox (Boolean)

    whether to

Returns:

Raises:



210
211
212
# File 'lib/fawry.rb', line 210

def delete_token(params, opts = {})
  FawryRequest.new('delete_token', params, opts).fire_delete_token_request
end

.list_tokens(params, opts = {}) ⇒ Fawry::FawryResponse

Sends a list tokens request to Fawry API performs param validation and builds the request signature

required(:merchant_code).value(:string) required(:customer_profile_id).value(:string) optional(:fawry_secure_key).value(:string)

configure the request send the request to fawry sandbox env or not false by default

or more of the params are invalid. the message specifices which params and why are they invalid

has Fawry API response keys as instance methods plus some convenience methods e.g. success?

Parameters:

  • params (Hash)

    list of params to send to fawry

  • opts (Hash) (defaults to: {})

    list of options to

Options Hash (opts):

  • :sandbox (Boolean)

    whether to

Returns:

Raises:



183
184
185
# File 'lib/fawry.rb', line 183

def list_tokens(params, opts = {})
  FawryRequest.new('list_tokens', params, opts).fire_list_tokens_request
end

.parse_callback(params, opts = {}) ⇒ Fawry::FawryCallback

Parses Fawry callback v2 into FawryCallback object with callback params as instance methods

from fawry server callback

configure the request. currently no options available

request signature cannot be verified

has Fawry server callback params’ keys as instance methods

Parameters:

  • params (Hash)

    list of params sent

  • opts (Hash) (defaults to: {})

    list of options to

Returns:

Raises:



230
231
232
# File 'lib/fawry.rb', line 230

def parse_callback(params, opts = {})
  FawryCallback.new(params, opts).parse
end

.payment_status(params, opts = {}) ⇒ Fawry::FawryResponse

Sends a payment status request to Fawry API performs param validation and builds the request signature

required(:merchant_ref_number).value(:string) optional(:merchant_code).value(:string) optional(:fawry_secure_key).value(:string)

configure the request send the request to fawry sandbox env or not false by default

or more of the params are invalid. the message specifices which params and why are they invalid

has Fawry API response keys as instance methods plus some convenience methods e.g. success?

Parameters:

  • params (Hash)

    list of params to send to fawry

  • opts (Hash) (defaults to: {})

    list of options to

Options Hash (opts):

  • :sandbox (Boolean)

    whether to

Returns:

Raises:



124
125
126
# File 'lib/fawry.rb', line 124

def payment_status(params, opts = {})
  FawryRequest.new('payment_status', params, opts).fire_payment_status_request
end

.refund(params, opts = {}) ⇒ Fawry::FawryResponse

Sends a refund request to Fawry API performs param validation and builds the request signature

required(:reference_number).value(:string) required(:refund_amount).value(:decimal) optional(:merchant_code).value(:string) optional(:fawry_secure_key).value(:string) optional(:reason).value(:string)

configure the request send the request to fawry sandbox env or not false by default

or more of the params are invalid. the message specifices which params and why are they invalid

has Fawry API response keys as instance methods plus some convenience methods e.g. success?

Parameters:

  • params (Hash)

    list of params to send to fawry

  • opts (Hash) (defaults to: {})

    list of options to

Options Hash (opts):

  • :sandbox (Boolean)

    whether to

Returns:

Raises:



98
99
100
# File 'lib/fawry.rb', line 98

def refund(params, opts = {})
  FawryRequest.new('refund', params, opts).fire_refund_request
end