Skip to content
This repository was archived by the owner on Nov 2, 2022. It is now read-only.

Commit 3cd751d

Browse files
committed
integrasjon av kredittkorttype
1 parent 74cb24f commit 3cd751d

File tree

3 files changed

+35
-13
lines changed

3 files changed

+35
-13
lines changed

GFDibsDao.php

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
add_action( 'init', array('GFDibsDao', 'updateDb') );
3+
// add_action( 'init', array('GFDibsDao', 'updateDb') );
44
class GFDibsDao {
55
protected $dibs_table_name;
66
protected $gf_table_name;
@@ -52,7 +52,7 @@ function createTransaction( $post ){
5252
$this->log('POST variables');
5353
$this->log($post);
5454

55-
$this->db->insert(
55+
$this->db->insert(
5656
$this->gf_table_name,
5757
array(
5858
'order_id' => $post['orderId'],
@@ -86,18 +86,29 @@ function updateTransaction( $post ){
8686
$transaction_id = $post['transact'];
8787
}
8888

89+
$paytype = null;
90+
if ( isset($post['cardnomask']) ){
91+
$paytype = $post['cardnomask'];
92+
93+
if ( isset($post['paytype']) ){
94+
$paytype .= ' ('.$post['paytype'].')';
95+
}
96+
}
97+
8998
$this->db->update(
9099
$this->gf_table_name,
91100
array(
92101
'completed' => 1,
93102
'transaction_id' => $transaction_id,
94103
'ticket' => ( isset($post['ticket']) ) ? $post['ticket'] : false,
104+
'paytype' => $paytype,
95105
),
96106
array( 'order_id' => $post['orderId'] ),
97107
array(
98108
'%d',
99109
'%s',
100-
'%s'
110+
'%s',
111+
'%s',
101112
)
102113
);
103114
}
@@ -218,6 +229,7 @@ function setupTables(){
218229
`completed` int(1) DEFAULT NULL,
219230
`transaction_id` varchar(50) DEFAULT NULL,
220231
`payment_type` varchar(50) DEFAULT NULL,
232+
`paytype` varchar(50) DEFAULT NULL,
221233
`test` int(1) DEFAULT NULL,
222234
`amount` int(10) DEFAULT NULL,
223235
`date_created` datetime DEFAULT NULL,
@@ -229,10 +241,21 @@ function setupTables(){
229241

230242
$wpdb->query($sql);
231243

232-
// error_log($sql);
244+
245+
try{
246+
// update $transaction_table
247+
$sql = sprintf( "SHOW COLUMNS FROM %s LIKE 'paytype'; ", $transaction_table);
248+
$has_column = $wpdb->query($sql);
249+
if ( !$has_column ){
250+
$sql = sprintf("ALTER TABLE %s ADD paytype varchar(40) DEFAULT NULL", $transaction_table ) ;
251+
$wpdb->query($sql);
252+
}
253+
}
254+
catch(Excecption $e){}
233255

234256
}
235257

258+
236259
function setDateCompleted($lead_id){
237260
$sql = sprintf('UPDATE %s SET date_completed="%s" where lead_id=%d', $this->gf_table_name, date('Y-m-d H:i:s'), $lead_id );
238261
error_log($sql);

GFDibsHook.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,6 @@ public static function updateLeadAfterPayment(){
487487
$Dao->updateTransaction($_POST);
488488

489489
// send confirmation mails
490-
_log('confm');
491-
_log($order_id);
492490
if ( $Transaction = $Dao->getTransactionByOrderId($order_id) ){
493491
_log($Transaction);
494492
/* prod */
@@ -587,10 +585,10 @@ public static function addPaymentDetails($form, $lead){
587585
<th scope="col" class="width_15"><?php _e('Date', DIBS_LANG);?></th>
588586
<th scope="col" class="width_15"><?php _e('Transaction id', DIBS_LANG);?></th>
589587
<th scope="col" class="width_15"><?php _e('Ticket', DIBS_LANG);?></th>
590-
<th scope="col" class="width_20"><?php _e('Payment Type', DIBS_LANG);?></th>
591-
588+
<th scope="col" class="width_10"><?php _e('Payment Type', DIBS_LANG);?></th>
592589
<th scope="col" class="width_10"><?php _e('Completed' , DIBS_LANG);?></th>
593590
<th scope="col" class="width_5"><?php _e('Amount', DIBS_LANG);?></th>
591+
<th scope="col" class="width_15"><?php _e('Credit card', DIBS_LANG);?></th>
594592
<th scope="col" class="width_5"><?php _e('Test', DIBS_LANG);?></th>
595593
</thead>
596594

@@ -602,6 +600,7 @@ public static function addPaymentDetails($form, $lead){
602600
<td ><?php echo $Transaction->payment_type; ?></td>
603601
<td><?php echo ( ($Transaction->completed) ? __('yes', DIBS_LANG) : __('no', DIBS_LANG) ); ?></td>
604602
<td><?php echo ($Transaction->amount/100); ?> <?php echo get_option('rg_gforms_currency');?></td>
603+
<td><?php echo ( ($Transaction->paytype) ? $Transaction->paytype : '' ); ?></td>
605604
<td><?php echo ( ($Transaction->test) ? __('yes', DIBS_LANG) : __('no', DIBS_LANG) ); ?></td>
606605
</tr>
607606
</tbody>

GFDibsUpdater.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class GFDibsUpdater{
1515

1616
function __construct($plugin_file ){
1717
$this->PluginFile = $plugin_file;
18+
1819
add_filter( "plugins_api", array( $this, "setPluginInfo" ), 10, 3 );
1920
add_filter( "pre_set_site_transient_update_plugins", array( $this, "setTransitent" ), 1 );
2021
add_action( 'admin_notices', array($this, 'getLicenceKeyInfo') );
@@ -24,7 +25,7 @@ function __construct($plugin_file ){
2425

2526

2627
function afterUpdate( $true, $hook_extra, $result ){
27-
_debug('after update');
28+
// _log('after update');
2829
global $wp_filesystem;
2930
//$this->getCurrentVersionInfo();
3031

@@ -85,7 +86,6 @@ function setTransitent( $transient ){
8586

8687
if( isset($transient->response) ){
8788
if ( !isset($transient->response[$this->Plugin]) ){
88-
// _debug('if');
8989

9090
$current_tag = $this->updateAvailable();
9191
// _debug($current_tag);
@@ -183,7 +183,7 @@ function getReleaseInfo(){
183183
$query_vars = array( 'plugin' => $this->Slug );
184184
$url = self::buildUrl('releases', $query_vars);
185185

186-
_debug($url);
186+
_log($url);
187187
$response = wp_remote_retrieve_body(wp_remote_get( $url ));
188188

189189
return $response;
@@ -221,7 +221,7 @@ function checkLicenceKey(){
221221

222222
$url = self::buildUrl('licence', $query_vars);
223223

224-
_debug($url);
224+
// _log($url);
225225
$response = wp_remote_retrieve_body(wp_remote_get( $url ));
226226

227227
return $response;
@@ -235,7 +235,7 @@ function registerPlugin($plugin = null, $network_activation = null ){
235235
);
236236

237237
$url = self::buildUrl('activation', $query_vars);
238-
_debug($url);
238+
// _log($url);
239239
wp_remote_get( $url );
240240
}
241241

0 commit comments

Comments
 (0)