Created
January 23, 2018 14:35
-
-
Save anchietajunior/f44e8002961255c29a7dd8734443e17b to your computer and use it in GitHub Desktop.
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
def create | |
@payment = Payment.new(payment_params) | |
respond_to do |format| | |
if @payment.save | |
result = CreateInvoiceService.new({payment_id: @payment.id}).charge | |
if result == "pending" | |
format.html { redirect_to @payment, notice: 'Payment was successfully created and Invoice is pending.' } | |
format.json { render :show, status: :created, location: @payment } | |
else | |
format.html { redirect_to @payment, notice: 'Payment was successfully created and Invoice is issued.' } | |
format.json { render :show, status: :created, location: @payment } | |
end | |
else | |
format.html { render :new } | |
format.json { render json: @payment.errors, status: :unprocessable_entity } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment