From cfe94fc0b5d96727b8563daa3bb297c453b524fd Mon Sep 17 00:00:00 2001 From: tolu-paystack Date: Thu, 30 Mar 2023 10:00:06 -0500 Subject: [PATCH] add server url --- .env.example | 3 ++- README.md | 3 ++- server.js | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index 326f4a3..e5f3fc0 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,4 @@ STATIC_DIR='./client' PAYSTACK_SECRET_KEY= -PORT='5000' \ No newline at end of file +PORT='5000' +SERVER_URL='http://localhost:5000' \ No newline at end of file diff --git a/README.md b/README.md index 70c4cbd..376d815 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,11 @@ git clone https://github.com/PaystackOSS/sample-subscriptions-app npm install ``` -3. Rename the `.env.example` file to `.env` and add your Paystack secret key. You can also change the default port from 5000 to a port of your choosing: +3. Rename the `.env.example` file to `.env` and add your Paystack secret key, and your server's URL including the port. This is necessary for the callback URL you'll be redirected to after completing a transaction. You can also change the default port from 5000 to a port of your choosing: ``` PAYSTACK_SECRET_KEY=sk_domain_xxxxxx +SERVER_URL=http://localhost:5000 ``` 4. Start the application diff --git a/server.js b/server.js index 839d8dc..7cba4b4 100644 --- a/server.js +++ b/server.js @@ -81,7 +81,7 @@ app.post('/initialize-transaction-with-plan', async (req, res) => { amount, plan, channels: ['card'], // limiting the checkout to show card, as it's the only channel that subscriptions are currently available through - callback_url: 'http://localhost:5000/account.html', + callback_url: `${process.env.SERVER_URL}/account.html`, }); if (initializeTransactionResponse.status === false) {