-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathstripe.php
executable file
·88 lines (65 loc) · 2.27 KB
/
stripe.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
/*
Plugin Name: Stripe Payment Gateway for WP eCommerce
Plugin URI: https://wpecommerce.org
Description: Integrate the Stripe Payment Gateway into WP eCommerce.
Version: 2.1
Author: WpeCommerce.org
Author URI: https://wpecommerce.org
*/
defined( 'WPINC' ) || die;
class WPSC_Stripe {
private static $instance;
private function __construct() {}
public static function get_instance() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WPSC_Stripe ) ) {
self::$instance = new WPSC_Stripe;
self::define_constants();
self::includes();
self::add_actions();
self::add_filters();
}
return self::$instance;
}
public static function define_constants() {
define( 'PW_WPSC_PLUGIN_DIR', dirname( __FILE__ ) );
}
public static function includes() {
include_once PW_WPSC_PLUGIN_DIR . '/includes/stripe-functions.php';
include_once PW_WPSC_PLUGIN_DIR . '/includes/checkout-fields.php';
include_once PW_WPSC_PLUGIN_DIR . '/includes/gateway-settings.php';
}
public static function add_actions() {
add_action( 'wpsc_init', array( self::$instance, 'init' ), 2 );
/* Defined in checkout-fields.php */
add_action( 'wpsc_init', 'pw_wpsc_stripe_checkout_fields' );
/* Defined in stripe-functions.php */
add_action( 'wpec_members_deactivate_subscription', 'pw_wpsc_cancel_stripe' );
}
public static function add_filters() {
add_filter( 'wpsc_merchants_modules', array( self::$instance, 'register_gateway' ), 50 );
}
public function init() {
include_once PW_WPSC_PLUGIN_DIR . '/pw_wpsc_stripe_merchant.php';
}
public function register_gateway( $gateways ) {
$num = max( array_keys( $gateways ) ) + 1;
$gateways[ $num ] = array(
'name' => 'Stripe',
'api_version' => 2.0,
'has_recurring_billing' => true,
'display_name' => __( 'Credit Card' ),
'image' => WPSC_URL . '/images/cc.gif',
'wp_admin_cannot_cancel' => false,
'requirements' => array(
'php_version' => 5.0
),
'class_name' => 'pw_wpsc_merchant_stripe',
'form' => 'pw_wpsc_stripe_settings_form',
'submit_function' => 'pw_wpsc_save_stripe_settings',
'internalname' => 'wpsc_stripe'
);
return $gateways;
}
}
add_action( 'wpsc_pre_init', 'WPSC_Stripe::get_instance' );