Skip to content

Instantly share code, notes, and snippets.

@nukturnal
Created November 8, 2012 06:56
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 nukturnal/4037300 to your computer and use it in GitHub Desktop.
Save nukturnal/4037300 to your computer and use it in GitHub Desktop.
MPower Java Checkout Invoice Confirmation
// 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());
System.out.println(invoice.getResponseText());
// You can retrieve the Name, Email & Phone Number
// of the customer using the callbacks below
System.out.println(invoice.getCustomerInfo("name"));
System.out.println(invoice.getCustomerInfo("email"));
System.out.println(invoice.getCustomerInfo("phone"));
// Return the URL to the Invoice Receipt PDF file for download
System.out.println(invoice.getReceiptUrl());
// Retrieving any custom data you have added to the invoice
// Please remember to use the right keys you used to set them earlier
System.out.println(invoice.getCustomData("Firstname"));
System.out.println(invoice.getCustomData("CartId"));
System.out.println(invoice.getCustomData("Plan"));
// You can also callback the total amount set earlier
System.out.println(invoice.getTotalAmount());
}else{
System.out.println(invoice.getStatus());
System.out.println(invoice.getResponseText());
System.out.println(invoice.getResponseCode());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment