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
// 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 */ |
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
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/"); |
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
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"); |
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
import com.mpowerpayments.mpower.*; |
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
# 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 |
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 | |
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/" |
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 | |
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/" |
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.add_custom_data("Firstname","Alswell") | |
invoice.add_custom_data("Lastname","Cobbinah") | |
invoice.add_custom_data("CartId",450021) | |
invoice.add_custom_data("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.add_tax("VAT (15%)",30); | |
invoice.add_tax("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 | |
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 |