StripePost v0.5.1 StripePost View Source
A minimal library for posting messages to the Stripe API.
Link to this section Summary
Functions
Capture the payment of an existing, uncaptured, charge. This is the second half of the two-step payment flow, where first you created a charge with the capture option set to false
Charge an account with the following body configurations
Retrieve (and create if missing) the customer by the provided (and globally unique aka "public id") name
Retrieve all customers stored within this process
Sync customer information directly from Stripe into Worder. This will lookup all customers in Stripe for easy access within this library
Link to this section Functions
capture(charge_id) View Source
Capture the payment of an existing, uncaptured, charge. This is the second half of the two-step payment flow, where first you created a charge with the capture option set to false.
For example, if you charged the following, but did NOT capture
StripePost.charge(
%{amount: 10000,
currency: "cad",
description: "3 wozzle",
source: "pk_abc_123"
capture: false}
)
The results will contain a charge ID, and captured should be false, for example
{"id": "ch_abc123",
"paid": true,
"status": "succeeded",
"captured": false}
When you are ready to capture the payment, use that charge "id", you can also provide additional fields, for example:
StripePost.capture("ch_abc123")
charge(body) View Source
Charge an account with the following body configurations
StripePost.charge(
%{amount: 10000,
currency: "cad",
description: "3 wozzle",
source: "pk_abc_123"}
)
Where the source is the payment token received from Stripe most likely
in your client javascriopt.
The configurations are optional, and can be (preferrably) configured as elixir configs, like:
config :stripe_post,
secret_key: "sk_test_abc123",
public_key: "pk_test_def456",
content_type: "application/x-www-form-urlencoded"
But, if you must, then you can specify it directly like
opts = %{
secret_key: "sk_test_abc123",
content_type: "application/x-www-form-urlencoded"
}
customer(name) View Source
Retrieve (and create if missing) the customer by the provided (and globally unique aka "public id") name.
StripePost.customer("c12ab54612ad")
customers() View Source
Retrieve all customers stored within this process
StripePost.customers
On first call, this will return an empty map.
%{}
If you have customers, then you need to explicitly call reload
StripePost.reload
Afterwhich you will now receive customers such as
%{"abc123" => "cus_AunbC99p7tNQj",
"abc456" => "cus_AuncZ98ePY18"}
Where the key (e.g. "abc123") is your public id for the customer
(stored as the description), and the value (e.g. "cus_AunbC99p7tNQj")
is the Stripe ID.
reload() View Source
Sync customer information directly from Stripe into Worder. This will lookup all customers in Stripe for easy access within this library.
StripePost.reload
This will reload all customers from the Stripe API in the background so the response will be
:ok