- Notifications
You must be signed in to change notification settings - Fork6
Mollie Payments API client for Crystalhttp://www.mollie.com
License
wout/mollie.cr
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
AcceptingiDEAL,Bancontact,SOFORT Banking,Creditcard,SEPA Bank transfer,SEPA Direct debit,PayPal,KBC/CBC Payment Button,Belfius Direct Net,paysafecard,ING Home’Pay,Gift cards,EPS,Giropay andApple Pay online payments without fixed monthly costs or any punishing registration procedures. Just use the Mollie API to receive payments directly on your website or easily refund transactions to your customers.
This is the unofficialCrystal shard for Mollie.It's directly ported from the Ruby version(mollie-ruby-api) but not an exactcopy. Usage may vary from the Ruby version due to language differences and tomake the most of Crystal's type system.
To use the Mollie API client, the following things are required:
- Get yourself a freeMollie account. No sign up costs.
- Create a newWebsite profile to generate API keys (live and test mode) and setup your webhook.
- Now you're ready to use the Mollie API client in test mode.
- In order to accept payments in live mode, payment methods must be activated in your account. Followa few of steps, and let us handle the rest.
Add mollie as a depencency to your application'sshard.yml
:
dependencies:mollie:github:wout/mollie.cr
Then runshards install
.
Create an initializer and add the following line:
Mollie.configuredo |config| config.api_key=ENV["MOLLIE_API_KEY"]end
You can also include a client instance in each request you make:
Mollie::Payment.get("pay-id",client:Mollie::Client.new("<your-api-key>"))
If you need to do multiple calls with the same API Key, use the following helper:
Mollie::Client.with_api_key("<your-api-key>")do |mollie| mandates= mollie.customer_mandate.all({customer_id:"customer-id" })returnif mandates.empty? payment= mollie.payment.create({amount: {value:"10.00",currency:"EUR", },method:"creditcard",description:"My first API payment",redirect_url:"https://webshop.example.org/order/12345/",webhook_url:"https://webshop.example.org/mollie-webhook/", })end
payment=Mollie::Payment.create({amount: {value:"10.00",currency:"EUR", },method:"creditcard",description:"My first API payment",redirect_url:"https://shop.org/order/12345",webhook_url:"https://shop.org/mollie-webhook", })
Note: Make sure to send the right amount of decimals and omit the thousandsseparator. Non-string values are not accepted.
To ensure amount values always carry the correct amount of decimals, an instanceofMollie::Amount
can be passed, which accepts integers, floats and strings:
payment=Mollie::Payment.create({amount:Mollie::Amount.new(10,"EUR"),method:"creditcard",description:"My first API payment",})
payment=Mollie::Payment.get("pay-id")puts"Payment received."if payment.paid?
The API also supports refunding payments. Note that there is no confirmation andthat all refunds are immediate and definitive. Refunds are only supported forcertain payment methods.
payment=Mollie::Payment.get("pay-id")refund= payment.refund!({amount: {value:"10.00",currency:"EUR" }})
Fetching all objects of a resource can be convenient. At the same time,returning too many objects at once can be unpractical from a performanceperspective. Doing so might be too much work for the Mollie API to generate, orfor your website to process. The maximum number of objects returned is 250.
For this reason the Mollie API only returns a subset of the requested set ofobjects. In other words, the Mollie API chops the result of a certain API methodcall into pages you’re able to programmatically scroll through.
payments=Mollie::Payment.allpayments.nextpayments.previous
- Fork it (https://github.com/your-github-user/mollie/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
- wout - creator and maintainer
BSD (Berkeley Software Distribution) License.
Mollie Contact:www.mollie.com —info@mollie.com — +31 20-612 88 55
- More information about iDEAL via Mollie
- More information about Credit card via Mollie
- More information about Apple Pay via Mollie
- More information about Bancontact via Mollie
- More information about SOFORT Banking via Mollie
- More information about SEPA Bank transfer via Mollie
- More information about SEPA Direct debit via Mollie
- More information about PayPal via Mollie
- More information about KBC/CBC Payment Button via Mollie
- More information about Belfius Direct Net via Mollie
- More information about paysafecard via Mollie
- More information about ING Home’Pay via Mollie
- More information about Gift cards via Mollie
- More information about EPS via Mollie
- More information about Giropay via Mollie
About
Mollie Payments API client for Crystalhttp://www.mollie.com