I am making a custom payment wordpress plugin for my local bank (BCA Sakuku) and have problem when generate different output for same flag status always got "00" just for success case but got failed for other three cases such as "Invalid TransactionID" case, "Invalid Signature" case, & "Double Payment" case. For further detail please check out this link.
Here my result.php
<?php
//catch from gateway
$_POST = json_decode(file_get_contents("php://input"), 1);
if( $_SERVER['REQUEST_METHOD'] == 'POST' ){
if( isset( $_POST['MerchantID'] ) AND isset( $_POST['TransactionID'] ) AND isset( $_POST['TransactionReffID'] ) AND isset( $_POST['Signature'] ) ){
//VALIDATE MERCHANT ID
if( $_POST['MerchantID'] == $_POST['MerchantID'] ){
$orders = $_POST['TransactionID'];
if( $orders AND $_POST['TransactionID'] ){
if( $orders == $_POST['TransactionID'] ){
$sakukuOrder = $_POST['TransactionID'];
if( $sakukuOrder ){
$str = $_SESSION["AccTok"].$_SESSION["TransID"].$_SESSION["AMOUT"].$_SESSION["PayID"];
$validate = strtoupper( hash('sha256', $str) );
if( $_POST['Signature'] == $_POST['Signature']){
//Only passed for "success" case
generateOutput( 0, "00" );
}else{
generateOutput( 1, "01" );
}
}else{
generateOutput( 1, "01" );
}
}else{
generateOutput( 1, "01" );
}
}
}else{
generateOutput( 1, "01" );
}
}else{
generateOutput( 1, "01" );
}
}
function generateOutput( $rs, $status ){
$reason = array(
"Indonesian" => array("Sukses","Transaksi tidak dapat diproses.","Transaksi sudah dibayar."),
"English" => array("Success","Transaction cannot be processed.","Transaction has been paid."),
);
$output = array(
"MerchantID" => ( !isset( $_POST['MerchantID'] ) ) ? '' : $_POST['MerchantID'],
"TransactionID" => ( !isset( $_POST['TransactionID'] ) ) ? '' : $_POST['TransactionID'],
"FlagStatus" => "01",
"ReasonStatus" => array( "Indonesian" => "", "English" => "" )
);
$output['FlagStatus'] = $status;
$output['ReasonStatus']['Indonesian'] = $reason['Indonesian'][ $rs ];
$output['ReasonStatus']['English'] = $reason['English'][ $rs ];
echo json_encode($output);
}
?>
So how I can figure out to generate different flag status output such as "00" for "success" case and "01" for "Invalid TransactionID" case, "Invalid Signature" case, & "Double Payment" case after payment completed?
For reproduce please checkout my demo or you can try buy one product on my development website with BCA Sakuku as payment option.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire