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
20 changed files
with
169 additions
and
12 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require 'mollie/api/client' | ||
|
||
class PaymentWebhookController < ApplicationController | ||
skip_before_filter :verify_authenticity_token, :only => [:mollie] | ||
|
||
def mollie | ||
mollie = Mollie::API::Client.new(Rails.application.secrets.mollie_api_key) | ||
payment_id = params[:id] | ||
|
||
payment = mollie.payments.get payment_id | ||
registration = Registration.find_by_payment_id payment_id | ||
|
||
if payment.paid? | ||
registration.paid = payment.amount | ||
RegistrationMailer.ticket(registration).deliver_now | ||
registration.save! | ||
elsif ['cancelled', 'expired', 'failed'].include? payment.status | ||
RegistrationMailer.payment_failed(registration, registration.event).deliver_now | ||
|
||
registration.destroy! | ||
end | ||
render :nothing => true, :status => 200, :content_type => 'text/html' | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module PaymentWebhookHelper | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /> | ||
</head> | ||
<body> | ||
<p>Dear <%= @registration.name %>,</p> | ||
|
||
<p>You received this mail because the payment for this ticket failed:</p> | ||
|
||
<table> | ||
<tbody> | ||
<tr> | ||
<td><strong>Event</strong></td> | ||
<td><%= @event.name %></td> | ||
</tr> | ||
<tr> | ||
<td><strong>Organisation</strong></td> | ||
<td><%= @event.club.name %></td> | ||
</tr> | ||
<tr> | ||
<td><strong>Location</strong></td> | ||
<td><%= @event.location %></td> | ||
</tr> | ||
<tr> | ||
<td><strong>Start date</strong></td> | ||
<td><%= nice_time @event.start_date %></td> | ||
</tr> | ||
<tr> | ||
<td><strong>End date</strong></td> | ||
<td><%= nice_time @event.end_date %></td> | ||
</tr> | ||
<tr> | ||
<td><strong>Website</strong></td> | ||
<td><a href="<%= @event.website %>"><%= @event.website %></a></td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
<p>If you have any problems, you can contact us via mail: <%= mail_to @event.contact_email, @event.contact_email %></p> | ||
|
||
<p>It's possible to create a new ticket on our website.</p> | ||
|
||
<p>Kind regards,<br /><%= @event.club.name %></p> | ||
|
||
<% unless @event.signature.blank? %> | ||
<%= simple_format @event.signature %> | ||
<% end %> | ||
|
||
</body> | ||
</html> |
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
6 changes: 6 additions & 0 deletions
6
db/migrate/20170817125038_add_payment_method_to_registration.rb
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class AddPaymentMethodToRegistration < ActiveRecord::Migration | ||
def change | ||
add_column :registrations, :payment_method, :string | ||
add_column :registrations, :payment_id, :string | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require 'test_helper' | ||
|
||
class PaymentWebhookControllerTest < ActionController::TestCase | ||
test "should get mollie" do | ||
get :mollie | ||
assert_response :success | ||
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