1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00
fab-manager/app/controllers/api/payzen_controller.rb
2021-04-09 17:17:58 +02:00

25 lines
700 B
Ruby

# frozen_string_literal: true
# API Controller for accessing PayZen API endpoints through the front-end app
class API::PayzenController < API::PaymentsController
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)
@status = (res['answer']['value'] == str)
rescue SocketError
@status = false
end
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
end