han_paysubscriptions.php
来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 1,216 行 · 第 1/4 页
PHP
1,216 行
//-------------------------------------- else { if ( $this->results['currency_code'] != $pay_method['submethod_use_currency'] ) { $this->do_log("{$this->class_gateway->i_am}: Tried to return validate but failed: Wrong currency ($this->results['currency_code'])"); } if ( $this->results['payment_status'] == 'RECURRING' ) { $this->_process_recurring( $pay_method ); } else if ( $this->results['payment_status'] == 'ONEOFF' ) { $this->_process_normal( $pay_method ); } } $this->class_gateway->core_print_status_message(); exit(); } /*-------------------------------------------------------------------------*/ // Process normal upgrade /*-------------------------------------------------------------------------*/ function _process_normal_upgrade( $pay_method ) { //-------------------------------------- // SUBSCRIPTION //-------------------------------------- $balance = ( $this->new_sub['sub_cost'] * $this->all_currency[ $pay_method['submethod_use_currency'] ]['subcurrency_exchange'] ) - $this->cur_details['subtrans_paid']; $this->new_sub['sub_cost'] = $this->new_sub['sub_cost'] * $this->all_currency[ $pay_method['submethod_use_currency'] ]['subcurrency_exchange']; $results = $this->class_gateway->gw_do_normal_payment_check( sprintf( "%.2f", $balance ), sprintf( "%.2f", $this->new_sub['sub_cost'] ), $this->cur_details['subtrans_id'] ); if ( $this->class_gateway->error ) { //-------------------------------------- // Log and exit //-------------------------------------- $this->do_log( "{$this->class_gateway->i_am}: ".$this->class_gateway->error ); exit(); } //-------------------------------------- // Update subscription //-------------------------------------- $this->update['subtrans_paid'] = $results['amount_paid'] * $this->def_currency['subcurrency_exchange']; $this->update['subtrans_trxid'] = $this->results['transaction_id']; $this->update['subtrans_sub_id'] = $this->new_sub['sub_id']; $this->update['subtrans_subscrid'] = $this->results['subscription_id']; $this->update['subtrans_state'] = strtolower( $results['state'] ); //-------------------------------------- // Deal with lifetime subs //-------------------------------------- if ( $this->new_sub['sub_unit'] == 'x' ) { $this->update['subtrans_end_date'] = 9999999999; } //-------------------------------------- // Update DB //-------------------------------------- if ( $this->update['subtrans_paid'] > 0.00 ) { $this->update['subtrans_cumulative'] = $this->cur_details['subtrans_cumulative'] + $this->update['subtrans_paid']; } $this->ipsclass->DB->do_update( 'subscription_trans', $this->update, "subtrans_id=".$this->cur_details['subtrans_id'] ); //-------------------------------------- // UPDATE MEMBER //-------------------------------------- if ( $this->update['subtrans_state'] == 'paid' ) { $this->do_paid_member($this->new_sub, $this->member, $this->cur_details['subtrans_id']); } else { $this->do_failed_member($this->new_sub, $this->member, $this->cur_details['subtrans_id']); } $this->do_log("{$this->class_gateway->i_am}: Subscription upgrade (one off payment). Set trans_id {$this->cur_details['subtrans_id']} to {$this->update['subtrans_state']}, paid {$this->update['subtrans_paid']}"); } /*-------------------------------------------------------------------------*/ // Process recurring upgrade /*-------------------------------------------------------------------------*/ function _process_recurring_upgrade( $pay_method ) { //-------------------------------------- // SUBSCRIPTION //-------------------------------------- $balance = ( $this->new_sub['sub_cost'] * $this->all_currency[ $pay_method['submethod_use_currency'] ]['subcurrency_exchange'] ) - $this->cur_details['subtrans_paid']; $this->new_sub['sub_cost'] = $this->new_sub['sub_cost'] * $this->all_currency[ $pay_method['submethod_use_currency'] ]['subcurrency_exchange']; $results = $this->class_gateway->gw_do_recurring_payment_check( sprintf( "%.2f", $balance ), sprintf( "%.2f", $this->new_sub['sub_cost'] ) ); if ( $this->class_gateway->error ) { //-------------------------------------- // Log and exit //-------------------------------------- $this->do_log( "{$this->class_gateway->i_am}: ".$this->class_gateway->error ); exit(); } //-------------------------------------- // Update subscription //-------------------------------------- $this->update['subtrans_paid'] = $results['amount_paid'] * $this->def_currency['subcurrency_exchange']; $this->update['subtrans_trxid'] = $this->results['transaction_id']; $this->update['subtrans_sub_id'] = $this->new_sub['sub_id']; $this->update['subtrans_subscrid'] = $this->results['subscription_id']; $this->update['subtrans_state'] = strtolower( $results['state'] ); //-------------------------------------- // Deal with lifetime subs //-------------------------------------- if ( $this->new_sub['sub_unit'] == 'x' ) { $this->update['subtrans_end_date'] = 9999999999; } //-------------------------------------- // Update DB //-------------------------------------- if ( $this->update['subtrans_paid'] > 0.00 ) { $this->update['subtrans_cumulative'] = $this->cur_details['subtrans_cumulative'] + $this->update['subtrans_paid']; } $this->ipsclass->DB->do_update( 'subscription_trans', $this->update, "subtrans_id=".$this->cur_details['subtrans_id'] ); //-------------------------------------- // UPDATE MEMBERS //-------------------------------------- if ( $this->update['subtrans_state'] == 'paid' ) { $this->do_paid_member($this->new_sub, $this->member, $this->cur_details['subtrans_id']); } else { $this->do_failed_member($this->new_sub, $this->member, $this->cur_details['subtrans_id']); } $this->do_log("{$this->class_gateway->i_am}: Subscription upgrade. Set trans_id {$this->cur_details['subtrans_id']} to {$this->update['subtrans_state']}, paid {$this->update['subtrans_paid']}"); } /*-------------------------------------------------------------------------*/ // Process normal NON UPGRADE /*-------------------------------------------------------------------------*/ function _process_normal( $pay_method ) { //-------------------------------------- // SUBSCRIPTION //-------------------------------------- $balance = ( $this->new_sub['sub_cost'] * $this->all_currency[ $pay_method['submethod_use_currency'] ]['subcurrency_exchange'] ) - $this->cur_details['subtrans_paid']; $this->new_sub['sub_cost'] = $this->new_sub['sub_cost'] * $this->all_currency[ $pay_method['submethod_use_currency'] ]['subcurrency_exchange']; $results = $this->class_gateway->gw_do_normal_payment_check( sprintf( "%.2f", $balance ), sprintf( "%.2f", $this->new_sub['sub_cost'] ), $this->cur_details['subtrans_id'] ); if ( $this->class_gateway->error ) { //-------------------------------------- // Log and exit //-------------------------------------- $this->do_log( "{$this->class_gateway->i_am}: ".$this->class_gateway->error ); exit(); } //-------------------------------------- // Update subscription //-------------------------------------- $this->update['subtrans_paid'] = $results['amount_paid'] * $this->def_currency['subcurrency_exchange']; $this->update['subtrans_trxid'] = $this->results['transaction_id']; $this->update['subtrans_sub_id'] = $this->new_sub['sub_id']; $this->update['subtrans_subscrid'] = $this->results['subscription_id']; $this->update['subtrans_state'] = strtolower( $results['state'] ); $this->update['subtrans_cumulative'] = $this->update['subtrans_paid']; $this->update['subtrans_member_id'] = $this->member['id']; $this->update['subtrans_old_group'] = $this->member['mgroup']; $this->update['subtrans_start_date'] = time(); //-------------------------------------- // Deal with lifetime subs //-------------------------------------- if ( $this->new_sub['sub_unit'] == 'x' ) { $this->update['subtrans_end_date'] = 9999999999; } else { $this->update['subtrans_end_date'] = time() + ( $this->new_sub['sub_length'] * $this->day_to_seconds[ $this->new_sub['sub_unit'] ] ); } //-------------------------------------- // Just updating a subscription //-------------------------------------- if ( $this->results['current_package_id'] ) { $subid = $this->ipsclass->DB->build_and_exec_query( array( 'select' => '*', 'from' => 'subscription_trans', 'where' => "subtrans_sub_id={$this->new_sub['sub_id']} and subtrans_state='pending'" ) ); if ( $subid['subtrans_id'] ) { //-------------------------------------- // Okay, existing subscription we're updating, so... //-------------------------------------- unset($this->update['subtrans_start_date']); unset($this->update['subtrans_end_date']); unset($this->update['subtrans_old_group']); unset($this->update['subtrans_cumulative']); $this->ipsclass->DB->do_update( 'subscription_trans', $this->update, "subtrans_subscrid='".addslashes($this->update['subtrans_subscrid'])."'" ); } } else { $this->ipsclass->DB->do_insert( 'subscription_trans', $this->update ); $newid = $this->ipsclass->DB->get_insert_id(); //-------------------------------------- // Mark all old subs as dead //-------------------------------------- $this->ipsclass->DB->do_update( 'subscription_trans', array( 'subtrans_state' => 'dead' ), "subtrans_state='paid' AND subtrans_member_id={$this->member['id']} AND subtrans_id != $newid" ); } //-------------------------------------- // UPDATE MEMBERS //-------------------------------------- if ( $this->update['subtrans_state'] == 'paid' ) { $this->do_paid_member($this->new_sub, $this->member, $subid['subtrans_id']); $this->do_log("{$this->class_gateway->i_am}: Subscription started (non recurring). Set trans_id {$this->cur_details['subtrans_id']} to {$this->update['subtrans_state']}, paid {$this->update['subtrans_paid']}"); } else { $this->do_failed_member($this->new_sub, $this->member, $subid['subtrans_id']); $this->do_log("{$this->class_gateway->i_am}: Subscription FAILED (not set to pod) (non recurring). Set trans_id {$this->cur_details['subtrans_id']} to {$this->update['subtrans_state']}, paid {$this->update['subtrans_paid']}"); } } /*-------------------------------------------------------------------------*/ // Process recurring NON UPGRADE /*-------------------------------------------------------------------------*/ function _process_recurring( $pay_method ) { //-------------------------------------- // SUBSCRIPTION //-------------------------------------- $balance = ( $this->new_sub['sub_cost'] * $this->all_currency[ $pay_method['submethod_use_currency'] ]['subcurrency_exchange'] ) - $this->cur_details['subtrans_paid']; $this->new_sub['sub_cost'] = $this->new_sub['sub_cost'] * $this->all_currency[ $pay_method['submethod_use_currency'] ]['subcurrency_exchange']; $results = $this->class_gateway->gw_do_recurring_payment_check( sprintf( "%.2f", $balance ), sprintf( "%.2f", $this->new_sub['sub_cost'] ) ); if ( $this->class_gateway->error ) { //-------------------------------------- // Log and exit //-------------------------------------- $this->do_log( "{$this->class_gateway->i_am}: ".$this->class_gateway->error ); exit(); } //-------------------------------------- // Update subscription //-------------------------------------- $this->update['subtrans_paid'] = $results['amount_paid'] * $this->def_currency['subcurrency_exchange']; $this->update['subtrans_trxid'] = $this->results['transaction_id']; $this->update['subtrans_sub_id'] = $this->new_sub['sub_id']; $this->update['subtrans_subscrid'] = $this->results['subscription_id']; $this->update['subtrans_state'] = strtolower( $results['state'] ); $this->update['subtrans_cumulative'] = $this->update['subtrans_paid'];
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?