Client for interacting with Xendit Payment Gateway API. Primarily uses the Payment Link API for fine payments.
Documentation: https://developers.xendit.co/api-reference/
Summary
Functions
Creates a payment link for a fine.
Retrieves a payment link by ID.
Gets payment link by external_id.
Parses a webhook payload and returns the event data.
Validates a Xendit webhook callback signature.
Functions
Creates a payment link for a fine.
Options
:external_id- Unique ID for the payment (defaults to "fine{fine_id}{timestamp}"):amount- Amount in IDR (required):description- Payment description:customer- Map with customer details (:given_names, :email, :mobile_number):success_redirect_url- URL to redirect after successful payment:failure_redirect_url- URL to redirect after failed payment:items- List of line items (optional)
Examples
iex> Client.Xendit.create_payment_link(
amount: 50000,
description: "Library Fine Payment",
customer: %{
given_names: "John Doe",
email: "john@example.com"
}
)
{:ok, %{
"id" => "pl-xxx",
"external_id" => "fine_123_1234567890",
"invoice_url" => "https://checkout.xendit.co/web/pl-xxx",
"amount" => 50000,
"status" => "PENDING"
}}
Retrieves a payment link by ID.
Examples
iex> Client.Xendit.get_payment_link("pl-xxx")
{:ok, %{
"id" => "pl-xxx",
"status" => "PENDING",
"amount" => 50000
}}
Gets payment link by external_id.
Examples
iex> Client.Xendit.get_payment_link_by_external_id("fine_123_1234567890")
{:ok, %{
"id" => "pl-xxx",
"external_id" => "fine_123_1234567890",
"status" => "PAID"
}}
Parses a webhook payload and returns the event data.
Examples
iex> Client.Xendit.parse_webhook_payload(%{
"id" => "pl-xxx",
"external_id" => "fine_123_1234567890",
"status" => "PAID",
"paid_amount" => 50000
})
{:ok, %{
payment_link_id: "pl-xxx",
external_id: "fine_123_1234567890",
status: "PAID",
paid_amount: 50000
}}
Validates a Xendit webhook callback signature.
Examples
iex> Client.Xendit.validate_webhook_signature(webhook_token, request_body)
true