Search code examples
node.jsreactjscashfree

Getting error "Cannot find name Cashfree" while using cashfree payment integration in react js


Migrating to 2022-09-01 Cashfree documentation link : https://docs.cashfree.com/docs/checkout-migration-to-version-2022-09-01

Added the js sdk script in index.html in the public folder

<script src="https://sdk.cashfree.com/js/ui/2.0.0/cashfree.sandbox.js"></script>

But while doing

let cf = new Cashfree(session_id)
getting error "Cannot find name Cashfree"

How to import or use "new Cashfree()" in this case?


Solution

  • Once you add the javascript SDK url in the index.html which is in the public folder, try importing it by adding

    let cf = new window.Cashfree(session_id)
    

    wherever required