Yes @albertsamsir! I did and I processed around 100k (more than 400 payments) successfully with Mollie. So it’s doing the job !
I have an Autoform where people leave their booking information:
{{#autoForm
schema=bookEventSchema
id="bookEventForm"
type="method"
meteormethod="placeBooking"
doc=emptyEventBooking
class="booking-form"
}}
These are my Autoform hooks (don’t mind the Dutch now and then):
AutoForm.hooks
bookEventForm:
onSuccess: (operation, result) ->
# there is only a paymentUrl for paid events. For free events we skip the Mollie payment platform.
if result.paymentUrl?
swal
title: 'Gelukt!'
type: 'success'
text: 'Nu bezig met oproepen van het betalingssysteem...'
showConfirmButton: false
showCancelButton: false
window.location.replace result.paymentUrl
else
FlowRouter.go 'bookEventConfirmation',
bookingId: result._id
citySlug: result.citySlug
onError: (operation, error) -> sAlert.error 'Het formulier bevat nog fouten, gelieve alles te controleren.'
beginSubmit: -> $('#form-loading-text').fadeIn()
endSubmit: -> $('#form-loading-text').fadeOut()
The result.paymentUrl
comes from a Meteor Method placeBooking
, that is the method attached to the Autoform.
This is the relevant part from the placeBooking
method:
unless @isSimulation
# check if there is a valid referral discount
if referrerId?
try doc = Meteor.call 'applyDiscountCode', bookingId, referrerId
EventEmitter.emit 'newBooking', bookingId, event, city
# Create and fetch a payment
if Settings.get('useOnlinePayments') and not event.isFree() and not event.allowFreeTrial()
Meteor.call 'createPayment', bookingId, (e, payment) ->
unless e
paymentUrl = payment.url
# use mollie's payment id as the new payment id for the booking
Bookings.update bookingId, $set: paymentId: payment.id
return _id: bookingId, citySlug: city.slug, paymentUrl: paymentUrl
I used a seperate method for creating payments: createPayment
. The relevant code is here:
Future = Npm.require 'fibers/future'
Meteor.methods
createPayment: (bookingId) ->
check bookingId, String
booking = Bookings.findOne bookingId
throw new Meteor.Error 'no-booking', 'Geen inschrijving gevonden.' unless booking?
throw new Meteor.Error 'cannot-be-zero', 'Een gratis betaling?!' if booking.price is 0
city = booking.event().city()
future = new Future() # we need to wait for the Async call
mollie = new Mollie.API.Client
mollie.setApiKey Meteor.settings.mollie.apiKey
webhookUrl = if App.inDevelopment() then 'https://cprghddfbi.localtunnel.me/' else Meteor.absoluteUrl 'api/process-payment', secure: Meteor.settings.useSsl
mollie.payments.create
amount: booking.price
description: "#{Settings.get 'organisationName'} Inschrijving"
redirectUrl: Meteor.absoluteUrl "bevestiging/#{bookingId}/#{city.slug}"
webhookUrl: webhookUrl
metadata: bookingId: bookingId
, (payment) ->
if payment.error
console.error payment.error
throw new Meteor.Error 'payment-error', payment.error.message
future.return id: payment.id, url: payment.getPaymentUrl()
return
return future.wait()
I still use an older version of Meteor, so I cannot use NPM directly, that’s why you see the Future = Npm.require 'fibers/future'
on top of the file.
Hope this helps you. Let me know if you have any further questions. Good luck!
PS: what are you building?