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
<?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"); |
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
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 |
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
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 |
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
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()); | |
} |
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
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); | |
} |
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
<?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; | |
} |
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
<?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; | |
} |
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
class MyAPI < Grape::API | |
class CrossOriginResourceSharingPolicy < Grape::Middleware::Base | |
def append_cors_headers(headers) | |
headers['Access-Control-Allow-Origin'] = env['HTTP_ORIGIN'] || '*' | |
headers['Access-Control-Allow-Credentials'] = 'true' | |
headers['Access-Control-Max-Age'] = '180' | |
if env['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'] | |
headers['Access-Control-Allow-Headers'] = env['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'] | |
end | |
headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, DELETE, OPTIONS' |
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
// 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); |
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
// 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); |