{"id":31589422,"url":"https://github.com/maseranw/payfast-subscribe-client","last_synced_at":"2026-01-20T16:56:16.801Z","repository":{"id":303058219,"uuid":"1014272962","full_name":"maseranw/payfast-subscribe-client","owner":"maseranw","description":"TypeScript SDK for submitting PayFast subscription payments. Works with @ngelekanyo/payfast-subscribe","archived":false,"fork":false,"pushed_at":"2025-07-06T11:39:07.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-06T02:55:17.790Z","etag":null,"topics":["payfast","payments","sdk"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@ngelekanyo/payfast-subscribe-client","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maseranw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-07-05T11:42:05.000Z","updated_at":"2025-07-06T11:39:10.000Z","dependencies_parsed_at":"2025-07-05T12:50:56.583Z","dependency_job_id":null,"html_url":"https://github.com/maseranw/payfast-subscribe-client","commit_stats":null,"previous_names":["maseranw/payfast-subscribe-client"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/maseranw/payfast-subscribe-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maseranw%2Fpayfast-subscribe-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maseranw%2Fpayfast-subscribe-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maseranw%2Fpayfast-subscribe-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maseranw%2Fpayfast-subscribe-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maseranw","download_url":"https://codeload.github.com/maseranw/payfast-subscribe-client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maseranw%2Fpayfast-subscribe-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279179180,"owners_count":26120377,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-16T02:00:06.019Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["payfast","payments","sdk"],"created_at":"2025-10-06T02:52:42.485Z","updated_at":"2025-10-16T10:32:38.003Z","avatar_url":"https://github.com/maseranw.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @ngelekanyo/payfast-subscribe-client\n\nA lightweight TypeScript SDK for initiating and submitting PayFast subscription payments from the browser.\n\n🔗 **Designed to work with [@ngelekanyo/payfast-subscribe](https://www.npmjs.com/package/@ngelekanyo/payfast-subscribe)** — a backend package for handling PayFast signatures, subscriptions, and ITN.\n\n---\n\n## ✨ Features\n\n- Initiate subscription or once-off payments\n- Submit payment forms to PayFast securely\n- Pause, unpause, cancel, and fetch subscriptions\n- Written in TypeScript, works in all frontend frameworks\n\n---\n\n## 📦 Installation\n\n```bash\nnpm install @ngelekanyo/payfast-subscribe-client\n```\n\n---\n\n## 🧩 Prerequisites\n\nThis package **requires a backend** using `@ngelekanyo/payfast-subscribe` to:\n- Sign and prepare payment data\n- Handle PayFast's ITN (Instant Transaction Notifications)\n- Manage subscriptions securely\n\n---\n\n## 🚀 Usage\n\n```ts\nimport {\n  initPayFastClient,\n  PayFastService,\n  PaymentData\n} from \"@ngelekanyo/payfast-subscribe-client\";\n\n// 1. Set your backend API base URL\ninitPayFastClient(\"https://your-backend.com\");\n\n// 2. Prepare payment data\nconst paymentData: PaymentData = {\n  amount: \"99.00\",\n  item_name: \"Pro Plan\",\n  item_description: \"Monthly subscription to Pro Plan\",\n  name_first: \"John\",\n  name_last: \"Doe\",\n  email_address: \"you@example.com\",\n  m_payment_id: \"uuid-123\",\n  subscription_type: \"1\",\n  billing_date: \"2025-07-05\",\n  recurring_amount: \"99.00\",\n  frequency: \"3\",\n  cycles: \"0\",\n  subscription_notify_email: \"you@example.com\",\n  subscription_notify_buyer: \"1\"\n};\n\nconst payfast = new PayFastService();\n\n// 3. Initiate payment via backend\nconst response = await payfast.initiatePayment(paymentData);\n\n// 4. Submit to PayFast\npayfast.submitPayment(response.paymentData, response.payfastUrl);\n```\n\n```ts\n\n const handlePause = async (token: string) =\u003e {\n    setLoading(true);\n    setError(null);\n    try {\n      const payfast = new PayFastService();\n      const response: PayFastActionResponse = await payfast.pauseSubscription(\n        token\n      );\n\n      const success =\n        response?.data?.code === 200 \u0026\u0026 response?.data?.status === \"success\";\n      if (!success) {\n        throw new Error(response?.data?.data?.message || \"Pause failed\");\n      }\n\n      await fetchSubscriptions();\n    } catch (err: any) {\n      setError(err.message || \"Failed to pause subscription\");\n    } finally {\n      setLoading(false);\n    }\n  };\n\n```\n---\n\n## 🔧 Available Methods\n\n| Method | Description |\n|--------|-------------|\n| `initPayFastClient(url)` | Set the backend base URL |\n| `initiatePayment(data)` | Call backend to prepare PayFast form |\n| `submitPayment(data, url)` | Submit a form to PayFast |\n| `pauseSubscription(token)` | Pause a subscription |\n| `unpauseSubscription(token)` | Resume a paused subscription |\n| `cancelSubscription(token, subscriptionId)` | Cancel a subscription |\n| `cancelSubscription(token)` | Cancel a subscription |\n| `fetchSubscription(token)` | Retrieve PayFast subscription details |\n\n---\n\n## ⚠️ Pause/Unpause Disclaimer\n\n\u003e **Important Notice:**  \n\u003e The `pause` and `unpause` subscription features provided by this package rely on PayFast's native subscription behavior. Please review the following carefully before implementing:\n\n- Pausing a subscription **does not cancel it** — it only delays future billing by the number of paused cycles (e.g. `cycles: 1` = 1 billing interval).\n- The **subscription end date is automatically extended** by PayFast for each paused cycle.\n- **Unpausing early** (before the pause period ends) will **not adjust the next billing date** — billing still resumes after the full pause duration.\n- ⚠️ This may result in a user receiving more than a full billing cycle of access without being charged, unless you **enforce access control** on your side.\n- This package does **not automatically manage user access** during pause periods. You must implement that logic in your backend or authorization layer.\n\n📚 For accurate and up-to-date details on PayFast's pause/unpause behavior, refer to the official PayFast documentation:\n\n👉 [PayFast Developer Docs](https://developers.payfast.co.za/docs)\n\n\n## 📚 Backend Setup\n\nUse [@ngelekanyo/payfast-subscribe](https://www.npmjs.com/package/@ngelekanyo/payfast-subscribe) in your Node.js/Express backend to:\n\n- Handle `/api/payfast/initiate`\n- Handle `/api/payfast/notify` (ITN callback)\n- Handle `/api/payfast/cancel/:token`\n- Handle `/api/payfast/cancel/:token/:subscriptionId`\n- (And optionally) pause/unpause/fetch routes\n\n🔒 Your backend should manage signing, verifying, and securing transactions.\n\n---\n\n## 👥 Maintainers\n\n- [@ngelekanyo](https://github.com/maseranw) (author \u0026 maintainer)\n\n## 🤝 Contributing\n\nContributions, suggestions, and issues welcome!  \nPlease open an issue or submit a pull request.\n\n## 📄 License\n\nThis project is licensed under the MIT License.  \nSee the [LICENSE](./LICENSE) file for details.\n\nMIT — © 2025 Ngelekanyo Masera\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaseranw%2Fpayfast-subscribe-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaseranw%2Fpayfast-subscribe-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaseranw%2Fpayfast-subscribe-client/lists"}