Are you ready to revolutionize the world of online stores with MedusaJS? We have an exciting opportunity that will make payment processing a breeze for our beloved Medusa platform! Introducing the Payment-Authorizenet provider, a community-driven project that brings the immensely popular Authorize.net payment gateway to our MedusaJS commerce stack.
What's in it for You?
π Streamline Payment Processing: With payment-authorizenet-medusa, you can unleash the full potential of Authorize.net's features, ensuring seamless and secure payments for your customers.
Features:
Authorize Payment : Authorize funds on a customer's card without immediate charge.
Capture Payment : Charge the previously authorized funds.
Auth-and-Capture : Authorize and capture funds in a single seamless step.
Cancel Payment : Cancel an authorization before the payment is captured.
Void Payment : Void a transaction before it has been settled.
Refund Payment : Process refunds for transactions that have already been settled.
Installation Made Simple
No hassle, no fuss! Install Payment-Authorizenet effortlessly with npm:
Authorize.net an immensely popular payment gateway with a host of features.
This provider enables the Authorize.net payment interface on Medusa commerce stack
Installation
Use the package manager npm to install Payment-Authorizenet.
npm install payment-authorizenet-medusa
Usage
Register for a Authorize.net account and generate the api keys
In your environment file (.env) define the API Login ID and Transaction Key:
You need to add the provider into your medusa-config.ts as shown below:
Client side configuration
For the NextJs start, make the following changes
Step 1.
Install package to your next starter. This simplifies the process by importing all the scripts implicitly
npm install authorizenet-react
or
yarn add authorizenet-react
Step 2.
Add environment variables in the client (storefront) (.env) file:
Note : To generate the Client Key, log in to the Merchant Interface as an Administrator and navigate to Account > Settings > Security Settings > General Security Settings > Manage Public Client Key
ANUTHORIZENET_PUBLIC_CLIENT_KEY= <your ANUTHORIZENET PUBLIC CLIENT KEY>
ANUTHORIZENET_PUBLIC_API_LOGIN_ID= <your ANUTHORIZENET API LOGIN ID>
Step 3.
Add /src/lib/constants.tsx
Step 4.
Add a AuthoirizenetCardConatiner in /src/modules/checkout/components/payment-conatiner/index.tsx
Step 5.
add AuthorizeNetCardContainer in the client /src/modules/checkout/components/payment/index.tsx
Step 6.
modify initiatePaymentSession in the client /src/modules/checkout/components/payment/index.tsx
Step 7.
Create a button for Autorize.net /src/modules/checkout/components/payment-button/authorizenet-payment-button.tsx
like below
Step 8.
Add into the payment element /src/modules/checkout/components/payment-button/index.tsx
then
watch out
Caveat the default starter template has an option which says use the same shipping and billing address
please ensure you deselect this and enter the phone number manually in the billing section.
The code was tested on limited number of usage scenarios. There maybe unforseen bugs, please raise the issues as they come, or create pull requests if you'd like to submit fixes.