Last active
August 29, 2015 14:19
-
-
Save pippinsplugins/542ff08a4d1b8aa49140 to your computer and use it in GitHub Desktop.
Restrict Content Pro base gateway class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Payment Gateway Base Class | |
* | |
* @package Restrict Content Pro | |
* @subpackage Classes/Roles | |
* @copyright Copyright (c) 2012, Pippin Williamson | |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License | |
* @since 2.1 | |
*/ | |
class RCP_Payment_Gateway { | |
public $supports = array(); | |
public $email; | |
public $user_id; | |
public $user_name; | |
public $currency; | |
public $amount; | |
public $discount; | |
public $length; | |
public $length_unit; | |
public $signup_fee; | |
public $subscription_key; | |
public $subscription_id; | |
public $subscription_name; | |
public $auto_renew; | |
public $return_url; | |
public $test_mode; | |
public function __construct( $subscription_data = array() ) { | |
$this->init(); | |
if( ! empty( $subscription_data ) ) { | |
$this->email = $subscription_data['user_email']; | |
$this->user_id = $subscription_data['user_id']; | |
$this->user_name = $subscription_data['user_name']; | |
$this->currency = $subscription_data['currency']; | |
$this->amount = $subscription_data['price']; | |
$this->discount = $subscription_data['discount']; | |
$this->discount_code = $subscription_data['discount_code']; | |
$this->length = $subscription_data['length']; | |
$this->length_unit = $subscription_data['length_unit']; | |
$this->signup_fee = $this->supports( 'fees' ) ? $subscription_data['fee'] : 0; | |
$this->subscription_key = $subscription_data['key']; | |
$this->subscription_id = $subscription_data['subscription_id']; | |
$this->subscription_name = $subscription_data['subscription_name']; | |
$this->auto_renew = $this->supports( 'recurring' ) ? $subscription_data['auto_renew'] : false;; | |
$this->return_url = $subscription_data['return_url']; | |
} | |
} | |
public function init() {} | |
public function process_signup() {} | |
public function process_webhooks() {} | |
public function scripts() {} | |
public function fields() {} | |
public function validate_fields() {} | |
public function supports( $item = '' ) { | |
return in_array( $item, $this->supports ); | |
} | |
public function generate_transaction_id() { | |
$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; | |
return strtolower( md5( $this->subscription_key . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'rcp', true ) ) ); | |
} | |
public function renew_member( $recurring = false, $status = 'active' ) { | |
$member = new RCP_Member( $this->user_id ); | |
$member->renew( $recurring, $status ); | |
} | |
private function add_error( $code = '', $message = '' ) { | |
rcp_errors()->add( $code, $message, 'register' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment