EPTSDK
A SDK (software development kit) for interacting with the Edge Payment Technologies, Inc HTTP API.
Using
In order to use the SDK you need two things:
- A merchant with Edge Payment Technologies with a minimum amount of business information.
- A sandbox or production private key from the dashboard.
Once you have those two things you need to instantiate a client. This client can be used for multiple requests. The only two required parameters for a client are the token and user_agent. The former is used for authenticating your requests and the latter is used for identifying your usage. User Agent identity helps us find clients that aren't behaving correctly and communicate with their owner. You can read more here https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent and https://docs.newrelic.com/docs/apis/rest-api-v2/basic-functions/set-custom-user-agent/
client = EPTSDK.client(%{
token: "ept_sandbox_sQsnYGFoLvE2Qt7tmsvuDESB2TBBA2wf1UfQruzmenG14tTMHb",
user_agent: "BigShoeApp/1.0",
})
We can now use that client to make requests:
{:ok, customerA, [], client} = EPTSDK.Customer.create(client, attributes: %{
name: "Johnson Parker",
email: "johnson@example.com"
})
{:ok, customerB, included, client} = client
|> EPTSDK.Customer.list(
filter: %{name: "Johnson Parker"},
include: ["address"],
sort: ["name"],
fields: %{customers: ["name"]}
)
|> List.first()
customerA == customerB
{:ok, customerA, [], client} = EPTSDK.Customer.update(client, customerA, attributes: %{
name: "Sally"
})
Payment subscription proration
When you create or confirm a payment subscription with proration_behavior: :create_prorations
and a future billing_cycle_anchor_at, Edge creates an immediate prorated first charge for the
remaining portion of the current billing period.
The billing anchor is still preserved, so the first full recurring charge is collected on
billing_cycle_anchor_at.
When proration_behavior: :none, Edge does not create an immediate prorated charge. The first
charge is delayed until the billing anchor and is billed as a full cycle.
{:ok, payment_subscription, [], client} =
EPTSDK.PaymentSubscription.create(client,
attributes: %{
amount_cents: 15_000,
amount_currency: :USD,
billing_period: :one_month,
billing_cycle_anchor_at: ~U[2030-02-01 00:00:00Z],
proration_behavior: :create_prorations
}
)
{:ok, confirmed_subscription, [], client} =
EPTSDK.PaymentSubscription.confirm(client, payment_subscription)
Installation
If available in Hex, the package can be installed
by adding ept_sdk to your list of dependencies in mix.exs:
def deps do
[
{:ept_sdk, "~> 10.0"}
]
end
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/ept_sdk.