Results 1 to 2 of 2

Thread: How to install a new payment gateway ?

  1. #1
    Thread Starter
    denism974's Avatar
    Join Date
    Aug 2013
    Location
    Reunion
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to install a new payment gateway ?

    I would like to install the french gateway payment Bluepaid to Jobroller 1.7.1
    I have the php file of bluepaid.
    Someone will have an idea of ​​how to integrate? and what file I need to change?

    Thanks for your help

    Code:
    <?php
    
    $nzshpcrt_gateways[$num] = array(
    	'name'                   => __( 'Bluepaid - Encaissement sécurisé par carte bancaire', 'wpsc' ),
    	'display_name'			 => __( 'Bluepaid, l\'encaissement par carte bancaire', 'wpsc' ),
    	'image' => WPSC_URL . '/images/cc.gif',
    	'requirements'           => array(
    		'php_version'        => 4.3,    
    		'extra_modules'      => array() 
    	),
    	'form'                   => 'form_bluepaid_standard',
    	'submit_function'        => 'submit_bluepaid_standard',
    	'function'       		 => 'gateway_bluepaid_standard',
    	'internalname'           => 'bluepaid_standard', 
    	'payment_type'           => 'bluepaid',
    	'supported_currencies'   => array(
    		'currency_list'      => array( 'AUD', 'BRL', 'CAD', 'CHF', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'ILS', 'JPY', 'MXN', 'MYR', 'NOK', 'NZD', 'PHP', 'PLN', 'SEK', 'SGD', 'THB', 'TWD', 'USD' ),
    		'option_name'        => 'bluepaid_curcode'
    	)
    );
    
    
    
    
    function gateway_bluepaid_standard($seperator, $sessionid) {
        global $wpdb, $wpsc_cart;
    
        $purchase_log = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `sessionid`= ".$sessionid." LIMIT 1",ARRAY_A) ;
    
        if ($purchase_log['totalprice']==0) {
            header("Location: ".get_option('transact_url').$seperator."sessionid=".$sessionid);
            exit();
        }
    
        $cart_sql = "SELECT * FROM `".WPSC_TABLE_CART_CONTENTS."` WHERE `purchaseid`='".$purchase_log['id']."'";
        $cart = $wpdb->get_results($cart_sql,ARRAY_A) ;
    		
    	$gateway = get_option('bluepaid_gateway');
    	if ( $gateway == 'bluepaid' ){
    		$gateway_url = "https://www.bluepaid.com/in.php";
    	}else if ( $gateway == 'bluepaid_new' ){
    		$gateway_url = "https://paiement-securise.bluepaid.com/in.php";
    	}else{
    		$gateway_url = "https://test-paiement-securise.bluepaid.com/in.php";
    	}
    
        $transact_url = $gateway_url;
        $data['id_boutique'] = get_option('bluepaid_standard_siteid');
    	
    	$tmp_url=get_option('bluepaid_return_url');
    	$tmp_url=str_replace('https://', '', $tmp_url);
    	$tmp_url=str_replace('http://', '', $tmp_url);
        $data['url_retour_ok'] = $tmp_url;
    	
        $data['url_retour_bo'] = $tmp_url;
    	
    	$tmp_url=get_option('bluepaid_return_stop');
    	$tmp_url=str_replace('https://', '', $tmp_url);
    	$tmp_url=str_replace('http://', '', $tmp_url);
        $data['url_retour_stop'] = $tmp_url;
    	//$data['url_retour_bo'] = get_option('siteurl')."/?bluepaid_callback=true";
    	
    	
        $data['test'] = get_option('bluepaid_test');
        $data['debug'] = get_option('bluepaid_debug');
    
        $currency_code = $wpdb->get_results("SELECT `code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`='".get_option('currency_type')."' LIMIT 1",ARRAY_A);
        $local_currency_code = $currency_code[0]['code'];
        $psc_currency_code = get_option('bluepaid_curcode');
    
        if($psc_currency_code == '') {
            $psc_currency_code = 'EUR';
        }
    
        $user_data = $wpdb->get_results("SELECT `user_email`, `ID`, `display_name` FROM `wp_users` WHERE `ID` = '".$purchase_log['user_ID']."' LIMIT 1",ARRAY_A);
    
        $shipping 		= $wpsc_cart->calculate_total_shipping();
        $discounts		= $wpsc_cart->coupons_amount;
        $total		= $wpsc_cart->calculate_total_price();
    
        $data['devise']	= $psc_currency_code;
        $data['montant']	= number_format(sprintf("%01.2f",($total + $shipping - $discounts)),2,'.','');
        $data['divers']	= base64_encode('invoice='.$sessionid);
        $data['id_client']	= $user_data[0]['ID'];
        $data['email_client']	= $user_data[0]['user_email'];
        $data['langue']	= 'FR';
    
    
        $data = apply_filters('wpsc_psc_standard_post_data',$data);
    
        $output  = "<p>You will be redirected to Bluepaid.com in a few seconds.</p>";
        $output .= "<form name='bluepaid_backoffice' action='{$transact_url}' method='POST'>";
        foreach($data as $key=>$value) {
            $output .= "<input type='hidden' name='{$key}' value='{$value}' />\n";
        }
        $output .= "<input type='submit' name='bluepaid_submit' value='...or do it manually' /></form>";
        $output .='<script type="text/javascript">document.bluepaid_backoffice.submit();</script>';
        echo $output;
    	$wpsc_cart->empty_cart();
        exit();
    }
    
    function zbaz_bluepaid_backoffice() {
        global $wpdb;
    	
        if(isset($_POST['etat']) && isset($_POST['divers'])) {	
    	parse_str(base64_decode($_POST['divers']));
    
    	$sessionid = $invoice;
    	$transaction_id = $_POST['id_trans'];
    	$amount = $_POST['montant_org'];
    	$payer_email = $_POST['email'];
    	$etat = isset($_POST['etat'])?$_POST['etat']:'ko';
    	$etat=strtolower($etat);
    	$mode = isset($_POST['mode'])?$_POST['mode']:'';
    
    	if($etat == 'ok'){
    		switch($mode) {
    			case 'test':
    				##transaction test ##no update
    				break;
    			case '':
    				$wpdb->query("UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET `transactid` = '".$transaction_id."', `date` = '".time()."', `processed` = '3' WHERE `sessionid` = ".$sessionid." LIMIT 1");
    				transaction_results($sessionid, false, $transaction_id);
    				break;
    			case 'r':
    				##refund
    				break;
    				
    			default:
    				$wpdb->query("UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET `transactid` = '".$transaction_id."', `date` = '".time()."'  WHERE `sessionid` = ".$sessionid." LIMIT 1");
    				break;
    		}
    	} else {
    		if($etat == 'ko'){
    			$wpdb->query("UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET `transactid` = '".$transaction_id."', `processed` = '6', `date` = '".time()."'  WHERE `sessionid` = ".$sessionid." LIMIT 1");
    		}else{
    			##payment in attempt
    		}
    	}
    	exit();
        }
    }
    function zbaz_bluepaid_callback() {
    	/*
    	if(isset($_GET['bluepaid_callback'])){
    		global $wpdb;
    		
    		if(isset($_POST['etat']) && isset($_POST['divers'])) {	
    		parse_str(base64_decode($_POST['divers']));
    	
    		$sessionid = $invoice;
    		$transaction_id = $_POST['id_trans'];
    		$amount = $_POST['montant_org'];
    		$payer_email = $_POST['email'];
    		$etat = isset($_POST['etat'])?$_POST['etat']:'ko';
    		$etat=strtolower($etat);
    		$mode = isset($_POST['mode'])?$_POST['mode']:'';
    	
    		if($etat == 'ok'){
    			switch($mode) {
    				case 'test':
    					##transaction test ##no update
    					$wpdb->query("UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET `transactid` = '".$transaction_id."', `date` = '".time()."', `processed` = '3' WHERE `sessionid` = ".$sessionid." LIMIT 1");
    					transaction_results($sessionid, false, $transaction_id);
    					break;
    				case '':
    					$wpdb->query("UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET `transactid` = '".$transaction_id."', `date` = '".time()."', `processed` = '3' WHERE `sessionid` = ".$sessionid." LIMIT 1");
    					transaction_results($sessionid, false, $transaction_id);
    					$wpsc_cart->empty_cart();
    					break;
    				case 'r':
    					##refund
    					break;
    					
    				default:
    					$wpdb->query("UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET `transactid` = '".$transaction_id."', `date` = '".time()."'  WHERE `sessionid` = ".$sessionid." LIMIT 1");
    					break;
    			}
    		} else {
    			if($etat == 'ko'){
    				$wpdb->query("UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET `transactid` = '".$transaction_id."', `processed` = '6', `date` = '".time()."'  WHERE `sessionid` = ".$sessionid." LIMIT 1");
    			}else{
    				##payment in attempt
    			}
    		}
    		exit();
    		}
    	}*/
    }
    
    function submit_bluepaid_standard(){
    
        if($_POST['bluepaid_standard_siteid'] != null) {
            update_option('bluepaid_standard_siteid', $_POST['bluepaid_standard_siteid']);
        }
    	
        if($_POST['bluepaid_return_url'] != null) {
            update_option('bluepaid_return_url', $_POST['bluepaid_return_url']);
        }
    	
        if($_POST['bluepaid_return_stop'] != null) {
            update_option('bluepaid_return_stop', $_POST['bluepaid_return_stop']);
        }		
    
        if($_POST['bluepaid_gateway'] != null) {
            update_option('bluepaid_gateway', $_POST['bluepaid_gateway']);
        }
        return true;
    }
    
    function form_bluepaid_standard() {
      global $wpdb, $wpsc_gateways;
      $tmp_returned_url=get_option( 'bluepaid_return_url' );
      $tmp_return_stop=get_option( 'bluepaid_return_stop' );
      
      
      $output = "
    	<tr>
    		<td>Plateforme :</td>
    		<td>
    			<select name='bluepaid_gateway'>
    				<option value='bluepaid'" . ( get_option( 'bluepaid_gateway' ) == 'bluepaid' ? ' selected="selected"' : '' ) . ">Bluepaid</option>
    			</select>
    		</td>
    	</tr>
    	<tr>
          <td>Identifiant de compte :
          </td>
          <td>
          <input type='text' size='6' value='".get_option('bluepaid_standard_siteid')."' name='bluepaid_standard_siteid' />
          </td>
      </tr>
    	<tr>
          <td>Url de retour
          </td>
          <td>
           <select name='bluepaid_return_url'> 
    			<option value=''>".attribute_escape(__('Choisir une page'))."</option>"; 
    			// Tableau d'arguments pour personalisé la liste des pages
    			$args = array(
    				'sort_order' => 'ASC', // ordre
    				'sort_column' => 'post_title', // par titre (post_date = par date ,post_modified = dernière modification, post_author = Par auteur)
    				'hierarchical' => 1, // Hiérarchie des sous pages
    				'exclude' => '', // page a exclure avec leurs ID ex: (2,147)
    				'include' => '', // page a inclure avec leurs ID (5,10)
    				'meta_key' => '',  // Inclure uniquement les pages qui ont cette clé des champs personnalisés
    				'meta_value' => '', // Inclure uniquement les pages qui ont cette valeur de champ personnalisé
    				'authors' => '', // Inclure uniquement les pages écrites par l'auteur(ID)
    				'child_of' => 0, // niveau des sous-pages
    				'parent' => -1, // Affiche les pages qui ont cet ID en tant que parent. La valeur par défaut -1 
    				'exclude_tree' => '', // Le contraire de «child_of», «exclude_tree 'supprimera tous les sous pages par ID.
    				'number' => '', // Défini le nombre de pages à afficher
    				'offset' => 0, //  nombre de pages à passer au-dessus
    				'post_type' => 'page', // post type
    				'post_status' => 'publish' // publish = Publier, private = page privé
    			); 
    		
    		  $pages = get_pages($args); 
    		  foreach ($pages as $pagg) {
    			  $select_opt='';
    			  if($tmp_returned_url==get_page_link($pagg->ID))$select_opt='selected="selected"';
    			  
    			  $option = '<option '.$select_opt.' value="'.get_page_link($pagg->ID).'">';
    			  $option .= $pagg->post_title;
    			  $option .= '</option>';
    			  $output .=$option;
    		  }
    		$output .="</select>";
          $output .="</td>
      </tr> 
    	<tr>
          <td>Url de retour sans validation
          </td>
          <td>
           <select name='bluepaid_return_stop'> 
    			<option value=''>".attribute_escape(__('Choisir une page'))."</option>"; 
    			$args = array(
    				'sort_order' => 'ASC', // ordre
    				'sort_column' => 'post_title', // par titre (post_date = par date ,post_modified = dernière modification, post_author = Par auteur)
    				'hierarchical' => 1, // Hiérarchie des sous pages
    				'exclude' => '', // page a exclure avec leurs ID ex: (2,147)
    				'include' => '', // page a inclure avec leurs ID (5,10)
    				'meta_key' => '',  // Inclure uniquement les pages qui ont cette clé des champs personnalisés
    				'meta_value' => '', // Inclure uniquement les pages qui ont cette valeur de champ personnalisé
    				'authors' => '', // Inclure uniquement les pages écrites par l'auteur(ID)
    				'child_of' => 0, // niveau des sous-pages
    				'parent' => -1, // Affiche les pages qui ont cet ID en tant que parent. La valeur par défaut -1 
    				'exclude_tree' => '', // Le contraire de «child_of», «exclude_tree 'supprimera tous les sous pages par ID.
    				'number' => '', // Défini le nombre de pages à afficher
    				'offset' => 0, //  nombre de pages à passer au-dessus
    				'post_type' => 'page', // post type
    				'post_status' => 'publish' // publish = Publier, private = page privé
    			); 
    		
    		  $pages = get_pages($args); 
    		  foreach ($pages as $pagg) {
    			  $select_opt='';
    			  if($tmp_return_stop==get_page_link($pagg->ID))$select_opt='selected="selected"';
    			  
    			  $option = '<option '.$select_opt.' value="'.get_page_link($pagg->ID).'">';
    			  $option .= $pagg->post_title;
    			  $option .= '</option>';
    			  $output .=$option;
    		  }
    		$output .="</select>";
          $output .="</td>
      </tr> ";
      
    
    
      return $output;
    }
    
    
    add_action('init', 'zbaz_bluepaid_callback');
    add_action('init', 'zbaz_bluepaid_backoffice');
    ?>

  2. #2
    jomarkosabel's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    40,981
    Thanks
    170
    Thanked 3,408 Times in 3,279 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!
    Please help our moderating team work more efficiently by not sending us support questions via PM. You can read more about how AppThemes support works here. However, you can send a PM to follow up and remind me if I missed your support request/thread.

    Thank you and have a nice day.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Samcy payment gateway
    By gatochato in forum Report ClassiPress Bugs
    Replies: 6
    Last Post: February 11th, 2014, 01:51 AM
  2. [SOLVED] Payment Gateway First?
    By puckett in forum Help Using Vantage (Legacy)
    Replies: 3
    Last Post: July 24th, 2013, 02:22 PM