Ngan luong API PHP Class for input card

    Rating: ★★★★☆
    View: 367
    Download: 226
    Từ khóa:

    Here some important function you can see 

    function card($card_type,$card_pin,$card_serial,$ref_code,$client_email,$client_fullname,&$output = array())
    {
    	$merchant_id 		= $this->card_merchant_id;
    	$merchant_account 	= $this->card_merchant_account;
    	$merchant_password 	= $this->card_merchant_password;
    	$merchant_password 	= md5($merchant_id.'|'.$merchant_password);
    	switch ($card_type)
    	{
    	case 'mobi':
    	{
    	$card_type = 'VMS';
    	break;
    	}
    	case 'vina':
    	{
    	$card_type = 'VNP';
    	break;
    	}
    	case 'viettel':
    	{
    	$card_type = 'VIETTEL';
    	break;
    	}
    	case 'vcoin':
    	{
    	$card_type = 'VCOIN';
    	break;
    	}
    	case 'gate':
    	{
    	$card_type = 'GATE';
    	break;
    	}
    	}
    	$params = array(
    	'func'=>'CardCharge',
    	'version'=>'2.0',
    	'merchant_id'=>$merchant_id,
    	'merchant_account'=>$merchant_account,
    	'merchant_password'=>$merchant_password,
    	'pin_card'=>$card_pin,
    	'card_serial'=>$card_serial,
    	'type_card'=>$card_type,
    	'ref_code'=>$ref_code,
    	'client_fullname'=>$client_fullname,
        'client_email'=>$client_email,
        'client_mobile'=> '01234909949',
    	);
    	$post_field = '';
    		foreach ($params as $key => $value)
    		{
    			if ($post_field != '') 
    			$post_field .= '&';
    			$post_field .= $key."=".$value;
    		}
    
    	$result = $this->post($this->url,$post_field);
    	$api_data = array();
    	$api_result = $this->_nl_check_result($result,$api_data);
    	if ($api_result)
    	{
    	$output['pin_card'] 			 =$api_data['pin_card'];			
    	$output['card_serial'] 		     =$api_data['card_serial'];
    	$output['type_card'] 			 =$api_data['type_card'] ;			
    	$output['ref_code'] 			 =$api_data['ref_code']; 			
    	$output['card_amount'] 		     =$api_data['card_amount']; 		
    	$output['transaction_amount']    =$api_data['transaction_amount']; 
    	$output['transaction_id'] 	     =$api_data['transaction_id'];
    	$output['error_code']            =$api_data['error_code'];
    	$output['client_fullname']       =$api_data['client_fullname'];
    	$output['client_email']          =$api_data['client_email'];
    	$output['client_mobile']         =$api_data['client_mobile'];
    	//$output['data'] 	= $api_data;
    	}
    	else 
    	{
    	$output = $api_data;
    	}
    	return $api_result;
    }

    - How to use: These example code that will show you the way to applay this code

    include("nganluongapi.php");
    $nl = new NganLuong();
    $output = array();
    $card_type = trim($_POST['typecard']);
    $card_pin = trim($_POST['pincard']);
    $card_serial = trim($_POST['serialcard']);
    $_is_client = trim($_POST['emailcard']);
    $client_fullname='fullname of user';
    $ref_code = 'abcd';
    if($nl->card($card_type,$card_pin,$card_serial,$ref_code,$_is_client,$client_fullname,$output))
    {
    		if($nl->card_save($output))
    		{
    		echo "Successful!Thanks you";
    		}
    }
    else
    echo $nl->_nl_get_error($output['error_code']);

     

    loading Đang tải...

    template được ưa chuộng