StripePost v0.5.1 StripePost.Client View Source
Access service functionality through Elixir functions, wrapping the underlying HTTP API calls.
This is where you will want to write your custom code to access your 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
Create a customer with the following body configurations
Retrieve a customer by his/her stripe ID
List all customer, if you don't provide a limit we will fetch them all
Link to this section Functions
capture(charge_id, body \\ %{}, opts \\ nil) 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",
%{amount: 10000,
application_fee: 100,
destination: 90210}
)
Please visit https://stripe.com/docs/api#capture_charge for more information
The configurations are optional, and can be (preferrably) configured as elixir opts, 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"
}
charge(body, opts \\ nil) 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.
You also now also authorize (without charging) an account by setting the
capture field to false. For more details auth and capture
StripePost.charge(
%{amount: 10000,
currency: "cad",
description: "3 wozzle",
source: "pk_abc_123"
capture: false}
)
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"
}
create_customer(body, opts \\ nil) View Source
Create a customer with the following body configurations
body = %{description: "customer xxx", source: "pk_abc_123"}
get_customer(id, opts \\ nil) View Source
Retrieve a customer by his/her stripe ID
list_customers(query_params \\ %{}, opts \\ []) View Source
List all customer, if you don't provide a limit we will fetch them all
query_params = %{limit: 100, starting_after: "obj_pk_1234"}