| @@ 16-74 (lines=59) @@ | ||
| 13 | /** |
|
| 14 | * Constructor |
|
| 15 | */ |
|
| 16 | public function __construct() { |
|
| 17 | $this->id = 'stripe'; |
|
| 18 | $this->method_title = __( 'Stripe', 'woocommerce-gateway-stripe' ); |
|
| 19 | $this->method_description = __( 'Stripe works by adding credit card fields on the checkout and then sending the details to Stripe for verification.', 'woocommerce-gateway-stripe' ); |
|
| 20 | $this->has_fields = true; |
|
| 21 | $this->view_transaction_url = 'https://dashboard.stripe.com/payments/%s'; |
|
| 22 | $this->supports = array( |
|
| 23 | 'subscriptions', |
|
| 24 | 'products', |
|
| 25 | 'refunds', |
|
| 26 | 'subscription_cancellation', |
|
| 27 | 'subscription_reactivation', |
|
| 28 | 'subscription_suspension', |
|
| 29 | 'subscription_amount_changes', |
|
| 30 | 'subscription_payment_method_change', // Subs 1.n compatibility |
|
| 31 | 'subscription_payment_method_change_customer', |
|
| 32 | 'subscription_payment_method_change_admin', |
|
| 33 | 'subscription_date_changes', |
|
| 34 | 'multiple_subscriptions', |
|
| 35 | 'pre-orders', |
|
| 36 | ); |
|
| 37 | ||
| 38 | // Load the form fields |
|
| 39 | $this->init_form_fields(); |
|
| 40 | ||
| 41 | // Load the settings. |
|
| 42 | $this->init_settings(); |
|
| 43 | ||
| 44 | // Get setting values. |
|
| 45 | $this->title = $this->get_option( 'title' ); |
|
| 46 | $this->description = $this->get_option( 'description' ); |
|
| 47 | $this->enabled = $this->get_option( 'enabled' ); |
|
| 48 | $this->testmode = 'yes' === $this->get_option( 'testmode' ); |
|
| 49 | $this->capture = 'yes' === $this->get_option( 'capture', 'yes' ); |
|
| 50 | $this->stripe_checkout = 'yes' === $this->get_option( 'stripe_checkout' ); |
|
| 51 | $this->stripe_checkout_locale = $this->get_option( 'stripe_checkout_locale' ); |
|
| 52 | $this->stripe_checkout_image = $this->get_option( 'stripe_checkout_image', '' ); |
|
| 53 | $this->saved_cards = 'yes' === $this->get_option( 'saved_cards' ); |
|
| 54 | $this->secret_key = $this->testmode ? $this->get_option( 'test_secret_key' ) : $this->get_option( 'secret_key' ); |
|
| 55 | $this->publishable_key = $this->testmode ? $this->get_option( 'test_publishable_key' ) : $this->get_option( 'publishable_key' ); |
|
| 56 | $this->bitcoin = 'USD' === strtoupper( get_woocommerce_currency() ) && 'yes' === $this->get_option( 'stripe_bitcoin' ); |
|
| 57 | $this->logging = 'yes' === $this->get_option( 'logging' ); |
|
| 58 | ||
| 59 | if ( $this->stripe_checkout ) { |
|
| 60 | $this->order_button_text = __( 'Continue to payment', 'woocommerce-gateway-stripe' ); |
|
| 61 | } |
|
| 62 | ||
| 63 | if ( $this->testmode ) { |
|
| 64 | $this->description .= ' ' . sprintf( __( 'TEST MODE ENABLED. In test mode, you can use the card number 4242424242424242 with any CVC and a valid expiration date or check the documentation "<a href="%s">Testing Stripe</a>" for more card numbers.', 'woocommerce-gateway-stripe' ), 'https://stripe.com/docs/testing' ); |
|
| 65 | $this->description = trim( $this->description ); |
|
| 66 | } |
|
| 67 | ||
| 68 | WC_Stripe_API::set_secret_key( $this->secret_key ); |
|
| 69 | ||
| 70 | // Hooks |
|
| 71 | add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) ); |
|
| 72 | add_action( 'admin_notices', array( $this, 'admin_notices' ) ); |
|
| 73 | add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); |
|
| 74 | } |
|
| 75 | ||
| 76 | /** |
|
| 77 | * get_icon function. |
|
| @@ 86-146 (lines=61) @@ | ||
| 83 | /** |
|
| 84 | * Constructor |
|
| 85 | */ |
|
| 86 | public function __construct() { |
|
| 87 | $this->id = 'stripe'; |
|
| 88 | $this->method_title = __( 'Stripe', 'woocommerce-gateway-stripe' ); |
|
| 89 | $this->method_description = __( 'Stripe works by adding credit card fields on the checkout and then sending the details to Stripe for verification.', 'woocommerce-gateway-stripe' ); |
|
| 90 | $this->has_fields = true; |
|
| 91 | $this->view_transaction_url = 'https://dashboard.stripe.com/payments/%s'; |
|
| 92 | $this->supports = array( |
|
| 93 | 'subscriptions', |
|
| 94 | 'products', |
|
| 95 | 'refunds', |
|
| 96 | 'subscription_cancellation', |
|
| 97 | 'subscription_reactivation', |
|
| 98 | 'subscription_suspension', |
|
| 99 | 'subscription_amount_changes', |
|
| 100 | 'subscription_payment_method_change', // Subs 1.n compatibility. |
|
| 101 | 'subscription_payment_method_change_customer', |
|
| 102 | 'subscription_payment_method_change_admin', |
|
| 103 | 'subscription_date_changes', |
|
| 104 | 'multiple_subscriptions', |
|
| 105 | 'pre-orders', |
|
| 106 | 'tokenization', |
|
| 107 | 'add_payment_method' |
|
| 108 | ); |
|
| 109 | ||
| 110 | // Load the form fields. |
|
| 111 | $this->init_form_fields(); |
|
| 112 | ||
| 113 | // Load the settings. |
|
| 114 | $this->init_settings(); |
|
| 115 | ||
| 116 | // Get setting values. |
|
| 117 | $this->title = $this->get_option( 'title' ); |
|
| 118 | $this->description = $this->get_option( 'description' ); |
|
| 119 | $this->enabled = $this->get_option( 'enabled' ); |
|
| 120 | $this->testmode = 'yes' === $this->get_option( 'testmode' ); |
|
| 121 | $this->capture = 'yes' === $this->get_option( 'capture', 'yes' ); |
|
| 122 | $this->stripe_checkout = 'yes' === $this->get_option( 'stripe_checkout' ); |
|
| 123 | $this->stripe_checkout_locale = $this->get_option( 'stripe_checkout_locale' ); |
|
| 124 | $this->stripe_checkout_image = $this->get_option( 'stripe_checkout_image', '' ); |
|
| 125 | $this->saved_cards = 'yes' === $this->get_option( 'saved_cards' ); |
|
| 126 | $this->secret_key = $this->testmode ? $this->get_option( 'test_secret_key' ) : $this->get_option( 'secret_key' ); |
|
| 127 | $this->publishable_key = $this->testmode ? $this->get_option( 'test_publishable_key' ) : $this->get_option( 'publishable_key' ); |
|
| 128 | $this->bitcoin = 'USD' === strtoupper( get_woocommerce_currency() ) && 'yes' === $this->get_option( 'stripe_bitcoin' ); |
|
| 129 | $this->logging = 'yes' === $this->get_option( 'logging' ); |
|
| 130 | ||
| 131 | if ( $this->stripe_checkout ) { |
|
| 132 | $this->order_button_text = __( 'Continue to payment', 'woocommerce-gateway-stripe' ); |
|
| 133 | } |
|
| 134 | ||
| 135 | if ( $this->testmode ) { |
|
| 136 | $this->description .= ' ' . sprintf( __( 'TEST MODE ENABLED. In test mode, you can use the card number 4242424242424242 with any CVC and a valid expiration date or check the documentation "<a href="%s">Testing Stripe</a>" for more card numbers.', 'woocommerce-gateway-stripe' ), 'https://stripe.com/docs/testing' ); |
|
| 137 | $this->description = trim( $this->description ); |
|
| 138 | } |
|
| 139 | ||
| 140 | WC_Stripe_API::set_secret_key( $this->secret_key ); |
|
| 141 | ||
| 142 | // Hooks. |
|
| 143 | add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) ); |
|
| 144 | add_action( 'admin_notices', array( $this, 'admin_notices' ) ); |
|
| 145 | add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); |
|
| 146 | } |
|
| 147 | ||
| 148 | /** |
|
| 149 | * Get_icon function. |
|