In this guide, you'll learn how to install and configure the Authorize.net payment provider for Medusa, prepare your Authorize.net account, set up the webhook and Google Pay, and switch from the plugin.
yarn add @gorgo/medusa-integration @gorgo/medusa-payment-authorizenetAdd the configurations of the Integration Module provider and of the Medusa Payment Module in your file of the Medusa Admin application:
medusa-config.ts1// ...2const AUTHORIZENET_INTEGRATION_ID = "authorizenet-1"34module.exports = defineConfig({5 // ...6 plugins: [7 // ...8 {9 resolve: "@gorgo/medusa-integration",10 options: {11 encryptionKey: process.env.INTEGRATION_ENCRYPTION_KEY,12 providers: [13 {14 resolve: "@gorgo/medusa-payment-authorizenet/providers/integration-authorizenet",15 id: AUTHORIZENET_INTEGRATION_ID,16 options: {},17 },18 ],19 },20 },21 {22 resolve: "@gorgo/medusa-payment-authorizenet",23 options: {},24 },25 ],26 modules: [27 // ...28 {29 resolve: "@medusajs/medusa/payment",30 options: {31 providers: [32 {33 resolve: "@gorgo/medusa-payment-authorizenet/providers/payment-authorizenet",34 id: "authorizenet",35 options: {36 id: AUTHORIZENET_INTEGRATION_ID37 }38 },39 ],40 },41 },42 ],43})
The payment provider registered this way gets the id , and its webhook route is .
Add environment variables with your secret :
.envINTEGRATION_ENCRYPTION_KEY=supersecret
The API Login ID, the Transaction Key and the other Authorize.net settings are not provider options. You enter them in Medusa Admin, as described in Manage Authorize.net Settings in Medusa Admin.
The plugin needs three values from the Authorize.net Merchant Interface, and a fourth for webhooks. Take them from the sandbox account while you test, and from the production account for real payments:
Keep the sandbox account in Live Mode. In Test Mode, Authorize.net keeps no transactions and returns for every transaction ID, so the plugin could not capture, refund or void them. Test connection in Medusa Admin fails while the account is in Test Mode.
An Authorize.net account takes payments in one currency, set when the account is created. Add the provider only to the regions that use it, as described in Add Payment Provider. Test connection shows the account's currencies.
To receive the payment notifications the plugin acts on, add a webhook for your store in Authorize.net:
Open the webhooks in the Authorize.net Merchant Interface of the account whose keys you use, or create the webhook with of the Webhooks API.
Set the URL in the following format:
Webhook URLhttps://{YOUR_MEDUSA_DOMAIN}/hooks/payment/authorizenet_authorizenet
Replace with your Medusa store domain.
Subscribe it to , and , and make it active.
Enter the account's Signature Key in the Signature Key field of the Authorize.net settings in Medusa Admin. Test connection then checks that an active webhook whose URL contains exists and sends the three events.
completes a payment that the Fraud Detection Suite held for review, is only written to the log, and records a capture made in the Merchant Interface. Authorize.net retries a failed delivery up to 10 times over several days and then makes the webhook inactive. Test connection reports an inactive webhook as missing. During development, run the backend behind a tunnel with a public HTTPS address, as the example project does with .
Google Pay appears in the express checkout row of the storefront once you switch it on in the Express checkout section of the Authorize.net settings. The plugin reads the Payment Gateway ID of your account from Authorize.net and passes it to Google Pay, so you don't enter it.
In the sandbox, the button runs in Google Pay's test environment. In production, Google Pay needs your merchant ID from the Google Pay & Wallet Console, and the settings refuse to switch Google Pay on without it. The button works on a page served over HTTPS and on .
The plugin registers under the same provider id as , so it replaces it without a data migration. The payments the old plugin created stay in the database, and this plugin captures, refunds and voids them by their transaction ID.
To switch:
Replace in the of the Payment Module with , keeping , and register the integration provider as shown in Configuration. Remove the old package, since only one provider can have .
Enter the keys and choose the Environment in Medusa Admin. The old plugin read , and from , and this plugin reads them from its settings.
Set Payment capture in the settings. The old plugin only ever authorized. With it recorded the payment as captured, but the transaction stayed authorized in Authorize.net and expired after 30 days. Check such transactions in the Merchant Interface and capture the ones still waiting.
Replace the storefront code. The old plugin took the card token, the addresses and the shipping from the session data the storefront sent. This plugin takes only the token from the storefront and reads the rest from the cart, as described in Integrate Authorize.net Payment into Storefront.