m_payment_paypal_api

Create, capture and synchronize PayPal Orders and verify webhook events.

This module exposes trusted Erlang APIs and has no template model paths. create(PaymentNr, Context) creates an order for an existing local payment, returning {ok, #payment_psp_handler{}} or an error. Recurring creation is unsupported.

For example, m_payment_paypal_api:fetch_order(OrderId, Context) returns {ok, OrderMap} or {error, Reason}. capture_order/2 captures an approved order; sync_order_status/2 refreshes its local status. ping(Context) returns ok if configured credentials can obtain an OAuth token, or {error, Reason}.

Credentials and the live/sandbox selection come from mod_payment_paypal settings. Webhook signature verification uses webhook_id and PayPal's verification API. webhook_event/2 processes already verified events; callers must not send unverified request bodies directly to it. Direct calls do not enforce administrative ACLs.