This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Onsite Payment Request requires the mpower customer account alias as the parameter | |
if invoice.create("MPOWER_CUSTOMER_USERNAME_OR_PHONENO") | |
puts invoice.status | |
puts invoice.response_text | |
puts invoice.token | |
else | |
puts invoice.status | |
puts invoice.response_text | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you wish to accept payments directly on your service | |
invoice = MPower::Onsite::Invoice.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you intend to use a simpler approach by redirecting to the MPower checkout page | |
invoice = MPower::Checkout::Invoice.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Invoice token is returned as a URL query string "token" | |
// You are free to also explicitly check the status of an invoice | |
String invoiceToken = "sjklsdll21-ms0w"; | |
MPowerCheckoutInvoice invoice = new MPowerCheckoutInvoice (setup, store); | |
if (invoice.confirm(invoiceToken)) { | |
// Retrieving Invoice Status | |
// Status can be either completed, pending, canceled, fail | |
System.out.println(invoice.getStatus()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Globally setting return URL, the piece of code below | |
// should be included with the checkout shop setup code | |
MPowerStore store = new MPowerStore() | |
store.setReturnlUrl("http://www.myawesomeshop.com/"); | |
// Setting the return URL on an invoice instance. | |
// This will overwrite any global settings for return URL | |
invoice.setReturnlUrl("http://www.myawesomeshop.com/"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Globally setting cancel URL, the piece of code below | |
// should be included with the checkout shop setup code | |
MPowerStore store = new MPowerStore() | |
store.setCancelUrl("http://www.myawesomeshop.com/"); | |
// Setting the cancel URL on an invoice instance. | |
// This will overwrite any global settings for cancel URL | |
invoice.setCancelUrl("http://www.myawesomeshop.com/"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Custom data allows you to add extra data to the invoice information | |
// which can be accessed via our confirm API callback | |
invoice.addCustomData("Firstname","Alswell"); | |
invoice.addCustomData("Lastname","Cobbinah"); | |
invoice.addCustomData("CartId",450021); | |
invoice.addCustomData("Plan","JUMBO"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The parameters for setting add tax are title_of_the_tax, tax_amount | |
invoice.addTax("VAT (15%)",30); | |
invoice.addTax("NHIL (5%)",10); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The code below depicts how to create the checkout invoice on our servers | |
// and redirect to the checkout page. | |
if (invoice.create()) { | |
System.out.println(invoice.getStatus()); | |
System.out.println(invoice.getResponseText()); | |
System.out.println(invoice.getInvoiceUrl()); | |
} else { | |
System.out.println(invoice.getResponseText()); | |
System.out.println(invoice.getStatus()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
invoice.setTotalAmount(100.50); |