Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meetKazuki/598dc7727e3b741caee8cec485d58e51 to your computer and use it in GitHub Desktop.
Save meetKazuki/598dc7727e3b741caee8cec485d58e51 to your computer and use it in GitHub Desktop.
Simple JS implementation for paystack
makeInvestment: async () => {
/*
add this script inside your page head tag <script async src="https://js.paystack.co/v1/inline.js" />
this will make the PasystackPop available
*/
const handler = PaystackPop.setup({
key: process.env.PAYSTACK_LIVE_API,
email: 'user@example.com',
amount: `100000`,
currency: user.currency,
ref: `${Date.now()}_xxxxxxxx`,
metadata: {
custom_fields: [
{
display_name: 'Customer Name',
variable_name: 'customer_name',
value: `Alabo Briggs`
}
]
},
callback: async (result) => {
/*
Do what you want with result object here, you can handle redirect or make post
request to server here if successful
*/
},
onClose: () => {
// if payment was succefull handle error here
}
});
return handler.openIframe();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment