PHP Classes

File: js/paystack.html

Recommend this page to a friend!
  Classes of bamigboye biodun   Logical Functions   js/paystack.html   Download  
File: js/paystack.html
Role: Auxiliary data
Content type: text/plain
Description: Example page to make a payment with the Paystack service
Class: Logical Functions
General-purpose PHP and JavaScript functions
Author: By
Last change:
Date: 1 year ago
Size: 1,272 bytes
 

Contents

Class file image Download
<!DOCTYPE html> <html lang="en"> <head></head> <body> </body> </html> <script src="https://js.paystack.co/v1/inline.js"></script> <script> const payWithPayStack= (payStackPublicKey,amount,email='defaultem@gmail.com',phone=00000000000,currency='NGN') => { return new Promise((resolve) => { amount = amount * 100; var handler = PaystackPop.setup({ key: payStackPublicKey, email: email, amount: amount, currency: currency, metadata: { custom_fields: [{ display_name: "Mobile Number", variable_name: "mobile_number", value: amount, }] }, callback: function(response) { resolve(response) }, onClose: function() { alert("Transaction Cancelled") } }); handler.openIframe(); }) //-- Promise Ends Here } //-- Usage payWithPayStack( 'pk_test_597ab21e3648f1fee27c53efcdbf2e235df101d6', 5000, 'emailIsOptional@gmail.com' ,090764636574,'NGN' ).then((response) =>{ console.log(response) }) /* Author : Biodun Bamigboye Email, Phone and Currency is Optional */ </script>