Integration 电子商务支付网关集成
最新版本的woocommerce支付网关集成有问题。 我最近开始为一个朋友使用woocommerce,他的woocommerce版本是1.6.5.2。但现在他将他的woocommerce更新到了最新版本(2.0.12)。 他有一些定制的支付网关,可以在1.6版本上工作,但现在不行了。 这是自定义支付网关代码:Integration 电子商务支付网关集成,integration,payment-gateway,woocommerce,Integration,Payment Gateway,Woocommerce,最新版本的woocommerce支付网关集成有问题。 我最近开始为一个朋友使用woocommerce,他的woocommerce版本是1.6.5.2。但现在他将他的woocommerce更新到了最新版本(2.0.12)。 他有一些定制的支付网关,可以在1.6版本上工作,但现在不行了。 这是自定义支付网关代码: /* Plugin Name ...... .../* $post_perma = trim( esc_url ( $_SERVER['REQUEST_URI'] ), '/' ); ad
/*
Plugin Name ......
.../*
$post_perma = trim( esc_url ( $_SERVER['REQUEST_URI'] ), '/' );
add_action('plugins_loaded', 'woocommerce_rba_etomitreba_init', 0);
if($post_perma == 'uspjeh'||$post_perma == 'greska') {
add_filter('the_content', 'after_processing');
}
function after_processing() {
global $post, $post_perma, $woocommerce;
if($post_perma == 'uspjeh') {
if(isset($_POST['OrderID'])&&isset($_POST['ApprovalCode'])) {
echo '<div class="notify notify-success">Not Important;)</div>';
$order = new WC_Order( $_POST['OrderID'] );
$order->payment_complete();
$order->status = 'completed';
$woocommerce->cart->empty_cart();
unset($_SESSION['order_awaiting_payment']);
}
else {
echo '<div class="notify notify-error">Not Important</div>';
}
}
if($post_perma == 'greska') {
echo '<div class="notify notify-error">DNot Important</div>';
}
}
function woocommerce_rba_etomitreba_init() {
if ( !class_exists( 'WC_Payment_Gateway' ) ) return;
class WC_Raiffeisen_Bank_eToMiTreba extends WC_Payment_Gateway {
public function __construct() {
$this->id = 'rba_etomitreba';
$this->method_title = __( 'Raiffeisen Bank', 'woocommerce' );
$this->icon = apply_filters('woocommerce_cheque_icon', '');
$this->has_fields = false;
// Load the form fields.
$this->form_fields = array(
'enabled' => array(
'title' => __( 'Not Important', 'woothemes' ),
'type' => 'checkbox',
'label' => __( 'Not Important', 'woothemes' ),
'default' => 'yes'
),
'merchant-id' => array(
'title' => __( 'Not Important', 'woothemes' ),
'type' => 'text',
'description' => __( 'Not Important', 'woothemes' ),
'default' => __( '', 'woothemes' )
),
'terminal-id' => array(
'title' => __( 'Not Important', 'woothemes' ),
'type' => 'text',
'description' => __( 'Not Important', 'woothemes' ),
'default' => __( '', 'woothemes' )
),
'rsa-private-key' => array(
'title' => __( 'Not Important', 'woothemes' ),
'type' => 'textarea',
'description' => __( 'Not Important', 'woothemes' ),
'default' => __( '', 'woothemes' )
),
'title' => array(
'title' => __( 'Not Important', 'woothemes' ),
'type' => 'text',
'description' => __( '', 'woothemes' ),
'default' => __( 'Not Important', 'woothemes' )
),
'description' => array(
'title' => __( 'Not Important', 'woothemes' ),
'type' => 'textarea',
'description' => __( '', 'woothemes' ),
'default' => 'Not Important.'
)
);
// Load the settings.
$this->init_settings();
$this->title = $this->settings['title'];
$this->description = $this->settings['description'];
// Actions
add_action('woocommerce_update_options_payment_gateways', array(&$this, 'process_admin_options'));
}
public function process_payment( $order_id ) {
$order = new WC_Order( $order_id );
$order->shipping_first_name;
$order->shipping_last_name;
$order->get_shipping_address();
$url_gateway = 'Not Important';
$merchant_id = 'xxxxx';
$terminal_id = 'xxxxx';
$total = $order->get_total()*100; // kn to lp conversion
$currency_id = 191;
$time = new DateTime('', new DateTimeZone('Europe/Zagreb'));
$purchase_time = $time->format('ymdHis');
$locale = 'hr';
$ordered_items = $order->get_items();
foreach($ordered_items as $item) {
$ordered_items_array[] = $item['name'];
}
$ordered_items = implode(', ',$ordered_items_array);
$purchase_desc = $time->format('d.m.Y. H:i:s').' - '.$order->shipping_first_name.' '.$order->shipping_last_name.' : '.$ordered_items;
$session_id = session_id();
$data = "$merchant_id;$terminal_id;$purchase_time;$order_id;$currency_id;$total;$session_id;";
$priv_key = $this->settings['rsa-private-key'];
$pkeyid = openssl_get_privatekey($priv_key);
openssl_sign($data, $signature, $pkeyid);
openssl_free_key($pkeyid);
$b64sign = base64_encode($signature);
$signature = $b64sign;
//$order->update_status('on-hold', __('Not Important', 'woothemes'));
echo '
<form name="ordersend" action="'.$url_gateway.'" method="post">
<input name="Version" type="hidden" value="1" >
<input name="MerchantID" type="hidden" value="'.$merchant_id.'" >
<input name="TerminalID" type="hidden" value="'.$terminal_id.'" >
<input name="TotalAmount" type="hidden" value="'.$total.'">
<input name="SD" type="hidden" value="'.$session_id.'">
<input name="Currency" type="hidden" value="'.$currency_id.'" >
<input name="Locale" type="hidden" value="'.$locale.'">
<input name="OrderID" type="hidden" value="'.$order_id.'" >
<input name="PurchaseTime" type="hidden" value="'.$purchase_time.'">
<input name="PurchaseDesc" type="hidden" value="'.$purchase_desc.'" >
<input name="Signature" type="hidden" value="'.$signature.'" >
</form>
<script language="javascript">
<!--
document.forms["ordersend"].submit();
--></script>
';
/*
return array (
'result' => 'success'
);*/
}
public function admin_options() {
?>
<img src="<?php echo 'Not Important ?>" width="664" height="114" />
<h3><?php _e('Not Important', 'woothemes'); ?></h3>
<p><?php _e('Not Important'); ?></p>
<table class="form-table">
<?php
// Generate the HTML For the settings form.
$this->generate_settings_html();
?>
</table>
<?php
} // End admin_options()
}
function woocommerce_raiffeisen_bank_etomitreba_gateway($methods) {
$methods[] = 'WC_Raiffeisen_Bank_eToMiTreba';
return $methods;
}
add_filter('woocommerce_payment_gateways', 'woocommerce_raiffeisen_bank_etomitreba_gateway' );
}
add_action('woocommerce_update_options_payment_gateways', array(&$this, process_admin_options'));
/*
插件名称。。。。。。
.../*
$post_perma=trim(esc_url($_SERVER['REQUEST_URI']),'/');
添加操作('plugins\u loaded','woocommerce\u rba\u etomitreba\u init',0);
如果($post_perma=='uspjeh'.$post_perma=='greska'){
添加_过滤器(“_内容”,“处理后”);
}
_处理后的函数(){
全球$post、$post_perma、$woocommerce;
如果($post_perma=='uspjeh'){
如果(isset($_POST['OrderID'])和&isset($_POST['ApprovalCode'])){
回声“不重要;)”;
$order=新WC_订单($_POST['OrderID']);
$order->payment_complete();
$order->status='completed';
$woocommerce->cart->empty_cart();
未设置($_会话['order_Waiting_payment']);
}
否则{
回声“不重要”;
}
}
如果($post_perma=='greska'){
回声“不重要”;
}
}
函数woocommerce_rba_etomitreba_init(){
如果(!class_存在('WC_支付网关'))返回;
WC_Raiffeisen_银行eToMiTreba扩展WC_支付网关{
公共函数构造(){
$this->id='rba_etomitreba';
$this->method_title=uuu('Raiffeisen Bank','woocommerce');
$this->icon=apply_filters('woocommerce_check_icon','');
$this->has_fields=false;
//加载表单字段。
$this->form_fields=array(
“已启用”=>阵列(
'title'=>uuu('Not Important','woothemes'),
'键入'=>'复选框',
'label'=>\('Not Important','woothemes'),
“默认值”=>“是”
),
“商户id”=>数组(
'title'=>uuu('Not Important','woothemes'),
'类型'=>'文本',
'description'=>\('Not Important','woosethemes'),
'默认值'=>\('''woothemes')
),
'终端id'=>阵列(
'title'=>uuu('Not Important','woothemes'),
'类型'=>'文本',
'description'=>\('Not Important','woosethemes'),
'默认值'=>\('''woothemes')
),
“rsa私钥”=>数组(
'title'=>uuu('Not Important','woothemes'),
'type'=>'textarea',
'description'=>\('Not Important','woosethemes'),
'默认值'=>\('''woothemes')
),
'title'=>数组(
'title'=>uuu('Not Important','woothemes'),
'类型'=>'文本',
'description'=>u uu('woothemes'),
'default'=>\('Not Important','woothemes')
),
'description'=>数组(
'title'=>uuu('Not Important','woothemes'),
'type'=>'textarea',
'description'=>u uu('woothemes'),
“默认值”=>“不重要。”
)
);
//加载设置。
$this->init_settings();
$this->title=$this->settings['title'];
$this->description=$this->settings['description'];
//行动
添加操作('woocmerce\u update\u options\u payment\u gateways',数组(&$this,'process\u admin\u options');
}
公共职能流程\付款($order\ U id){
$order=新WC\U订单($order\U id);
$order->shipping\u first\u name;
$order->shipping\u last\u name;
$order->get_shipping_address();
$url_gateway='不重要';
$merchant_id='xxxxx';
$terminal_id='xxxxx';
$total=$order->get_total()*100;//kn到lp的转换
$currency_id=191;
$time=新日期时间(“”,新日期时区('Europe/Zagreb'));
$purchase_time=$time->format('ymdHis');
$locale='hr';
$ordered_items=$order->get_items();
foreach($ordered_items作为$item){
$ordered_items_array[]=$item['name'];
}
$ordered_items=内爆(“,”,$ordered_items_数组);
$purchase\u desc=$time->format('d.m.Y.H:i:s').-'.$order->shipping\u first\u name'.$order->shipping\u last\u name'.$ordered\u items;
$session_id=session_id();
$data=“$merchant_id;$terminal_id;$purchase_time;$order_id;$currency_id;$total;$session_id;”;
$priv_key=$this->settings['rsa-private-key'];
$pkeyid=openssl_get_privatekey($priv_key);
openssl_-sign($data,$signature,$pkeyid);
openssl免费密钥($pkeyid);
$b64sign=base64_编码($signature);
$signature=$b64sign;
//$order->update_status('on-hold','Not-Important','woothemes');
回声'
';
/*
返回数组(
“结果”=>“成功”
);*/
}
公共功能管理选项(){
?>
“width=“664”height=“114”/>
add_action('woocommerce_update_options_payment_gateways', array(&$this, process_admin_options'));