Skip to content

PayHereDevs/payhere-nextjs-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PayHere NextJS Example

This is a Next.js project bootstrapped with create-next-app.

This repo contains an example integration of a Next.js project with the PayHere Javascript SDK.

PayHere

  1. Development and production versions of the payhere.js file are available in the "public" folder.
- public
 - payhere.js
 - payhere.dev.js
  1. In index.js, the appropriate script is loaded from this method:
function payHereURL(){
    if (process && process.env.NODE_ENV == "production")
      return '/payhere.js';
    else
      return '/payhere.dev.js';
}
  1. Include the PayHere Script as follows:
<script src={payHereURL()}></script>
  1. Check the startPayment() method in index.js to see how PayHere is integrated.

Run

Run the development server:

npm run dev
# or
yarn dev

Open http://localhost:3000 with your browser to see the result.

About

Sample integration with Next.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published