예제 #1
0
 public static function httpGetRequest($url)
 {
     Requests::register_autoloader();
     $headers = array('MP-Public-Key' => MPower_Setup::getPublicKey(), 'MP-Private-Key' => MPower_Setup::getPrivateKey(), 'MP-Master-Key' => MPower_Setup::getMasterKey(), 'MP-Token' => MPower_Setup::getToken(), 'MP-Mode' => MPower_Setup::getMode(), 'User-Agent' => "MPower Checkout API PHP client v1 aka Don Nigalon");
     $request = Requests::get($url, $headers, array('timeout' => 10));
     return json_decode($request->body, true);
 }
예제 #2
0
파일: direct_pay.php 프로젝트: tynawood/rm
 public function creditAccount($payee_account, $amount)
 {
     $payload = array('account_alias' => $payee_account, 'amount' => $amount);
     $result = MPower_Utilities::httpJsonRequest(MPower_Setup::getDirectPayCreditUrl(), $payload);
     if (count($result) > 0) {
         switch ($result['response_code']) {
             case 00:
                 $this->status = $result['status'];
                 $this->response_text = $result["response_text"];
                 $this->description = $result["description"];
                 $this->transaction_id = $result["transaction_id"];
                 return true;
                 break;
             default:
                 $this->status = $result['status'];
                 $this->response_text = $result["response_text"];
                 $this->response_code = $result["response_code"];
                 return false;
         }
     } else {
         $this->status = "fail";
         $this->response_code = 4002;
         $this->response_text = "An Unknown MPower Server Error Occured.";
         return false;
     }
 }
예제 #3
0
파일: direct_card.php 프로젝트: tynawood/rm
 public function charge($amount, $card_name, $card_number, $card_cvc, $exp_month, $exp_year)
 {
     $payload = array('card_name' => $card_name, 'card_number' => $card_number, 'card_cvc' => $card_cvc, 'exp_month' => $exp_month, 'exp_year' => $exp_year, 'amount' => $amount);
     $result = MPower_Utilities::httpJsonRequest(MPower_Setup::getDirectCreditcardChargeUrl(), $payload);
     if (count($result) > 0) {
         switch ($result['response_code']) {
             case 00:
                 $this->status = $result['status'];
                 $this->response_text = $result["response_text"];
                 $this->description = $result["description"];
                 $this->transaction_id = $result["transaction_id"];
                 $this->unity_transaction_id = $result["unity_transaction_id"];
                 return true;
                 break;
             default:
                 $this->status = $result['status'];
                 $this->response_text = $result["response_text"];
                 $this->response_code = $result["response_code"];
                 return false;
         }
     } else {
         $this->status = "fail";
         $this->response_code = 4002;
         $this->response_text = "An Unknown MPower Server Error Occured.";
         return false;
     }
 }
 private function initialize()
 {
     \MPower_Setup::setMasterKey("da1666f2-fb46-4fa2-b3ca-194992922f49");
     \MPower_Setup::setPublicKey("test_public_SgwQ0HO892lCaCGXg2r3kF85o7M");
     \MPower_Setup::setPrivateKey("test_private_7eyIvdfBBoUBubMSV4hcqEvQm14");
     \MPower_Setup::setMode("test");
     \MPower_Setup::setToken("2a4b2b1b9cbf8649e69b");
     // Return url
     \MPower_Checkout_Store::setReturnUrl(url('order/feedback/' . PaymentMethod::PAYMENT_MPOWER));
     \MPower_Checkout_Store::setName("MediBig.com");
     \MPower_Checkout_Store::setTagline("I can also buy it!");
     \MPower_Checkout_Store::setPhoneNumber("0501373573");
     //\MPower_Checkout_Store::setPostalAddress("Post office Box AN 10604");
     $this->invoice = new \MPower_Checkout_Invoice();
 }
예제 #5
0
 public function create($account_alias)
 {
     $invoice_data = array('invoice' => array('items' => $this->items, 'taxes' => $this->taxes, 'total_amount' => $this->getTotalAmount(), 'description' => $this->getDescription()), 'store' => array('name' => MPower_Checkout_Store::getName(), 'tagline' => MPower_Checkout_Store::getTagline(), 'postal_address' => MPower_Checkout_Store::getPostalAddress(), 'phone' => MPower_Checkout_Store::getPhoneNumber(), 'logo_url' => MPower_Checkout_Store::getLogoUrl(), 'website_url' => MPower_Checkout_Store::getWebsiteUrl()), 'custom_data' => $this->showCustomData(), 'actions' => array('cancel_url' => $this->cancel_url, 'return_url' => $this->return_url));
     $payload = array('invoice_data' => $invoice_data, 'opr_data' => array('account_alias' => $account_alias));
     $result = MPower_Utilities::httpJsonRequest(MPower_Setup::getOPRInvoiceUrl(), $payload);
     switch ($result["response_code"]) {
         case 00:
             $this->status = "success";
             $this->token = $result["token"];
             $this->invoice_token = $result["invoice_token"];
             $this->response_code = $result["response_code"];
             $this->response_text = $result["response_text"];
             return true;
             break;
         default:
             $this->invoice_url = "";
             $this->status = "fail";
             $this->response_code = $result["response_code"];
             $this->response_text = $result["response_text"];
             return false;
             break;
     }
 }
<?php

require 'mpower_php/mpower.php';
// Make sure the client library is relative to your path
MPower_Setup::setMasterKey("dd6f2c90-f075-012f-5b69-00155d866600");
MPower_Setup::setPublicKey("live_public_DP2tNf1X2NHWIE4EN1Ep3FCPKXc");
MPower_Setup::setPrivateKey("live_private_HSJ-DYh7jdiqnqIvDW_X3F4kE8k");
MPower_Setup::setMode("live");
MPower_Setup::setToken("e179a0d8f07ef0078e38");
$direct_pay = new MPower_DirectPay();
if ($direct_pay->creditAccount("0244124660", 70.65000000000001)) {
    print $direct_pay->description;
    print $direct_pay->response_text;
    print $direct_pay->transaction_id;
} else {
    print $direct_pay->response_text;
}
예제 #7
0
<?php

require 'mpower_php/mpower.php';
MPower_Setup::setMasterKey("dd6f2c90-f075-012f-5b69-00155d866600");
MPower_Setup::setPublicKey("live_public_xDPNs0zAJ856YfC3z6rBwGsjqBA");
MPower_Setup::setPrivateKey("live_private_0mhrAda3hiiEfIirJYRC7w77moY");
MPower_Setup::setMode("live");
MPower_Setup::setToken("d13ab6c069296cfff556");
// Configure Checkout Store
MPower_Checkout_Store::setName("Awesome Online Store");
MPower_Checkout_Store::setTagline("Awesome localhost.localdomain online store tagline ");
MPower_Checkout_Store::setPhoneNumber("0244000001");
MPower_Checkout_Store::setPostalAddress("P. O. Box AN 1010. Accra - Ghana.");
// You may set this to your localhost for local testing of redirects
// MPower_Checkout_Store::setCancelUrl("http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME'])."/index.php");
// MPower_Checkout_Store::setReturnUrl("http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME'])."/confirm.php");
예제 #8
0
 public static function setMode($mode)
 {
     self::$mode = $mode;
 }
예제 #9
0
파일: Payments.php 프로젝트: tynawood/rm
echo "<img src='final.gif' width='100%' height='780' />";
sleep(3);
//die;
$live = !false;
if ($live == false) {
    MPower_Setup::setMasterKey("90a2f8a1-7f7b-471f-bdb4-268a270985d4");
    MPower_Setup::setPublicKey("test_public_rg2qugm3CWU2J-xvi14KE4-AYGY");
    MPower_Setup::setPrivateKey("test_private_eBw1XNZOWtx8XTvDMuZCDZot8I4");
    MPower_Setup::setMode("test");
    MPower_Setup::setToken("0b8275226b2ec2da5458");
} else {
    MPower_Setup::setMasterKey("90a2f8a1-7f7b-471f-bdb4-268a270985d4");
    MPower_Setup::setPublicKey("live_public_qj5brK9VO3LbA8xSPE8IPtyExf4");
    MPower_Setup::setPrivateKey("live_private_b1wT60n7jXB4zlMaC67gIjNDC3s");
    MPower_Setup::setMode("live");
    MPower_Setup::setToken("314891080ac32d5c94de");
}
// Configure Checkout Store
MPower_Checkout_Store::setName("CND GLOBAL FASHION");
MPower_Checkout_Store::setTagline("A Touch Of African Fashion");
MPower_Checkout_Store::setPhoneNumber("+3361877452626/+336752517819");
MPower_Checkout_Store::setPostalAddress("130 Grande Rue 92310 \n Paris Servres");
//$invoice = new MPower_Checkout();
$invoice = new MPower_Checkout_Invoice();
$invoice->setCancelUrl("http://www.cndglobalfashion.com/Mpower/Cancel.php");
$invoice->setReturnUrl("http://www.cndglobalfashion.com/Mpower/Success.php");
/* Adding items to your invoice is very basic, the parameters expected are
		name_of_item, quantity, unit_price, total_price and optional item
		description. */
@session_start();
//@session_destroy();