Created
July 18, 2020 22:05
-
-
Save hakimkal/cd975d527550582dff33769176b0c777 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 payment_transactions(conn, params)do | |
| pay_provider = params["provider"] | |
| #check pay provider | |
| if pay_provider == "paystack" do | |
| pay_status = check_paystack_status(transaction_ref) | |
| if pay_status[:status] do | |
| #create transaction record | |
| paymt = %{ | |
| status: pay_status[:status], | |
| } | |
| #Persist paystack transaction | |
| {:ok, payment_log} = Payments.create_transaction(paymt) | |
| if pay_status[:status] == "success" do | |
| dattrs = %{ | |
| payment_status: true, | |
| approved_amount: pay_status[:amount], | |
| transaction_code: transaction_ref | |
| } | |
| conn | |
| |> put_flash(:info, "Your payment is confirmed, provide details about your request!") | |
| |> render("path.html") | |
| else | |
| #redirect to home page and inform user that payment is not verified | |
| conn | |
| |> put_flash(:info, "We are unable to verify your payment at this time, We will provide you a link soonest!") | |
| |> redirect(to: Routes.page_path(conn, :dashboard)) | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment