gringotts v1.0.2 Gringotts.Gateways.Trexle
Trexle Payment Gateway Implementation:
For further details, please refer Trexle API documentation.
Following are the features that have been implemented for the Trexle Gateway:
| Action | Method |
|---|---|
| Authorize | authorize/3 |
| Purchase | purchase/3 |
| Capture | capture/3 |
| Refund | refund/3 |
| Store | store/2 |
The opts argument
A Keyword list opts passed as an optional argument for transactions with the gateway. Following are the keys
supported:
- ip_address
- description
Trexle account registeration with Gringotts
After creating your account successfully on Trexle follow the dashboard link to fetch the secret api_key.
Your Application config must look something like this:
config :gringotts, Gringotts.Gateways.Trexle,
adapter: Gringotts.Gateways.Trexle,
api_key: "Secret API key",
default_currency: "USD"
Link to this section Summary
Functions
Performs the authorization of the card to be used for payment
Captures a particular amount using the charge token of a pre authorized card
Performs the amount transfer from the customer to the merchant
Refunds the amount to the customer’s card with reference to a prior transfer
Stores the card information for future use
Validates the config dynamically depending on what is the value of required_config
Link to this section Functions
Performs the authorization of the card to be used for payment.
Authorizes your card with the given amount and returns a charge token and captured status as false in response.
Example
iex> amount = 100
iex> card = %{
name: "John Doe",
number: "5200828282828210",
expiry_month: 1,
expiry_year: 2018,
cvc: "123",
address_line1: "456 My Street",
address_city: "Ottawa",
address_postcode: "K1C2N6",
address_state: "ON",
address_country: "CA"
}
iex> options = [email: "john@trexle.com", ip_address: "66.249.79.118" , description: "Store Purchase 1437598192"]
iex> Gringotts.authorize(:payment_worker, Gringotts.Gateways.Trexle, amount, card, options)
capture(String.t(), float(), list()) :: map()
Captures a particular amount using the charge token of a pre authorized card.
The amount specified should be less than or equal to the amount given prior to capture while authorizing the card. If the amount mentioned is less than the amount given in authorization process, the mentioned amount is debited. Please note that multiple captures can’t be performed for a given charge token from the authorization process.
Example
iex> amount = 100
iex> token = "charge_6a5fcdc6cdbf611ee3448a9abad4348b2afab3ec"
iex> Gringotts.capture(:payment_worker, Gringotts.Gateways.Trexle, token, amount)
Performs the amount transfer from the customer to the merchant.
The actual amount deduction performed by Trexle using the customer’s card info.
Example
iex> card = %{
name: "John Doe",
number: "5200828282828210",
expiry_month: 1,
expiry_year: 2018,
cvc: "123",
address_line1: "456 My Street",
address_city: "Ottawa",
address_postcode: "K1C2N6",
address_state: "ON",
address_country: "CA"
}
iex> options = [email: "john@trexle.com", ip_address: "66.249.79.118" ,description: "Store Purchase 1437598192"]
iex> amount = 50
iex> Gringotts.purchase(:payment_worker, Gringotts.Gateways.Trexle, amount, card, options)
refund(float(), String.t(), list()) :: map()
Refunds the amount to the customer’s card with reference to a prior transfer.
Trexle processes a full or partial refund worth amount, referencing a
previous purchase/3 or capture/3.
Multiple refund can be performed for the same charge token from purchase or capture done before performing refund action unless the cumulative amount is less than the amount given while authorizing.
Example
The following session shows how one would refund a previous purchase (and similarily for captures).
iex> amount = 5
iex> token = "charge_668d3e169b27d4938b39246cb8c0890b0bd84c3c"
iex> options = [email: "john@trexle.com", ip_address: "66.249.79.118", description: "Store Purchase 1437598192"]
iex> Gringotts.refund(:payment_worker, Gringotts.Gateways.Trexle, amount, token, options)
Stores the card information for future use.
Example
The following session shows how one would store a card (a payment-source) for future use.
iex> card = %{
name: "John Doe",
number: "5200828282828210",
expiry_month: 1,
expiry_year: 2018,
cvc: "123",
address_line1: "456 My Street",
address_city: "Ottawa",
address_postcode: "K1C2N6",
address_state: "ON",
address_country: "CA"
}
iex> options = [email: "john@trexle.com", ip_address: "66.249.79.118", description: "Store Purchase 1437598192"]
iex> Gringotts.store(:payment_worker, Gringotts.Gateways.Trexle, card, options)
Validates the config dynamically depending on what is the value of required_config