The orders is the element that let us to charge an amount to the clients.
We have two ways to proceed, it's called the intent and depending on what
you choose, it will let you charge the money instantly or hold the money
until the process, product or service will be released.
captureis the intent that charges the money immediately. The flow is:authorizeis the intent that holds the money and lets you capture the funds later. The flow is:- Create the order using
authorizeas the intent, seecreate/3. - Use the URL inside of the response for approving the payment.
- Create the authorization, see
authorize/1. - Capture funds using the authorization, see
Paypal.Payment.capture/1.
- Create the order using
If you are interested in the authorization, check Paypal.Payment module for
further information.
Official PayPal API Documentation: PayPal Orders API v2
Summary
Functions
Authorize payment for an order.
Capture payment for an order.
Create an order.
The kind of intents, for further information Paypal.Order.
Show order details by ID.
Statuses for the order. The order is following different states, we could illustrate it as a state diagram
Functions
@spec authorize(String.t()) :: {:ok, Paypal.Order.Authorized.t()} | {:error, Paypal.Common.Error.t() | term()}
Authorize payment for an order.
Official documentation: Authorize Payment for Order
@spec capture(String.t()) :: {:ok, Paypal.Order.Info.t()} | {:error, Paypal.Common.Error.t() | term()}
Capture payment for an order.
Official documentation: Capture Payment for Order
@spec create( :capture | :authorize, [Paypal.Order.PurchaseUnit.t() | map()], Paypal.Order.ExperienceContext.t() | map() ) :: {:ok, Paypal.Order.Info.t()} | {:error, Paypal.Common.Error.t() | term()}
Create an order.
Official documentation: Create Order
The kind of intents, for further information Paypal.Order.
@spec show(String.t()) :: {:ok, Paypal.Order.Info.t()} | {:error, Paypal.Common.Error.t() | term()}
Show order details by ID.
Official documentation: Show Order Details
@spec statuses() :: [ created: String.t(), saved: String.t(), approved: String.t(), voided: String.t(), completed: String.t(), payer_action_required: String.t() ]
Statuses for the order. The order is following different states, we could illustrate it as a state diagram:
stateDiagram-v2
[*] --> CREATED
CREATED --> PAYER_ACTION_REQUIRED
PAYER_ACTION_REQUIRED --> APPROVED
APPROVED --> SAVED
SAVED --> APPROVED
APPROVED --> VOIDED
APPROVED --> COMPLETED
VOIDED --> [*]
COMPLETED --> [*]As you can see, we start in CREATED state and we are moving until reach VOIDED or COMPLETED.