2021-04-01 18:20:26 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# API Controller for accessing PayZen API endpoints through the front-end app
|
2021-04-09 17:17:58 +02:00
|
|
|
class API::PayzenController < API::PaymentsController
|
2021-04-01 18:20:26 +02:00
|
|
|
require 'pay_zen/charge'
|
|
|
|
|
|
|
|
def sdk_test
|
|
|
|
str = 'fab-manager'
|
|
|
|
|
|
|
|
client = PayZen::Charge.new(base_url: params[:base_url], username: params[:username], password: params[:password])
|
|
|
|
res = client.sdk_test(str)
|
|
|
|
|
2021-04-02 17:16:27 +02:00
|
|
|
@status = (res['answer']['value'] == str)
|
|
|
|
rescue SocketError
|
|
|
|
@status = false
|
2021-04-01 18:20:26 +02:00
|
|
|
end
|
2021-04-09 17:17:58 +02:00
|
|
|
|
|
|
|
def create_payment
|
|
|
|
amount = card_amount
|
|
|
|
|
|
|
|
client = PayZen::Charge.new
|
|
|
|
@result = client.create_payment(amount: amount, customer: { reference: params[:customer][:id], email: params[:customer][:email] })
|
|
|
|
end
|
2021-04-01 18:20:26 +02:00
|
|
|
end
|