Skip to content

Instantly share code, notes, and snippets.

View nukturnal's full-sized avatar

Alfred Rowe nukturnal

View GitHub Profile
@nukturnal
nukturnal / opr_request.rb
Last active October 12, 2015 19:48
MPower Ruby OPR Request
# 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
@nukturnal
nukturnal / init_onsite_invoice.rb
Created November 15, 2012 13:10
MPower Ruby initialise an onsite invoice
# If you wish to accept payments directly on your service
invoice = MPower::Onsite::Invoice.new
@nukturnal
nukturnal / init_checkout_invoice.rb
Created November 15, 2012 13:05
MPower Ruby initialise a checkout invoice
# If you intend to use a simpler approach by redirecting to the MPower checkout page
invoice = MPower::Checkout::Invoice.new
@nukturnal
nukturnal / confirm.java
Created November 8, 2012 06:56
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());
@nukturnal
nukturnal / returnurl.java
Created November 8, 2012 06:52
MPower Java Checkout Invoice Return URL
// 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/");
@nukturnal
nukturnal / cancelurl.java
Created November 8, 2012 06:51
MPower Java Checkout Invoice Cancel URL
// 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/");
@nukturnal
nukturnal / custom_data.java
Created November 8, 2012 06:46
MPower Java Checkout Invoice Custom Data
// 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");
@nukturnal
nukturnal / addtax.java
Created November 8, 2012 06:44
MPower Java Checkout Invoice Adding Tax
// The parameters for setting add tax are title_of_the_tax, tax_amount
invoice.addTax("VAT (15%)",30);
invoice.addTax("NHIL (5%)",10);
@nukturnal
nukturnal / create_redirect_checkout.java
Created November 8, 2012 06:40
MPower Java Checkout Invoice Creation & Redirection
// 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());
}
@nukturnal
nukturnal / total_amount.java
Created November 8, 2012 06:36
MPower Java Checkout Invoice Total Amount
invoice.setTotalAmount(100.50);