daily pastebin goal
90%
SHARE
TWEET

Untitled

a guest Feb 16th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.     define('SPID', 888777);
  3.     define('PASSWORD', 'ZjYwY2ZjYmI1YTRjZmEzY2JlNzNhNzEzODI0YzBlZjYwYmFlZWFmZGFmNTBkMjA4MWMyMGM3MDA3NzA0ZWQzMg==');
  4.     define('SERVICEID', 888777000);
  5.     define('initiator_username', 'DreamInit');
  6.     define('initiator_pass', 'Qazwsx123!');
  7.     define('B2CPaybill', 300237);
  8.     define('result_url', 'https://10.176.0.117:443/callback.php');
  9.     // define('SSL_CERT_PATH', env('SSL_CERT_PATH'));
  10.     // define('SSL_KEY_PATH', env('SSL_KEY_PATH'));
  11.     // define('SSL_PASS', env('SSL_PASS'));
  12.     // define('APICRYPT_PATH', env('APICRYPT_PATH'));
  13.     // send money to the number provided
  14.    
  15.     sendmoney();
  16.     function sendmoney($phone=null,$amount=null)
  17.     {        
  18.         date_default_timezone_set('Africa/Nairobi');
  19.         $phone = '254711959143';
  20.         $amount = 5000;
  21.         $no = "254".substr($phone,-9);
  22.         $timestamp_ = 20160927093535;//date("YdmHis");
  23.         $real_pass = base64_encode(hash('sha256', SPID . "" . PASSWORD . "" . $timestamp_));
  24.         $real_pass = 'ZjYwY2ZjYmI1YTRjZmEzY2JlNzNhNzEzODI0YzBlZjYwYmFlZWFmZGFmNTBkMjA4MWMyMGM3MDA3NzA0ZWQzMg==';
  25.         $securityCredential = getSecurityCredential(initiator_pass);
  26.         $rand = rand(123456, 654321);
  27.         $originId = SPID . "_".initiator_username."_" . $rand;
  28.         $type = 2;
  29.         $third_party_id = null;
  30.         $reqTime = date('Y-m-d') . "T" . date('H:i:s') . ".0000521Z"; //2014-10-21T09:47:19.0000521Z
  31.         $curlData =
  32.         '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  33.         <s:Header>
  34.         <h:RequestSOAPHeader xmlns:h="http://www.huawei.com.cn/schema/common/v2_1" xmlns="http://www.huawei.com.cn/schema/common/v2_1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  35.         <h:spId>'.SPID.'</h:spId>
  36.         <h:spPassword>ZjYwY2ZjYmI1YTRjZmEzY2JlNzNhNzEzODI0YzBlZjYwYmFlZWFmZGFmNTBkMjA4MWMyMGM3MDA3NzA0ZWQzMg==</h:spPassword>
  37.         <h:serviceId>'.SERVICEID.'</h:serviceId>
  38.         <h:timeStamp>'.$timestamp_.'</h:timeStamp>
  39.         </h:RequestSOAPHeader>
  40.         </s:Header>
  41.         <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  42.         <RequestMsg xmlns="http://api-v1.gen.mm.vodafone.com/mminterface/request">
  43.         <![CDATA[<request xmlns="http://api-v1.gen.mm.vodafone.com/mminterface/request">
  44.         <Transaction>
  45.         <CommandID>BusinessPayment</CommandID>
  46.         <OriginatorConversationID>'.$originId.'</OriginatorConversationID>
  47.         <Parameters><Parameter><Key>Amount</Key><Value>'.$amount.'</Value></Parameter></Parameters>
  48.         <ReferenceData><ReferenceItem><Key>QueueTimeoutURL</Key><Value>'.result_url.'</Value></ReferenceItem></ReferenceData>
  49.         <Timestamp>'.$reqTime.'</Timestamp></Transaction>
  50.         <Identity>
  51.         <Caller>
  52.         <CallerType>'.$type.'</CallerType>
  53.         <ThirdPartyID>'.SPID.'</ThirdPartyID>
  54.         <Password>Password0</Password>
  55.         <CheckSum></CheckSum>
  56.         <ResultURL>'.result_url.'</ResultURL>
  57.         </Caller>
  58.         <Initiator>
  59.             <IdentifierType>11</IdentifierType>
  60.             <Identifier>'.initiator_username.'</Identifier>
  61.             <SecurityCredential>'.$securityCredential.'</SecurityCredential>
  62.             <ShortCode>'.B2CPaybill.'</ShortCode>
  63.         </Initiator>
  64.         <PrimaryParty>
  65.         <IdentifierType>4</IdentifierType>
  66.         <Identifier>'.B2CPaybill.'</Identifier>
  67.         </PrimaryParty>
  68.         <ReceiverParty>
  69.         <IdentifierType>1</IdentifierType>
  70.         <Identifier>'.$no.'</Identifier>
  71.         </ReceiverParty>
  72.         </Identity>
  73.         <KeyOwner>1</KeyOwner></request>]]></RequestMsg>
  74.         </s:Body>
  75.         </s:Envelope>';
  76.         sendRequest($curlData);
  77.     }
  78.     function sendRequest($curlData)
  79.     {
  80.         $url = 'https://196.201.214.136:18423/mminterface/request';
  81.         $curl = curl_init();
  82.         curl_setopt($curl, CURLOPT_URL, $url);
  83.         curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  84.         curl_setopt($curl, CURLOPT_TIMEOUT, 360);
  85.         curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 360);
  86.         curl_setopt($curl, CURLOPT_ENCODING, 'utf-8');
  87.         curl_setopt($curl, CURLOPT_HTTPHEADER, array(
  88.             'SOAPAction:""',
  89.             'Content-Type: text/xml; charset=utf-8',
  90.         ));
  91.         curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
  92.         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
  93.         curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
  94.         //CURLOPT_VERBOSE        => true,
  95.         // curl_setopt($curl, CURLOPT_SSLCERT, 'broker/TestBroker.cer');
  96.         // curl_setopt($curl, CURLOPT_SSLCERT, SSL_CERT_PATH);
  97.         // curl_setopt($curl, CURLOPT_SSLCERTTYPE, 'PEM');
  98.         //curl_setopt($curl, CURLOPT_SSLKEY, '/var/www/html/sdp_apps/services/b2c/pkcs/certs_chain.pem');
  99.         // curl_setopt($curl, CURLOPT_SSLKEY, SSL_KEY_PATH);
  100.         // curl_setopt($curl, CURLOPT_SSLKEYPASSWD, SSL_PASS);
  101.         curl_setopt($curl, CURLOPT_POST, 1);
  102.         curl_setopt($curl, CURLOPT_POSTFIELDS, $curlData);
  103.         //curl_setopt($curl, CURLOPT_HEADERFUNCTION, 'read_header'); // get header
  104.         $result = curl_exec($curl);
  105.         if (curl_errno($curl)) {
  106.             echo 'Curl Error: ' . curl_error($curl) . "\n\n";
  107.         }
  108.         echo date('Y-m-d H:i:s') . ": Response: $result\n";
  109.         curl_close($curl);
  110.         return $result;
  111.     }
  112.     function read_header($curl, $string)
  113.     {
  114.         print "Received header: $string\n\n";
  115.         return strlen($string);
  116.     }
  117.     function getSecurityCredential($source)
  118.     {
  119.         $crypttext;
  120.         $padding = "OPENSSL_PKCS1_PADDING";
  121.         $fp=fopen("api-cert/apicrypt.safaricom.co.ke.cer.txt","r");
  122.         $pub_key=fread($fp,8192);
  123.         fclose($fp);
  124.         $pub_key_string=openssl_get_publickey($pub_key);
  125.         openssl_public_encrypt($source,$crypttext,$pub_key_string);
  126.         $test = base64_encode($crypttext);
  127.         return $test;
  128.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top