Skip to content

Commit

Permalink
added callbakc for payment by mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegPhenomenon committed Mar 25, 2024
1 parent ca624b0 commit dd87de5
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,6 @@ yarn-debug.log*
/public/assets/
/public/assets/builds
public/assets/builds/*
app/assets/builds/*
app/assets/builds/*

.DS_Store
9 changes: 7 additions & 2 deletions app/controllers/api/v1/offers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,20 @@ def create
Rails.logger.info(params)
Rails.logger.info('----')

#{"bid"=>{"price"=>320.0, "auction_id"=>"2a893210-f1f1-4be8-9d78-b793f1fa0ec6", "billing_profile_id"=>"23"},
#"controller"=>"api/v1/offers", "action"=>"create", "offer"=>{}}

auction = Auction.find_by(uuid: params[:bid][:auction_id])
return if auction.nil?

offer = auction.offer_from_user(current_user.uuid)

billing_profile = current_user.billing_profiles.find_by(id: params[:bid][:billing_profile_id])

offer = auction.offer_from_user(current_user.id)

Rails.logger.info('----')
Rails.logger.info(current_user.inspect)
Rails.logger.info(billing_profile.inspect)
Rails.logger.info(offer.inspect)
Rails.logger.info('----')

if offer.nil?
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/api/v1/tara_auth_sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def create

if @user.present?
sign_in(User, @user)
render json: { message: 'User signed in', user: @user }, status: :ok
render json: { message: 'User signed in', user: @user, token: current_token }, status: :ok
else
render json: { error: 'User not found' }, status: :not_found
end
Expand All @@ -30,6 +30,10 @@ def check_for_permission
# TODO:
true
end

def current_token
request.env['warden-jwt_auth.token']
end
end
end
end
11 changes: 11 additions & 0 deletions app/controllers/mobile_payments_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class MobilePaymentsController < ApplicationController
skip_before_action :verify_authenticity_token, only: %i[callback]

def callback
EisBilling::SendCallbackService.call(reference_number: linkpay_params[:payment_reference])

redirect_to mobile_payments_path
end

def index; end
end
3 changes: 3 additions & 0 deletions app/models/auction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ class Auction < ApplicationRecord # rubocop:disable Metrics
delegate :size, to: :offers, prefix: true

def update_list_broadcast
return if blind?

Auctions::UpdateListBroadcastService.call({ auction: self })
end

def update_offer_broadcast
return if blind?
Auctions::UpdateOfferBroadcastService.call({ auction: self })
end

Expand Down
1 change: 1 addition & 0 deletions app/views/mobile_payments/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Payment was paid! you can close the window arrrggg!!!
2 changes: 1 addition & 1 deletion config/initializers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def skip_format?

config.jwt do |jwt|
jwt.secret = AuctionCenter::Application.config.customization[:jwt_secret]
jwt.dispatch_requests = [ ['POST', %r{^/sessions/sign_in$}] ]
jwt.dispatch_requests = [ ['POST', %r{^/sessions/sign_in$}], ['POST', %r{^/api/v1/tara_auth_session}] ]
jwt.revocation_requests = [ ['DELETE', %r{^/sessions/sign_out$}] ]
jwt.expiration_time = 30.minutes.to_i
end
Expand Down
8 changes: 4 additions & 4 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
match '/auth/tara/cancel', via: %i[get post delete], to: 'auth/tara#cancel',
as: :tara_cancel
match '/auth/tara/create', via: [:post], to: 'auth/tara#create', as: :tara_create
match '/api/v1/tara_auth_sessions', via: [:post], to: 'api/v1/tara_auth_sessions#create'
end

devise_for :users, path: 'sessions',
Expand Down Expand Up @@ -125,10 +126,6 @@

resources :payment_orders, only: %i[new show create], shallow: true, param: :uuid do
member do
# get 'return'
# put 'return'
# post 'return'

post 'callback'
end
end
Expand All @@ -137,6 +134,9 @@
match '/linkpay_callback', via: %i[get], to: 'linkpay#callback', as: :linkpay_callback
match '/linkpay_deposit_callback', via: %i[get], to: 'linkpay#deposit_callback', as: :deposit_callback

match '/mobile_payments_callback', via: %i[get], to: 'mobile_payments#callback', as: :mobile_payments_callback
get '/mobile_payments', to: 'mobile_payments#index', as: :mobile_payments

resource :locale, only: :update
resources :offers, only: :index
resources :results, only: :show, param: :uuid
Expand Down

0 comments on commit dd87de5

Please sign in to comment.