{"id":36668290,"url":"https://github.com/a11rew/medusa-payment-paystack","last_synced_at":"2026-01-12T10:37:32.888Z","repository":{"id":61287764,"uuid":"549833272","full_name":"a11rew/medusa-payment-paystack","owner":"a11rew","description":"Paystack payment processor for Medusa","archived":false,"fork":false,"pushed_at":"2025-12-01T02:43:17.000Z","size":14177,"stargazers_count":92,"open_issues_count":6,"forks_count":26,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-12-02T18:51:13.586Z","etag":null,"topics":["medusa-plugin","medusa-plugin-payment","paystack"],"latest_commit_sha":null,"homepage":"","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/a11rew.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":"2022-10-11T20:09:57.000Z","updated_at":"2025-11-30T13:46:13.000Z","dependencies_parsed_at":"2024-01-01T03:37:44.781Z","dependency_job_id":"43adba85-f325-4028-934a-1c900f46258a","html_url":"https://github.com/a11rew/medusa-payment-paystack","commit_stats":{"total_commits":74,"total_committers":3,"mean_commits":"24.666666666666668","dds":0.3648648648648649,"last_synced_commit":"b898e282f5d065f3f3fb58103b31a7caf81dba7f"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/a11rew/medusa-payment-paystack","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a11rew%2Fmedusa-payment-paystack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a11rew%2Fmedusa-payment-paystack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a11rew%2Fmedusa-payment-paystack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a11rew%2Fmedusa-payment-paystack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/a11rew","download_url":"https://codeload.github.com/a11rew/medusa-payment-paystack/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a11rew%2Fmedusa-payment-paystack/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28338733,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T06:09:07.588Z","status":"ssl_error","status_checked_at":"2026-01-12T06:05:18.301Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["medusa-plugin","medusa-plugin-payment","paystack"],"created_at":"2026-01-12T10:37:32.789Z","updated_at":"2026-01-12T10:37:32.868Z","avatar_url":"https://github.com/a11rew.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Medusa Paystack Plugin](https://user-images.githubusercontent.com/46872764/197322473-fddbc659-d81e-4f19-b36c-d9f553433c8f.png)\n\n# About\n\n`medusa-payment-paystack` is a [Medusa](https://medusajs.com) plugin that adds [Paystack](https://paystack.com) as a payment provider to Medusa ecommerce stores.\n\n![GIF Demoing Paying with Paystack](https://user-images.githubusercontent.com/87580113/197406110-ff68bd20-60a1-4842-85c1-1a6ef46dd498.gif)\n\n# Setup\n\n## Prerequisites\n\n- [Paystack account](https://dashboard.paystack.com/#/signup)\n- [Paystack account's secret key](https://support.paystack.com/hc/en-us/articles/360009881600-Paystack-Test-Keys-Live-Keys-and-Webhooks)\n- Medusa server\n\n## Medusa Server\n\nIf you don’t have a Medusa server installed yet, you must follow the [quickstart guide](https://docs.medusajs.com/learn) first.\n\n### Install the Paystack Plugin\n\nIn the root of your Medusa server (backend), run the following command to install the Paystack plugin:\n\n```bash\nyarn add medusa-payment-paystack\n```\n\n### Configure the Paystack Plugin\n\nNext, you need to enable the plugin in your Medusa server.\n\nIn `medusa-config.ts` add the following to the `plugins` array:\n\n```ts\nmodule.exports = defineConfig({\n  projectConfig: {\n    databaseUrl: process.env.DATABASE_URL,\n    // ... other config\n  },\n  modules: [\n    // other modules\n    {\n      resolve: \"@medusajs/medusa/payment\",\n      options: {\n        providers: [\n          // other payment providers like stripe, paypal etc\n          {\n            resolve: \"medusa-payment-paystack\",\n            options: {\n              secret_key: \u003cPAYSTACK_SECRET_KEY\u003e,\n            } satisfies import(\"medusa-payment-paystack\").PluginOptions,\n          },\n        ],\n      },\n    },\n  ],\n});\n```\n\nThe full list of configuration options you can pass to the plugin can be found in [Config](#configuration)\n\n### Setup Webhooks\n\nTo ensure that Medusa is notified of successful payments, you need to set up webhooks in your Paystack dashboard. If you're installing this plugin for production use, this is a required step.\n\nGo to your [Paystack dashboard](https://dashboard.paystack.com/#/settings/developer) and navigate to the \"API Keys \u0026 Webhooks\" section.\n\nSet the Webhook URL to `\u003cyour-medusa-backend-url\u003e/hooks/payment/paystack`. Eg. `https://your-medusa-backend.com/hooks/payment/paystack`.\n\n## Admin Setup\n\nThis step is required for you to be able to use Paystack as a payment provider in your storefront.\n\n### Add Paystack to Regions\n\nRefer to [this documentation in the user guide](https://docs.medusajs.com/v1/user-guide/regions/providers/#manage-payment-providers) to learn how to add a payment provider like Paystack to a region.\n\n## Storefront Setup\n\nFollow Medusa's [Storefront Development Checkout Flow](https://docs.medusajs.com/resources/storefront-development/checkout/payment) guide using `pp_paystack` as the `provider_id` to add Paystack to your checkout flow.\n\n### Email in `initiatePaymentSession` data\n\nPaystack requires the customer's email address to create a transaction.\n\nYou **need** to pass the customer's email address in the `initiatePaymentSession` context to create a transaction.\n\nIf your storefront does not collect customer email addresses, you can provide a dummy email but be aware all transactions on your Paystack dashboard will be associated with that email address.\n\n```ts\nawait initiatePaymentSession(cart, {\n  provider_id: selectedPaymentMethod,\n  data: {\n    email: cart.email,\n  },\n});\n```\n\n### Completing the Payment Flow\n\n`medusa-payment-paystack` returns an access code and authorization URL that you should use to complete the Paystack payment flow on the storefront.\n\nUsing the returned access code and authorization URL allows the plugin to confirm the status of the transaction on your backend, and then relay that information to Medusa.\n\n`medusa-payment-paystack` inserts the access code (`paystackTxAccessCode`) and authorization URL (`paystackTxAuthorizationUrl`) into the [`PaymentSession`](https://docs.medusajs.com/advanced/backend/payment/overview/#payment-session)'s data.\n\nYou can use the access code to resume the payment flow, or the authorization URL to redirect the customer to Paystack's hosted payment page.\n\n#### Using Access Code\n\nExtract the access code from the payment session's data:\n\n```js\nconst { paystackTxAccessCode } = paymentSession.data;\n```\n\nProvide this access code to the `resumeTransaction` method from Paystack's [InlineJS](https://paystack.com/docs/guides/migrating-from-inlinejs-v1-to-v2/) library. This example uses the [Inline-TS](https://www.npmjs.com/package/paystack-inline-ts) wrapper around the InlineJS library.\n\n```tsx\nimport Paystack from \"@paystack/inline-ts\";\n\nconst PaystackPaymentButton = ({\n  session,\n  notReady,\n}: {\n  session: HttpTypes.StorePaymentSession | undefined;\n  notReady: boolean;\n}) =\u003e {\n  const paystackRef = useRef\u003cPaystack | null\u003e(null);\n\n  useEffect(() =\u003e {\n    if (!paystackRef.current) {\n      // Initialize Paystack\n      paystackRef.current = new Paystack();\n    }\n  }, []);\n\n  // If the session is not ready, we don't want to render the button\n  if (notReady || !session || !paystackRef.current) return null;\n\n  // Get the accessCode added to the session data by the Paystack plugin\n  const accessCode = session.data.paystackTxAccessCode;\n  if (!accessCode) throw new Error(\"Transaction access code is not defined\");\n\n  return (\n    \u003cbutton\n      onClick={() =\u003e {\n        const paystack = paystackRef.current!;\n\n        paystack.resumeTransaction(accessCode, {\n          async onSuccess() {\n            // Call Medusa checkout complete here\n            await placeOrder();\n          },\n          onError(error: unknown) {\n            // Handle error\n          },\n        });\n      }}\n    \u003e\n      Pay with Paystack\n    \u003c/button\u003e\n  );\n};\n```\n\n#### Using Authorization URL\n\nAs a prerequisite, you must have configured a \"Callback URL\" in your Paystack dashboard. Follow [this guide](https://support.paystack.com/en/articles/2129538) to set it up.\n\nThe callback URL can be a custom route on your Medusa backend, it can be a page in your storefront or a view in your mobile application. That route just needs to call the Medusa [Complete Cart](https://docs.medusajs.com/resources/storefront-development/checkout/complete-cart) method.\n\nExtract the authorization URL from the payment session's data:\n\n```ts\nconst { paystackTxAuthorizationUrl } = session.data;\n```\n\nRedirect the customer to the authorization URL to complete the payment.\n\n```ts\n// Redirect the customer to Paystack's hosted payment page\nwindow.open(paystackTxAuthorizationUrl, \"_self\");\n```\n\nOnce the payment is successful, the customer will be redirected back to the callback URL. This page can then call the Medusa [Complete Cart](https://docs.medusajs.com/resources/storefront-development/checkout/complete-cart) method to complete the checkout flow and show a success message to the customer.\n\n### Verify Payment\n\nCall the Medusa [Complete Cart](https://docs.medusajs.com/resources/storefront-development/checkout/complete-cart) method in the payment completion callback of your chosen flow as mentioned in [Completing the Payment Flow](#completing-the-payment-flow) above.\n\n`medusa-payment-paystack` will verify the transaction with Paystack and mark the cart as paid for in Medusa.\n\nEven if the \"Complete Cart\" method is not called for any reason, with webhooks set up correctly, the transaction will still be marked as paid for in Medusa when the user pays for it.\n\n## Refund Payments\n\nYou can refund captured payments made with Paystack from the Admin dashboard.\n\n`medusa-payment-paystack` handles refunding the given amount using Paystack and marks the order in Medusa as refunded.\n\nPartial refunds are also supported.\n\n# Configuration\n\n| Name            | Type      | Default | Description                                                                                                                                                                                            |\n| --------------- | --------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| secret_key      | `string`  | -       | Your Paystack secret key. Should be in the format sk_test-... or sk_live-... Obtainable from the Paystack dashboard - Settings -\u003e API Keys \u0026 Webhooks.                                                 |\n| disable_retries | `boolean` | `false` | Disable retries on network errors and 5xx errors on idempotent requests to Paystack. Generally, you should not disable retries, these errors are usually temporary but it can be useful for debugging. |\n| debug           | `boolean` | `false` | Enable debug mode for the plugin. If true, logs helpful debug information to the console. Logs are prefixed with \"PS_P_Debug\".                                                                         |\n\n# Examples\n\nThe [`examples`](https://github.com/a11rew/medusa-payment-paystack/blob/main/examples) directory contains an example Medusa installation with the Paystack plugin installed and configured. The backend can be found in the [`backend`](https://github.com/a11rew/medusa-payment-paystack/blob/main/examples/backend) directory and the storefront can be found in the [`storefront`](https://github.com/a11rew/medusa-payment-paystack/blob/main/examples/storefront) directory.\n\nThe storefront is built with Next.js and uses the inline-js Paystack library to complete the payment flow.\n\nThe examples are the default Medusa V2 storefront and backend starters. View all the changes made to the examples to add Paystack support in this commit: [feat: add paystack payment support](https://github.com/a11rew/medusa-payment-paystack/commit/3782286cb5693df1511d24bdaa2440efe6e747c5).\n\n# V1\n\nThe [`v1` branch](https://github.com/a11rew/medusa-payment-paystack/tree/v1) contains the original version of this plugin with support for Medusa V1. The example storefront and backend for the v1 version can also be found in the [examples directory](https://github.com/a11rew/medusa-payment-paystack/tree/v1/examples) of the `v1` branch.\n\nIt can be installed from npm using the `1` version tag:\n\n```bash\nyarn add medusa-payment-paystack@1\n```\n\nThe `v1` branch is no longer maintained and is only kept for reference.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa11rew%2Fmedusa-payment-paystack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fa11rew%2Fmedusa-payment-paystack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa11rew%2Fmedusa-payment-paystack/lists"}