Skip to content

Instantly share code, notes, and snippets.

View nukturnal's full-sized avatar

Alfred Rowe nukturnal

View GitHub Profile
@nukturnal
nukturnal / return_url.php
Last active October 12, 2015 12:58
MPower PHP Checkout Invoice Return URL
<?php
// Globally setting return URL, the piece of code below
// should be included with the checkout shop setup code
MPower_Checkout_Store::setReturnUrl("http://www.myawesomeshop.com/confirm.php");
// Setting the return URL on an invoice instance.
// This will overwrite any global settings for return URL
$invoice->setReturnUrl("http://www.myawesomeshop.com/confirm.php");
@nukturnal
nukturnal / custom_data.php
Last active October 12, 2015 12:58
MPower PHP Checkout Invoice Custom Data
<?php
// 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 / confirm_invoice.php
Last active October 12, 2015 13:07
MPower PHP Library Checkout Invoice Confirmation
<?php
// MPower will automatically set the confirm token to QUERY_STRING
// param $_GET['token'] if not explicitly specified
$token = $_GET["token"];
$invoice = new MPower_Checkout_Invoice();
if ($invoice->confirm($token)) {
// Retrieving Invoice Status
// Status can be either completed, pending, canceled, fail
@nukturnal
nukturnal / namespace.cs
Created November 7, 2012 15:04
MPower .NET Namespace
using MPowerPayments;
@nukturnal
nukturnal / apikeys_setup.cs
Created November 7, 2012 15:08
MPower .NET API keys set up
MPowerSetup setup = new MPowerSetup {
MasterKey = "dd6f2c90-f075-012f-5b69-00155d864600",
PrivateKey = "test_private_oDLVlm1eNyh0IsetdhdJvcl0ygA",
PublicKey = "test_public_zzF3ywvX9DE-OSDNhUqKoaTI4wc",
Token = "ca03737cf942cf644f36",
Mode = "test"
};
@nukturnal
nukturnal / store_conf.cs
Created November 7, 2012 15:18
MPower .NET Checkout Store Configuration
MPowerStore store = new MPowerStore {
Name = "Awesome Online Store",
Tagline = "This is my awesome tagline",
PhoneNumber = "030200001",
PostalAddress = "P. O. Box 10770 Accra North Ghana",
LogoUrl = "http://www.mylogourl.com/photo.png"
};
@nukturnal
nukturnal / building_checkout_invoice.cs
Created November 7, 2012 15:37
MPower .NET 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 / total_amount.cs
Created November 7, 2012 15:40
MPower .NET Checkout Invoice Total Amount
invoice.SetTotalAmount (100.50);
@nukturnal
nukturnal / create_redirect_checkout.cs
Created November 7, 2012 15:46
MPower .NET Library 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 ()) {
Console.WriteLine (invoice.Status);
Console.WriteLine (invoice.ResponseText);
Console.WriteLine (invoice.GetInvoiceUrl());
} else {
Console.WriteLine (invoice.ResponseText);
Console.WriteLine (invoice.Status);
}
@nukturnal
nukturnal / addtax.cs
Created November 7, 2012 15:52
MPower .NET 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);