Class: Omnipay::Adapters::Oneclicpay
- Inherits:
-
Object
- Object
- Omnipay::Adapters::Oneclicpay
- Defined in:
- lib/omnipay/adapters/oneclicpay.rb
Constant Summary collapse
- HTTP_METHOD =
'POST'- REDIRECT_URLS =
{ :sandbox => 'https://secure.homologation.oneclicpay.com', :production => 'https://secure.oneclicpay.com' }
- VALIDATION_URLS =
{ :sandbox => 'https://secure.homologation.oneclicpay.com:60000', :production => 'https://secure.oneclicpay.com:60000' }
Instance Method Summary collapse
- #callback_hash(params) ⇒ Object
-
#initialize(callback_url, config) ⇒ Oneclicpay
constructor
A new instance of Oneclicpay.
- #request_phase(amount, params = {}) ⇒ Object
Constructor Details
#initialize(callback_url, config) ⇒ Oneclicpay
Returns a new instance of Oneclicpay.
30 31 32 33 34 35 36 37 38 |
# File 'lib/omnipay/adapters/oneclicpay.rb', line 30 def initialize(callback_url, config) @callback_url = callback_url @tpe_id = config[:tpe_id] @secret_key = config[:secret_key] @is_sandbox = config[:sandbox] raise ArgumentError.new("Missing tpe_id or secret_key parameter") unless [@tpe_id, @secret_key].all? end |
Instance Method Details
#callback_hash(params) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/omnipay/adapters/oneclicpay.rb', line 55 def callback_hash(params) if params[:result] == "NOK" && params[:reason] == "Abandon de la transaction." return { :success => false, :error => Omnipay::CANCELATION } end if params[:result] == "OK" # Validate the response via the API transaction_id = params[:transactionId] amount = get_transaction_amount(transaction_id) if amount { :success => true, :amount => amount, :transaction_id => transaction_id } else { :success => false, :error => Omnipay::INVALID_RESPONSE, :error_message => "Could not fetch the amount of the transaction #{transaction_id}" } end elsif params[:result] == "NOK" { :success => false, :error => Omnipay::PAYMENT_REFUSED, :error_message => params[:reason] } else { :success => false, :error => Omnipay::INVALID_RESPONSE, :error_message => "No :result key in the params #{params.inspect}" } end end |
#request_phase(amount, params = {}) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/omnipay/adapters/oneclicpay.rb', line 41 def request_phase(amount, params={}) product_name = params[:title] || '' transaction_id = params[:transaction_id] || random_transaction_id locale = params[:locale] || 'fr' [ HTTP_METHOD, redirect_url, redirect_params_for(amount, product_name, transaction_id, locale), transaction_id ] end |