Skip to content

Instantly share code, notes, and snippets.

View nukturnal's full-sized avatar

Alfred Rowe nukturnal

View GitHub Profile
@nukturnal
nukturnal / building_checkout_invoice.java
Created November 8, 2012 06:34
MPower Java Building a Checkout Invoice
// Adding items to your invoice is very basic, the parameters
// expected are name_of_item, quantity, unit_price, total_price and
// optional item description.
invoice.addItem("13' Apple Retina 500 HDD",1,10.99,10.99);
invoice.addItem("Case Logic laptop Bag",2,100.50,201,"Optional description");
invoice.addItem("Philips electric shaver",2,50.50,101.00);
/* You can optionally set a generation invoice description text which can
be used in cases where your invoice does not need an items list or in cases
where you need to include some extra descriptive information to your invoice */
@nukturnal
nukturnal / storesetup.java
Created November 8, 2012 06:15
MPower Java Checkout Store Setup
MPowerCheckoutStore store = new MPowerCheckoutStore();
store.setName("My Awesome Online store");
store.setTagline("This is an awesome Java store setup.");
store.setPhoneNumber("024000001");
store.setPostalAddress("606 Memorylane Chokor no.1 Road.");
store.setWebsiteUrl("http://my-awesome-long-website-url.com/");
@nukturnal
nukturnal / apikeys_setup.java
Created November 8, 2012 06:13
MPower Java API Keys Setup
MPowerSetup setup = new MPowerSetup();
setup.setMasterKey("dd6f2c90-f075-012f-5b69-00155d846600");
setup.setPrivateKey("test_private_oDLVld1eNyh0IsetdhdJvcl0ygA");
setup.setPublicKey("test_public_zzF3ywvX9DE-dSDNhUqKoaTI4wc");
setup.setToken("ca03737cf94wcf644f36");
setup.setMode("test");
@nukturnal
nukturnal / import.java
Created November 8, 2012 06:11
MPower Java Package Require
import com.mpowerpayments.mpower.*;
@nukturnal
nukturnal / confirm_invoice.rb
Last active October 12, 2015 13:57
MPower Ruby Checkout Invoice Confirmation
# Get the token prameter from the QUERYSTRING if you are on Rails or Sinatra
token = params[:token]
invoice = MPower::Checkout::Invoice.new
if invoice.confirm(token)
# Retrieving Invoice Status
# Status can be either completed, pending, canceled, fail
puts invoice.status
@nukturnal
nukturnal / returnurl.rb
Created November 8, 2012 05:38
MPower Ruby Checkout Invoice Return URL
# Globally setting return URL, the piece of code below
# should be included with the checkout shop setup code
MPower::Checkout::Store.return_url = "http://www.myawesomeshop.com/"
# Setting the return URL on an invoice instance.
# This will overwrite any global settings for return URL
invoice.return_url = "http://www.myawesomeshop.com/"
@nukturnal
nukturnal / cancelurl.rb
Created November 8, 2012 05:37
MPower Ruby Checkout Invoice Cancel URL
# Globally setting cancel URL, the piece of code below
# should be included with the checkout shop setup code
MPower::Checkout::Store.cancel_url = "http://www.myawesomeshop.com/"
# Setting the cancel URL on an invoice instance.
# This will overwrite any global settings for cancel URL
invoice.cancel_url = "http://www.myawesomeshop.com/"
@nukturnal
nukturnal / custom_data.rb
Last active October 12, 2015 13:57
MPower Ruby 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.add_custom_data("Firstname","Alswell")
invoice.add_custom_data("Lastname","Cobbinah")
invoice.add_custom_data("CartId",450021)
invoice.add_custom_data("Plan","JUMBO")
@nukturnal
nukturnal / addtax.rb
Created November 8, 2012 05:27
MPower Ruby Checkout Invoice Adding Tax
# The parameters for setting add tax are title_of_the_tax, tax_amount
invoice.add_tax("VAT (15%)",30);
invoice.add_tax("NHIL (5%)",10);
@nukturnal
nukturnal / create_redirect_checkout.rb
Last active October 12, 2015 13:57
MPower Ruby 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
puts invoice.status
puts invoice.response_text
# you may want to do "redirect_to invoice.invoice_url" in a Rails controller
puts invoice.invoice_url
else
puts invoice.status
puts invoice.response_text