How the Checkout Component flow works
mainThe Checkout Component follows a specific lifecycle involving the merchant's page, the PayPal SDK, and a popup window:
- Merchant Setup: The merchant adds the PayPal SDK script (e.g.,
https://www.paypal.com/sdk/js?client-id=xyz) to their page. - Button Rendering: The merchant renders smart-payment-buttons using
paypal.Buttons({ ...props }).render('#container'). - Iframe Injection: The SDK renders an iframe containing the PayPal buttons.
- Triggering Checkout: When a buyer clicks a button, the SDK calls
paypal.Checkout({ ...props }).render('body')to load the checkout flow in a popup. - Token Retrieval: The checkout app retrieves the order ID or EC token via
window.xprops.payment(). - Completion: Once the buyer completes the flow, the child window notifies the merchant via
window.xprops.onAuthorize(). - Capture: The merchant then calls PayPal to capture the payment.