Enable your connector on https://www.twilio.com/console/voice/pay-connectors Enable PCI mode for your account on https://www.twilio.com/console/voice/settings Make a note of the unique name you created for your payment connector.
Make sure you have Node.js as well as npm
installed.
You will also need to have the Twilio CLI installed. as well as a couple of Twilio CLI Plugins.
twilio plugins:install @twilio-labs/plugin-serverless
twilio plugins:install @twilio-labs/plugin-flex@beta
Afterwards, install the dependencies by running npm install
:
cd flex-agent-assisted-payments-plugin
# If you use npm
npm install
cd aap-backend
#run npm install again in this subfolder to install function specific dependancies
npm install
Make a copy of the .env.example file, call it .env, and populated it with values from Twilio Console
ACCOUNT_SID=
AUTH_TOKEN=
TWILIO_API_SECRET=
TWILIO_API_KEY=
PAYMENT_CONNECTOR=Default
SYNC_SERVICE_SID=
Replace the name of your payment connector with the name you gave to it in the Twilio Console. You will need to create a new API Key/Secret using the Twilio Console. You will be able to find your Account SID, Auth Token, and Sync Service ID in the Twilio console.
twilio serverless:deploy
Wait a few moments, and your functions should be deployed to Twilio Serverless with a domain like:
aap-backend-XXXX-dev.twil.io
Make a note of this Domain. You will need it soon.
Return to the main plugin directory.
cd ..
Open file payConfig.json and replace the runtime domain with the URL from your Serverless Deployment. Make sure to add the https:// to the front.
Now is also the perfect time to customise the plugin with your specific requirements.
Once you are happy with your plugin, you have to bundle it in order to deploy it to Twilio Flex.
First, use twilio login
to create a profile for your deployment.
twilio profiles:list
will show you existing profiles.
Make sure you are switched to the correct project using twilio profiles:use <Name_Of_Profile>
before running your deployment.
Run the following command to start the bundling:
twilio flex:plugins:deploy
Follow the 'Next Steps' in the CLI in order to package this as part of a release within Flex. The command to release the plugin on its own will look something like:
twilio flex:plugins:release --plugin plugin-pay@0.0.1 --name "Autogenerated Release" --description "The description of this Flex Plugin Configuration"
Once this is done, you can make a call into Flex to test your configuration!