PHP Sample Codes

Payment Page

Amount To Be Withdrawn
Name on Credit Card
Credit Card Number
Expiry Month / Year:
/
Security Code:
(Last 3 digits on the back of the card)

<form method="post" action="">
	<table class="table table-condensed table-bordered" style="border:1px solid #ccc;background:#fbfbfb;margin:5px;width:99%;">
		<tr>
			<td style="font-size:15px;width:210px;"><b>Cekilecek Tutar</b></td>
			<td>
				<div class="col-sm-5">
				  <input type="text" class="form-control" id="amount" name="amount" onkeyup="sadece_para('amount');" placeholder="Cekilecek Tutar" value="<?=$_POST['amount']?>">
				</div>
			</td>
		</tr>
		<tr>
			<td style="font-size:15px;width:210px;"><b>Kredi Karti Uzerindeki Isim</b></td>
			<td>
				<div class="col-sm-5">
				  <input type="text" class="form-control" id="kart_isim" name="kart_isim" placeholder="Kredi Karti Uzerindeki Isim" autocomplete=off  size="20">
				</div>
			</td>
		</tr>
		<tr>
			<td style="font-size:15px;width:210px;"><b>Kredi Kart Numarasi</b></td>
			<td>
				<div class="col-sm-5">
				  <input type="text" class="form-control" id="pan" name="pan"  maxlength="16" onkeydown="sadece_rakam('pan');" placeholder="Kredi Kart Numarasi" autocomplete=off  size="20">
				</div>
			</td>
		</tr>
		<tr>
			<td style="font-size:15px;"><b>Son Kullanma Ay / Yil: </b></td>
			<td style="text-align:left;">
				<div class="col-sm-8"  style="float:left;">
					  <select style="width:80px;padding:3px;font-size:15px;" name="Ecom_Payment_Card_ExpDate_Month" id="Ecom_Payment_Card_ExpDate_Month">
					  </select>
						/
						<select style="width:80px;padding:3px;font-size:15px;" name="Ecom_Payment_Card_ExpDate_Year" id="Ecom_Payment_Card_ExpDate_Year">
						</select>
				</div>
			</td>
		</tr>
		<tr>
			<td style="font-size:15px;"><b>Guvenlik Kodu: <br/><span style="font-weight:100;">(Kartin arkasinda ki son 3 hane)</span></b></td>
			<td>
				<div class="col-sm-2">
					<input type="text" class="form-control" id="cv2" name="cv2" maxlength="4" placeholder="Guvenlik Kodu" autocomplete=off size="4" value="">
				</div>
				<button type="submit" id="devamEt" style="float:right;margin:20px;" class="btn btn-primary">Devam Et</button>
			</td>
		</tr>
	</table>
</form>

if(isset($_POST['pan'])){
	
	$moka_url = "https://service.testmoka.com/PaymentDealer/DoDirectPaymentThreeD";
	$dealer_code = "xxx";
	$username = "xxx";
	$password = "xxx";
	$currency = "TL";
	$InstallmentNumber = 0;
	$OtherTrxCode = "111";
	$SubMerchantName = "";
	$RedirectUrl = "https://pos.testmoka.com/OdemeSonuc.php?MyTrxCode=".$OtherTrxCode;

	$checkkey = hash("sha256",$dealer_code."MK".$username."PD".$password);
	$veri = array('PaymentDealerAuthentication'=>array('DealerCode'=>$dealer_code,'Username'=>$username,'Password'=>$password,
														'CheckKey'=>$checkkey),
				'PaymentDealerRequest'=>array('CardHolderFullName'=>$_POST['kart_isim'],
												'CardNumber'=>$_POST['pan'],
												'ExpMonth'=>$_POST['Ecom_Payment_Card_ExpDate_Month'],
												'ExpYear'=>'20'.$_POST['Ecom_Payment_Card_ExpDate_Year'],
												'CvcNumber'=>$_POST['cv2'],
												'Amount'=>$_POST['amount'],
												'Currency'=>$currency,
												'InstallmentNumber'=>$InstallmentNumber,
												'ClientIP'=>$_SERVER['REMOTE_ADDR'],
												'RedirectUrl'=>$RedirectUrl,
												'OtherTrxCode'=>$OtherTrxCode,
												'SubMerchantName'=>$SubMerchantName));


	$veri = json_encode($veri);
	$ch = curl_init($moka_url); 
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
	curl_setopt($ch, CURLOPT_POST, 1); 
	curl_setopt($ch, CURLOPT_POSTFIELDS, $veri);
	curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
	curl_setopt($ch, CURLOPT_SSLVERSION, 6);	    // TLS 1.2 baglanti destegi icin
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);    // VerifyPeer = 0 kalmalı
	$result = curl_exec ($ch); 
	curl_close ($ch);
	$result = json_decode($result);

	if($result->ResultCode == 'Success'){
		echo '

YOUR CARD INFORMATION IS CONFIRMED!!!

You will now be redirected to the bank's page to verify card security.
You will now be redirected to the bank's page to verify card security.

Click here if the redirect doesn't work...

'; header("Location: ".$result->Data); exit; }else{ echo '

Card information could not be verified. to try again click here.

'; } }

Results Page


if($_POST['isSuccessful'] == 'False'){
	echo '
ERROR !!!! Your payment transaction could not be completed.

Bank Answer : '.$_POST['resultMessage'].'

'; } else if($_POST['isSuccessful'] == 'True'){ echo '

Successful ! Your Payment Transaction Has Been Successfully Completed.

'.$_GET['MyTrxCode'].'

'.$_POST['trxCode'].'

'; }
Click to Download Sample Project.