-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
106 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,52 @@ | ||
# frozen_string_literal: true | ||
|
||
class MailpaymentController < ApplicationController | ||
before_action :load_booking, only: :edit | ||
before_action :check_token, only: :edit | ||
before_action :check_expire_time, only: :edit | ||
|
||
def create | ||
@booking = Booking.includes(:room).find(params[:id]) | ||
PaymentMailer.payment_booking(@booking).deliver_now | ||
flash[:notice] = t "messages.notice.mailpayment.sent_mail", email: @booking.email_booking.to_s | ||
@booking = Booking.includes(:room).find_by(id: params[:id]) | ||
if @booking | ||
@booking.create_booking_digest | ||
PaymentMailer.payment_booking(@booking).deliver_now | ||
flash[:notice] = t "messages.notice.mailpayment.sent_mail", email: @booking.email_booking.to_s | ||
else | ||
flash[:danger] = t "messages.failed.mailpayment.sent_mail" | ||
end | ||
redirect_to manager_bookings_path | ||
end | ||
|
||
def edit | ||
if @booking.Pending? | ||
redirect_to @booking.paypal_url(payment_booking_path(@booking)) | ||
else | ||
flash[:danger] = t "messages.failed.mailpayment.paymented" | ||
redirect_to root_path | ||
end | ||
end | ||
|
||
private | ||
|
||
def check_token | ||
return if @booking.booking_digest == params[:id] | ||
|
||
flash[:danger] = t "messages.failed.mailpayment.token" | ||
redirect_to root_path | ||
end | ||
|
||
def load_booking | ||
return if @booking = Booking.includes(:room).find_by(id: params[:booking]) | ||
|
||
flash[:danger] = t "messages.failed.mailpayment.sent_mail" | ||
redirect_to root_path | ||
end | ||
|
||
def check_expire_time | ||
return unless @booking.booking_expired? | ||
|
||
@booking.destroy | ||
flash[:danger] = t "messages.failed.mailpayment.expire" | ||
redirect_to root_path | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
paypal_host: https://www.sandbox.paypal.com | ||
app_host: http://514e8bcd.ngrok.io | ||
app_host: http://3fa1c2d5.ngrok.io | ||
email: bookinghomestay@merchant.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters