feat: add Paystack recurring payment plans (#310)#421
Closed
Ginaonuh wants to merge 1 commit into
Closed
Conversation
- paystack.ts: add createPlan(), subscribeToPlan(), cancelSubscription() - circle.service: call createPlan() on circle creation, store paystack_plan_code - circle.service: call subscribeToPlan() on join when plan + auth code present, store paystack_subscription_code on member row - schemas: add optional authorizationCode to joinCircleSchema - join routes (v1 + legacy): pass authorizationCode through to joinCircle() - webhook (v1 + legacy): handle subscription.charge_failed — look up member by subscription code and send SMS notification via notifySubscriptionChargeFailed() - sms.ts: add sendSubscriptionChargeFailedSms() - notification.service: add notifySubscriptionChargeFailed() - migration: add paystack_plan_code to circles, paystack_subscription_code to members Closes JosephOnuh#310
|
@Ginaonuh Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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
Resolves #310 — Add Paystack recurring payment plans for automated circle contributions.
Acceptance Criteria
createPlan()called increateCircle(), plan code stored incircles.paystack_plan_codesubscribeToPlan()called injoinCircle()whenauthorizationCodeprovided, code stored inmembers.paystack_subscription_codecycleFrequency)subscription.charge_failedwebhook event sends SMS vianotifySubscriptionChargeFailed()Changes
src/lib/paystack.ts— AddedcreatePlan(),subscribeToPlan(),cancelSubscription()src/server/services/circle.service.ts—createCircle()creates a Paystack plan (best-effort, non-blocking on failure);joinCircle()accepts optionalpaystackAuthCodeand subscribes active memberssrc/types/schemas.ts— Added optionalauthorizationCodetojoinCircleSchemasrc/app/api/v1/circles/[id]/join/route.ts+ legacy — PassauthorizationCodethrough tojoinCircle()src/app/api/v1/webhooks/paystack/route.ts+ legacy — Handlesubscription.charge_failed: look up member bypaystack_subscription_code, send SMSsrc/lib/sms.ts— AddedsendSubscriptionChargeFailedSms()src/server/services/notification.service.ts— AddednotifySubscriptionChargeFailed()migrations/1748700000000_add-paystack-recurring.ts— Addspaystack_plan_codetocircles,paystack_subscription_codetomembersNotes
authorization_code(from a prior transaction) and pass it in the join request body asauthorizationCodecancelSubscription()is exported for future use when a member leaves or a circle is cancelled