Repository navigation
Store a referral code and send it with checkout - #364
Open
MehdiMamas wants to merge 3 commits into
Open
MehdiMamas wants to merge 3 commits into
MehdiMamas wants to merge 3 commits into
Conversation
Lets an extension keep a first-touch referral code and pass it on the existing payment, trial, login, and new-key requests. Attribution stays on the ExtensionPay server. Co-authored-by: Cursor <cursoragent@cursor.com>
Explains using one promotion code per referrer, plus setReferral, until ExtensionPay attributes the ref parameter. Co-authored-by: Cursor <cursoragent@cursor.com>
The payment URLs already use ref, so the API-key body uses the same name instead of a second referral field. Co-authored-by: Cursor <cursoragent@cursor.com>
MehdiMamas
marked this pull request as ready for review
September 28, 2026 19:28
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
extpay.setReferral(code)andextpay.getReferral()so an extension can keep a first-touch referral code in extension storage.refon the existing choose-plan, trial, and login URLs, and asrefon the existingPOST /api/new-keybody. The public links already use?ref=, so the body uses the same name. No new requests.This pull request is only the ExtPay.js client. The extensionpay.com server is not in this repository, so the items below need to be built there.
Needs to be added on extensionpay.com
The owner configures one program per extension. The referrer reward is one of: a percentage (first payment, N months, or every renewal), a fixed cash amount, or free time (for example one free month). The referred user can optionally get a percentage or fixed discount (first payment, N months, or forever).
Accept the code this client already sends
reffromPOST /api/new-keyand from the choose-plan, trial, and login query strings.user.referral({code, capturedAt}). The client already copies unknown user fields through.Configuration
https://extensionpay.com/extension/<id>?ref=<code>that land on the store listing.discountswhen creating the Checkout session, so the buyer does not have to type the code.Attribution and rewards
metadataorclient_reference_id) and onto each renewal from the webhook.Dashboard, referrers, and abuse checks
Stripe promotion codes already cover a typed discount and redemption limits. That workaround is described in
docs/referral_guide.md. It does not replace the server work above.Test plan
setReferral('youtuber123')thengetReferral()returns that code and acapturedAtdatesetReferral('other')keepsyoutuber123;{overwrite: true}replaces itsetReferral('bad code')throwsopenPaymentPage,openTrialPage, andopenLoginPageappend&ref=new-keyrequest body includesrefand does not includereferralrefparameter