aviabird / gringotts

A complete payment library for Elixir and Phoenix Framework
https://hexdocs.pm/gringotts/Gringotts.html
MIT License
481 stars 53 forks source link

Response struct should allow multiple tokens #127

Open oyeb opened 6 years ago

oyeb commented 6 years ago

Motivation

To complete a single transaction (say, authorization) with some gateways, various tokens need to be created like customer_token, card_token, session_token, etc. Some tokens expire, some don't and we should return these tokens to the caller for possible re-use.

Proposed Solution

Rename the token field to tokens of the type: keyword.

If the following tokens are generated during an authorization: customer_token, card_token, then they can be returned like so:

%Response{
  ...
  tokens: [customer: "customer_token", card: "card-token"]
}

Todo

barthr commented 5 years ago

Should the value of tokens be a keyword list? I suppose those keys are unique. I think maybe a map would be more sufficient. Anyway, I could tackle this issue if no one else is working on it!