mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-17 06:52:27 +01:00
retreive the formToken from PZ API
This commit is contained in:
parent
b3720d7f47
commit
ef7dcd37d8
@ -3,6 +3,7 @@
|
||||
# API Controller for accessing PayZen API endpoints through the front-end app
|
||||
class API::PayzenController < API::PaymentsController
|
||||
require 'pay_zen/charge'
|
||||
require 'pay_zen/helper'
|
||||
|
||||
def sdk_test
|
||||
str = 'fab-manager'
|
||||
@ -17,8 +18,12 @@ class API::PayzenController < API::PaymentsController
|
||||
|
||||
def create_payment
|
||||
amount = card_amount
|
||||
@id = PayZen::Helper.generate_ref(cart_items_params, params[:customer])
|
||||
|
||||
client = PayZen::Charge.new
|
||||
@result = client.create_payment(amount: amount, customer: { reference: params[:customer][:id], email: params[:customer][:email] })
|
||||
@result = client.create_payment(amount: amount[:amount],
|
||||
order_id: @id,
|
||||
customer: { reference: params[:customer][:id], email: params[:customer][:email] })
|
||||
@result
|
||||
end
|
||||
end
|
||||
|
@ -50,8 +50,8 @@ export const PayzenForm: React.FC<PayzenFormProps> = ({ onSubmit, onSuccess, onE
|
||||
});
|
||||
|
||||
const submitEmbeddedPayzenForm = (): void => {
|
||||
// FIXME: not working...
|
||||
const button: HTMLButtonElement = document.querySelector('button.kr-payment-button');
|
||||
button.setAttribute('type', 'button');
|
||||
button.click()
|
||||
}
|
||||
|
||||
|
@ -4,4 +4,5 @@ export interface SdkTestResponse {
|
||||
|
||||
export interface CreatePaymentResponse {
|
||||
formToken: string
|
||||
orderId: string
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
json.formToken @result['answer']
|
||||
json.formToken @result['answer']['formToken']
|
||||
json.orderId @id
|
||||
|
@ -16,5 +16,12 @@ class PayZen::Helper
|
||||
end
|
||||
res
|
||||
end
|
||||
|
||||
def generate_ref(cart_items, customer)
|
||||
require 'sha3'
|
||||
|
||||
content = { cart_items: cart_items, customer: customer }.to_json + DateTime.current.to_s
|
||||
SHA3::Digest.hexdigest(:sha256, content)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user