PayPal integration into purchases-js as payment gateway#815
Draft
PayPal integration into purchases-js as payment gateway#815
Conversation
Integrate PayPal as a new checkout provider following the same pattern as the existing Paddle integration. Uses a popup window approach for PayPal's approval flow, with backend operation status polling after the popup closes. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Attach rejection handlers before advancing fake timers so the async rejections from polling intervals are caught before vitest flags them as unhandled. Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Remove pypl_ API key prefix and separate PayPal routing
- Remove standalone PayPal UI components (paypal-purchases-ui.svelte)
- Remove PayPalCheckoutStartResponse; add paypal_gateway_params to
WebBillingCheckoutStartResponse instead
- Update CheckoutPreparePayPalGatewayParams to { is_sandbox } per
backend contract
- Simplify PayPalService to only handle popup + polling (remove
startCheckout, which is handled by PurchaseOperationHelper)
- Add PayPal button to existing payment-entry-page when
paypal_gateway_params is present in checkout/start response
- Wire paypal_gateway_params through purchases-ui → inner → page
- Expose getBackend() and currentOperationSessionId on
PurchaseOperationHelper for PayPal flow
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Defaults to null so stories and other consumers that don't need PayPal don't have to pass it. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Generated by 🚫 Danger |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
paypal_gateway_paramsincheckout/prepareandcheckout/startresponses — no separate API key prefixChanges
New files:
src/paypal/paypal-service.ts— Popup + polling logic for PayPal approval flowsrc/tests/paypal/paypal-service.test.ts— Unit tests for PayPalServiceModified files:
src/networking/responses/checkout-start-response.ts— AddedPayPalGatewayParamsandpaypal_gateway_paramsfield toWebBillingCheckoutStartResponsesrc/networking/responses/checkout-prepare-response.ts— UpdatedCheckoutPreparePayPalGatewayParamsfrom{ client_access_token }to{ is_sandbox }src/helpers/purchase-operation-helper.ts— ExposedgetBackend()andcurrentOperationSessionIdfor PayPal flowsrc/ui/purchases-ui.svelte— Extracts and passespaypal_gateway_paramsfrom checkout start responsesrc/ui/purchases-ui-inner.svelte— PassespaypalGatewayParamsthrough to payment entry pagesrc/ui/pages/payment-entry-page.svelte— Renders "Pay with PayPal" button whenpaypal_gateway_paramsis presentsrc/helpers/api-key-helper.ts— Removedpypl_API key prefix andisPayPalApiKey()src/main.ts— Removed separate PayPal routing andperformPayPalPurchase()Deleted files:
src/ui/paypal-purchases-ui.svelte— Standalone PayPal UI (replaced by integration into existing checkout)src/ui/paypal-purchases-ui-inner.svelte— Standalone PayPal inner UIBackend contract (from Khepri PR)
POST /checkout/startreturnspaypal_gateway_paramsas an optional field alongside existing Stripe fields:{ "operation_session_id": "...", "gateway_params": { ... }, "stripe_billing_params": { ... }, "paypal_gateway_params": { "order_id": "...", "approval_url": "https://www.paypal.com/checkoutnow?token=...", "is_sandbox": true } }POST /checkout/preparereturns:{ "stripe_gateway_params": { ... }, "paypal_gateway_params": { "is_sandbox": true } }Test plan
🤖 Generated with Claude Code