Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...


Once you've copied this code into your website, you can start receiving payments via Monnify immediately. 

You can also now receive payments with our new web sdk by simply replacing the “src” value of the above code sample with https://sdk-v2.monnify.com/plugin/monnify.js and leaving the paymentMethods array empty so that it uses all the available payment methods configured for you. After clicking the “Pay With Monnify“ button, you should have an image like this:

...

below is an example of a sample code:

Code Block
languagejson
<script type="text/javascript" src="https://sdk-v2.monnify.com/plugin/monnify.js"></script>
<button onclick="payWithMonnify()">Pay with Monnify</button>
			

<script type="text/javascript">
	function payWithMonnify() {
		MonnifySDK.initialize({
			amount: 5000,
			currency: "NGN",
			reference: '' + Math.floor((Math.random() * 1000000000) + 1),
			customerName: "John Doe",
			customerEmail: "monnify@monnify.com",
			apiKey: "MK_PROD_SAF7HR5F3F",
			contractCode: "4934121693",
			paymentDescription: "Test Pay",
			isTestMode: true,
		    metadata: {
                    "name": "Damilare",
                    "age": 45
            },
			paymentMethods: [],
			incomeSplitConfig: 	[
            	{
	    			"subAccountCode": "MFY_SUB_342113621921",
	    			"feePercentage": 50,
		    		"splitAmount": 1900,
		    		"feeBearer": true
    			},
    			{
		    		"subAccountCode": "MFY_SUB_342113621922",
		    		"feePercentage": 50,
	    			"splitAmount": 2100,
	    			"feeBearer": true
	    		}
    	    ],
			onComplete: function(response){
				//Implement what happens when transaction is completed.
	 			console.log(response);
			},
			onClose: function(data){
				//Implement what should happen when the modal is closed here
				console.log(data);
			}
		});
	}
</script>
Info

You will need to pass in your own values when initializing the SDK. Your contractCode, and apiKey can be found on your Monnify dashboard

When the transaction is completed, Monnify returns a response object to your onComplete function. 

...