Module: SlimpayClient

Defined in:
lib/slimpay_client.rb,
lib/slimpay_client/app.rb,
lib/slimpay_client/base.rb,
lib/slimpay_client/card.rb,
lib/slimpay_client/error.rb,
lib/slimpay_client/order.rb,
lib/slimpay_client/mandate.rb,
lib/slimpay_client/payment.rb,
lib/slimpay_client/version.rb,
lib/slimpay_client/creditor.rb,
lib/slimpay_client/resource.rb,
lib/slimpay_client/card_alias.rb,
lib/slimpay_client/direct_debit.rb,
lib/slimpay_client/configuration.rb,
lib/slimpay_client/recurrent_direct_debit.rb,
lib/slimpay_client/recurrent_card_transaction.rb

Overview

SlimpayClient module defines Simpay’s HAPI constants and require dependencies. TODO: If-None-Match support. (next answer ?= 304) TODO: wiki/doc full worflow: 1. App to change URls, 2. Order to sign mandate, 3. DirectDebit to pay with mandate.

Defined Under Namespace

Classes: App, Base, Card, CardAlias, Configuration, Creditor, DirectDebit, Error, Mandate, Order, Payment, RecurrentCardTransaction, RecurrentDirectDebit, Resource

Constant Summary collapse

PRODUCTION_ENDPOINT =
'https://api.slimpay.net'.freeze
SANDBOX_ENDPOINT =
'https://api.preprod.slimpay.com'.freeze
SANDBOX_CLIENT_ID =
'democreditor01'.freeze
SANDBOX_SECRET_ID =
'demosecret01'.freeze
SANDBOX_CREDITOR =
'democreditor'.freeze
VERSION =
"1.0.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject

Returns the value of attribute configuration.



37
38
39
# File 'lib/slimpay_client.rb', line 37

def configuration
  @configuration
end

Class Method Details

.answer(http_response) ⇒ Object

Used to display HTTP requests responses nicely in case of error.

Arguments:
http_response: (HTTParty::Response)


62
63
64
65
66
67
68
69
70
71
# File 'lib/slimpay_client.rb', line 62

def self.answer(http_response)
  # return SlimpayClient::Error.empty if http_response.try(:body).nil?
  return SlimpayClient::Error.empty if ( http_response.blank? || http_response.body.blank? )

  if http_response.code >= 400
    SlimpayClient::Error.new(http_response)
  else
    http_response.body
  end
end

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

Sets the initial configuration for client_id, client_secret and creditor_reference

Usage:
SlimpayClient.configure do |config|
  config.client_id = "your_client_id"
  config.client_secret = "your_client_secret"
  config.creditor_reference = "your_creditor_reference"
  config.sandbox = true
  config.notify_url = 'you_notifications_url'
  config.success_url = 'your_success_url'
  config.failure_url = 'your_failure_url'
  config.cancel_url = 'your_cancel_url'
  config.return_url = 'your_return_url'
end

Yields:



53
54
55
56
# File 'lib/slimpay_client.rb', line 53

def self.configure
  self.configuration ||= Configuration.new
  yield(configuration)
end