Skip to content

Instantly share code, notes, and snippets.

Avatar

Alfred Rowe nukturnal

View GitHub Profile
@nukturnal
nukturnal / direct_pay_example.php
Created Apr 6, 2013
Code snippet shows how to perform an MPower DirectPay
View direct_pay_example.php
<?php
require('mpower_php/mpower.php'); // Make sure the client library is relative to your path
MPower_Setup::setMasterKey("82403450-ee3a-4c57-9564-a8fbe30c5fb7");
MPower_Setup::setPublicKey("test_public_M6-fRS1RCnzlGqgeLaBF5vLLoKs");
MPower_Setup::setPrivateKey("test_private_jKxSn3ylcQdrQcuxAOFAbxvK5w4");
MPower_Setup::setMode("test");
MPower_Setup::setToken("7f6c81c1ea223674416e");
@nukturnal
nukturnal / rapgenius_cache_control_study.txt
Created Mar 9, 2013
Study on Rapgenious.com and their page caching.
View rapgenius_cache_control_study.txt
curl -I rapgenius.com
HTTP/1.1 200 OK
Server: nginx
Date: Sat, 09 Mar 2013 14:28:28 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 55913
Connection: keep-alive
Etag: "3cd63da6d49e1ec8fa84dc3ae13ff216"
X-Runtime: 1524
Set-Cookie: _rapgenius_session=BAh7BzoQX2NzcmZfdG9rZW4iMUxZRGZsbjhJdzZvS3NtTVlseE5iRnl6NnhUdzFiT245aVQwc0dzQ202S2M9Og9zZXNzaW9uX2lkIiUxZmEyOTQzZjU1NjI5NGVmZGQ2YjdmYjE2YmU1Y2Q1NA%3D%3D--c3f35e29399219a5990c3d864f9fa4b5682638f6; domain=.rapgenius.com; path=/; HttpOnly
View directpay.rb
direct_pay = MPower::DirectPay.new
if (direct_pay.credit_account("CUSTOMER_MPOWER_USERNAME_OR_PHONE",100))
puts direct_pay.description
puts direct_pay.response_text
puts direct_pay.transaction_id
else
puts direct_pay.description
puts direct_pay.response_text
end
View directpay.cs
MPowerDirectPay direct_pay = new MPowerDirectPay (setup);
if(direct_pay.CreditAccount("MPOWER_CUSTOMER_USERNAME_OR_PHONENO",50)){
Console.WriteLine(direct_pay.Description);
Console.WriteLine(direct_pay.Status);
Console.WriteLine(direct_pay.ResponseText);
}else{
Console.WriteLine(direct_pay.ResponseText);
Console.WriteLine(direct_pay.Status);
}
View directpay.java
MPowerDirectPay direct_pay = new MPowerDirectPay(apiSetupInstance);
if(direct_pay.creditAccount("MPOWER_CUSTOMER_USERNAME_OR_PHONENO",50)){
System.out.println("Status: "+direct_pay.getStatus());
System.out.println("Descripion: "+direct_pay.getDescription());
System.out.println("Transaction ID: "+direct_pay.getTransactionId());
}else{
System.out.println("Status: "+direct_pay.getStatus());
System.out.println("Response Message: "+direct_pay.getResponseText());
}
View directpay.php
<?php
$direct_pay = new MPower_DirectPay();
if ($direct_pay->creditAccount("MPOWER_CUSTOMER_USERNAME_OR_PHONENO",70.65)) {
print $direct_pay->description;
print $direct_pay->response_text;
print $direct_pay->transaction_id;
}else{
print $direct_pay->response_text;
}
View opr_request.php
<?php
// Onsite Payment Request requires the mpower customer account alias as the parameter
if ($invoice->create("MPOWER_CUSTOMER_USERNAME_OR_PHONENO")) {
echo $invoice->getStatus();
echo $invoice->response_text;
echo $invoice->getReceiptUrl();
} else {
echo $invoice->getStatus();
echo $invoice->response_text;
}
@nukturnal
nukturnal / init_onsite_invoice.java
Created Nov 15, 2012
MPower Java initialise an onsite invoice
View init_onsite_invoice.java
// If you wish to accept payments directly on your service
// Please note that the constructor requires a instance of both
// MPowerSetup & MPowerStore Classes respectively
MPowerOnsiteInvoice invoice = new MPowerOnsiteInvoice (setup, store);
@nukturnal
nukturnal / init_checkout_invoice.java
Created Nov 15, 2012
MPower Java initialise a checkout invoice
View init_checkout_invoice.java
// If you intend to use a simpler approach by redirecting to the MPower checkout page
// Please note that the constructor requires a instance of both
// MPowerSetup & MPowerStore Classes respectively
MPowerCheckoutInvoice invoice = new MPowerCheckoutInvoice (setup, store);
@nukturnal
nukturnal / opr_request.java
Created Nov 15, 2012
MPower Java OPR Request
View opr_request.java
// Onsite Payment Request requires the mpower customer account alias as the parameter
if (invoice.create("MPOWER_CUSTOMER_USERNAME_OR_PHONENO")) {
System.out.println ("OPR Token" + invoice.getToken());
System.out.println ("Status" + invoice.getStatus());
System.out.println ("Response Message" + invoice.getResponseText());
} else {
System.out.println("Status" + invoice.getStatus());
System.out.println("Response Message" + invoice.getResponseText());
}