Example Walkthrough
The following is a multi-part walkthrough demonstrating how the Payment Link API endpoints and iframe work together in a typical workflow.
Before running the included code snippets, you may need to install the required imports if you do not already have them installed. You will also need to set any .env variables specified in the walkthrough.
The following code can be saved as a .js file and called via CLI to run the merchant set-up walkthrough using the command:
node ./src/pl_merchant_setup_walkthrough.js PUT_UNIQUE_REFERENCE_HERE
Example Merchant Setup Walkthrough Source File
Or you may use this code in conjunction with the other files below in a demo project for your convenience.
DEMO PAYLINK PROJECT
1. In the CLI, navigate to the location where you want to start your node.js application.
2. Create a new folder for your project.
3. Navigate into the folder you created.
4. Create a default package.json
file.
5. Save a copy of the connectfi_payment_link_example.tgz file in the root folder of the project directory.
connectfi_payment_link_example-1.0.0.tgz
6. Install the connectfi_payment_link_example.tgz file by using the following CLI command in your project directory.
7. Create a new file in your project directory with the following code.
// paylinkGettingStarted/your_file_name.js
const { startServer } = require('connectfi_payment_link_example');
8. Set CONNECTFI_CLIENTID, CONNECTFI_PASSWORD, and CONNECTFI_BASE_URL in a .env file in the root folder of your project.
(Speak to a support representative to be issued client credentials and URL after receiving access to the sandbox.)
9. Start the example walkthrough by using the following CLI command in your project directory.
10. This will create a server that is listening on port 8000. Go to http://localhost:8000/merchantSetupExample in the browser and follow the instructions to complete the walkthrough.
11. Enter a UNIQUE_MERCHANT_REFERENCE in order to quickly run the pl_merchant_setup_walkthrough and generate a cFiMercantId.
12. Next, go to http://localhost:8000/getMerchantToken in the browser and enter the value of the cFiMerchantId that you generated in order to call pl_merchant_get_token (makes an authorized POST request to the /payment-link/merchant/get-token API) and get a merchant token.
13. Once you have a fresh merchant token, you may visit the pre-prepared iframe integration sandbox at https://connectfi-payment-link-sandbox.paygears.net/ and enter the merchant token to view the payment link iframe, which will give you access to the /public/merchant functionality for testing.