I tried to append the PayPal code directly into your canvas, but the canvas update failed due to a regex replacement error on my side. No changes were made to your document. Below is everything you need—copy/paste into your files exactly as indicated. If you want, I can try inserting these into your canvas again next.
[1] Front-End (focus-library-offer.html)
Place this below the Pricing section (before the FAQ or just before ). It renders a PayPal “Subscribe” button that creates an annual subscription and then redirects to a “pending” page while the webhook activates access.
[Replace]
-
PAYPAL_CLIENT_IDwith your live or sandbox client id -
PAYPAL_PLAN_IDwith your annual plan id (starts withP-)
[2] Classic ASP Webhook Endpoint
Create /api/paypal/paypal-webhook.asp. This verifies PayPal's signature and hands the event JSON to SQL for processing.
[3] Optional “onApprove” Logger
Create /api/paypal/subscription-approved.asp (no auth needed; logs client-side approval so you can reconcile if a webhook is delayed).
[4] SQL — Event Log + Membership Activation
Create /db/sql/membership.sql and run it on your SQL Server (2016+ for JSON functions).
[Set 42 to the actual access_id used by your CMS for Focus Library.]
[5] PayPal Dashboard Setup
[Steps]
-
Create Product: “Life Story Music Focus Library” (Digital, service).
-
Create Plan: Annual billing, USD 100.00. Collect the Plan ID (e.g.,
P-XXXX). -
Webhooks: Add a webhook for
https://YOURDOMAIN.com/api/paypal/paypal-webhook.asp.-
Events:
-
BILLING.SUBSCRIPTION.ACTIVATED -
BILLING.SUBSCRIPTION.CANCELLED -
BILLING.SUBSCRIPTION.EXPIRED -
BILLING.SUBSCRIPTION.SUSPENDED -
PAYMENT.SALE.COMPLETEDandPAYMENT.CAPTURE.COMPLETED
-
-
Grab the Webhook ID and put it in
WEBHOOK_ID.
-
-
Credentials: Put your Client ID and Secret in the ASP constants (or a config include).
[Sandbox vs Live]
-
Sandbox: change
API_BASEtohttps://api-m.sandbox.paypal.comand use sandbox client id/secret/plan. -
Live: switch back to
api-m.paypal.comand live credentials.
[6] Routing/UX
[Pages]
-
/member/pending: simple page saying “Your membership is being activated… check your email in a minute.” -
/checkout/error: display a generic failure + support link. -
On success: your app will show the Focus Library as unlocked (because
user_accessrow exists).
[7] Test Plan (Sandbox)
[Checklist]
-
Replace
PAYPAL_CLIENT_IDandPAYPAL_PLAN_IDwith Sandbox values. -
Enable the webhook to the Sandbox URL.
-
Click the PayPal button → use a Sandbox Buyer → approve.
-
Confirm:
-
paypal_webhook_eventsreceivesBILLING.SUBSCRIPTION.ACTIVATED(and a payment event). -
user_membershipshas anactiverow with 365-day window. -
user_accesshas theaccess_idrow.
-
-
Cancel the subscription from the Sandbox Buyer's PayPal → webhook sets membership
cancelled. -
Switch to Live after validation.
[8] Notes for Your CMS
-
If your membership/access lives in different tables (e.g.,
content_user_access,memberships, etc.), map the MERGE blocks accordingly. -
If you prefer immediate revocation on cancel, uncomment the
DELETE FROM user_accesslines. -
If you want to base membership length on PayPal's
billing_info.next_billing_time, you can pull it from$.resourceand setend_ataccordingly.
If you want, I can take another pass at inserting these into the canvas files exactly where they belong (now that you've seen the snippets), or generate Classic ASP includes (/api/paypal/config.inc.asp) to centralize your credentials and plan IDs.
