gringotts v1.0.0 Gringotts.Gateways.Monei

An API client for the MONEI gateway.

For reference see MONEI’s API (v1) documentation.

The following features of MONEI are implemented:

typeActionMethod
PAPre-authorizeauthorize/3
CPCapturecapture/3
DBDebitpurchase/3
RFRefundrefund/3
RVReversalvoid/2
Tokenization / Registrationsstore/2

The opts argument

Most Gringotts API calls accept an optional Keyword list opts to supply optional arguments for transactions with the MONEI gateway. The following keys are supported:

KeyRemarkStatus
billing_addressNot implemented
cartNot implemented
currencyImplemented
customParametersNot implemented
customerNot implemented
invoiceNot implemented
merchantNot implemented
shipping_addressNot implemented
shipping_customerNot implemented

MONEI quirks

  • MONEI does not process money in cents, and the amount is rounded to 2 decimal places.

Caveats

Although MONEI supports payments from various cards, banks and virtual accounts (like some wallets), this library only accepts payments by (supported) cards.

TODO

Link to this section Summary

Functions

Performs a (pre) Authorize operation

Captures a pre-authorized amount

Makes the request to MONEI’s network

Transfers amount from the customer to the merchant

Refunds the amount to the customer’s account with reference to a prior transfer

Parses MONEI’s response and returns a Gringotts.Response struct in a :ok, :error tuple

Stores the payment-source data for later use

Validates the config dynamically depending on what is the value of required_config

Voids the referenced payment

Link to this section Functions

Link to this function authorize(amount, card, opts)
authorize(number(), Gringotts.CreditCard, keyword()) :: Gringotts.Response

Performs a (pre) Authorize operation.

The authorization validates the card details with the banking network, places a hold on the transaction amount in the customer’s issuing bank and also triggers risk management. Funds are not transferred.

MONEI returns an ID string which can be used to:

Note

A stand-alone pre-authorization expires in 72hrs.

Link to this function capture(amount, paymentId, opts)
capture(number(), String.t(), keyword()) :: Gringotts.Response

Captures a pre-authorized amount.

amount is transferred to the merchant account by MONEI when it is smaller or equal to the amount used in the pre-authorization referenced by paymentId.

Note

MONEI allows partial captures and unlike many other gateways, does not release the remaining amount back to the payment source. Thus, the same pre-authorisation ID can be used to perform multiple captures, till:

  • all the pre-authorized amount is captured or,
  • the remaining amount is explicitly “reversed” via void/2. [citation-needed]
Link to this function commit(method, endpoint, params, opts)
commit(atom(), String.t(), keyword(), keyword()) ::
  {:ok, HTTPoison.Response} |
  {:error, HTTPoison.Error}

Makes the request to MONEI’s network.

Link to this function purchase(amount, card, opts)
purchase(number(), Gringotts.CreditCard, keyword()) :: Gringotts.Response

Transfers amount from the customer to the merchant.

MONEI attempts to process a purchase on behalf of the customer, by debiting amount from the customer’s account by charging the customer’s card.

Link to this function refund(amount, paymentId, opts)
refund(number(), String.t(), keyword()) :: Gringotts.Response

Refunds the amount to the customer’s account with reference to a prior transfer.

MONEI processes a full or partial refund worth amount, referencing a previous purchase/3 or capture/3.

The end customer will always see two bookings/records on his statement. Refer MONEI’s Backoffice Operations guide.

Link to this function respond(monei_response)
respond(term()) ::
  {:ok, Gringotts.Response} |
  {:error, Gringotts.Response}

Parses MONEI’s response and returns a Gringotts.Response struct in a :ok, :error tuple.

Link to this function store(card, opts)
store(Gringotts.CreditCard, keyword()) :: Gringotts.Response

Stores the payment-source data for later use.

MONEI can store the payment-source details, for example card or bank details which can be used to effectively process One-Click and Recurring payments, and return a registration token for reference.

It is recommended to associate these details with a “Customer” by passing customer details in the opts.

Note

  • One-Click and Recurring payments are currently not implemented.
  • Payment details can be saved during a purchase/3 or capture/3.
Link to this function unstore(arg1, opts)
unstore(String.t(), keyword()) :: Gringotts.Response

WIP

MONEI unstore does not seem to work. MONEI always returns a 403

Deletes previously stored payment-source data.

Link to this function validate_config(config)

Validates the config dynamically depending on what is the value of required_config

Link to this function void(paymentId, opts)
void(String.t(), keyword()) :: Gringotts.Response

Voids the referenced payment.

This method attempts a reversal of the either a previous purchase/3 or authorize/3 referenced by paymentId.

As a consequence, the customer will never see any booking on his statement. Refer MONEI’s Backoffice Operations guide.

Voiding a previous authorization

MONEI will reverse the authorization by sending a “reversal request” to the payment source (card issuer) to clear the funds held against the authorization. If some of the authorized amount was captured, only the remaining amount is cleared. [citation-needed]

Voiding a previous purchase

MONEI will reverse the payment, by sending all the amount back to the customer. Note that this is not the same as refund/3.