A plugin to use Nova.Pay on Medusa.
A Medusa V2 plugin to integrate Nova.Pay into your store.
Install the package via npm or yarn:
1npm install @novamoney/nova-pay2# or3yarn add @novamoney/nova-pay
Add the following environment variables to your file:
1NOVA_PAY_API_KEY=your_api_key_here2NOVA_PAY_CART_PAGE_ID=your_cart_page_uuid_here3NOVA_PAY_SUBDOMAIN=your_nova_pay_subdomain_here4NOVA_PAY_VERBOSE=true # Optional: enables sync logging
Enable the plugin in your file:
1// medusa-config.ts23module.exports = defineConfig({4 // ...5 plugins: [6 // ... other plugins7 {8 resolve: "@novamoney/nova-pay",9 options: {10 apiKey: process.env.NOVA_PAY_API_KEY,11 subdomain: process.env.NOVA_PAY_SUBDOMAIN12 },13 },14 ],15 // ...16 modules: [17 // ... other modules18 {19 resolve: "@medusajs/medusa/payment",20 options: {21 providers: [22 {23 resolve: "@novamoney/nova-pay/providers/payment",24 id: "nova-pay",25 options: {26 apiKey: process.env.NOVA_PAY_API_KEY,27 cartPageId: process.env.NOVA_PAY_CART_PAGE_ID,28 subdomain: process.env.NOVA_PAY_SUBDOMAIN29 }30 },31 ]32 }33 }34 ]35});
When you initiate a payment using one of the Nova.Pay providers, the response will include a in the object of the payment session. You must redirect the customer to this URL to complete the payment.
1const handlePayment = async (paymentSession) => {2 if (paymentSession.data.link) {3 // Redirect to Nova.Pay checkout4 window.location.href = paymentSession.data.link;5 }6};
Licensed under the MIT License.