-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbulletproof-checkout-lite.php
More file actions
151 lines (131 loc) · 6.15 KB
/
Copy pathbulletproof-checkout-lite.php
File metadata and controls
151 lines (131 loc) · 6.15 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php
/**
* Plugin Name: BulletProof Checkout Lite
* Plugin URI: https://www.bulletproof-checkout.com/
* Description: Protect your credit card payments with 3D Secure (3DS) and say goodbye to chargebacks.
* Version: 1.0.26
* Author: BulletProof Checkout <support@bulletproof-checkout.com>
* Author URI: https://www.bulletproof-checkout.com/
* License: GPLv3
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
* Text Domain: bulletproof-checkout-lite
* WC requires at least: 5.0
* WC tested up to: 10.5.3
* Tested up to: 6.9
* Requires PHP: 7.4
* Requires Plugins: woocommerce
*/
if (!defined('ABSPATH')) {
exit;
}
// Define constants for API base URL, gateway identifiers, and response format.
// Please, do not change the constants
// Live Endpoints
if (!defined('BULLETPROOF_CHECKOUT_API_BASE_URL')) define('BULLETPROOF_CHECKOUT_API_BASE_URL', 'https://bulletproofcheckout.net/API/endpoints/directpost/');
if (!defined('BULLETPROOF_CHECKOUT_API_BASE_URL_PAYMENTS')) define('BULLETPROOF_CHECKOUT_API_BASE_URL_PAYMENTS', 'https://bulletproofcheckout.net/API/endpoints/payment/view/');
if (!defined('BULLETPROOF_CHECKOUT_API_BASE_URL_SEARCH')) define('BULLETPROOF_CHECKOUT_API_BASE_URL_SEARCH', 'https://bulletproofcheckout.net/API/endpoints/payment/search/');
// Sandbox Endpoints
if (!defined('BULLETPROOF_CHECKOUT_API_BASE_URL_SANDBOX')) define('BULLETPROOF_CHECKOUT_API_BASE_URL_SANDBOX', 'https://bulletproofcheckout.net/APIsandbox/endpoints/directpost/');
if (!defined('BULLETPROOF_CHECKOUT_API_BASE_URL_SANDBOX_PAYMENTS')) define('BULLETPROOF_CHECKOUT_API_BASE_URL_SANDBOX_PAYMENTS', 'https://bulletproofcheckout.net/APIsandbox/endpoints/payment/view/');
if (!defined('BULLETPROOF_CHECKOUT_API_BASE_URL_SANDBOX_SEARCH')) define('BULLETPROOF_CHECKOUT_API_BASE_URL_SANDBOX_SEARCH', 'https://bulletproofcheckout.net/APIsandbox/endpoints/payment/search/');
if (!defined('BULLETPROOF_CHECKOUT_GATEWAY')) define('BULLETPROOF_CHECKOUT_GATEWAY', 'BP');
if (!defined('BULLETPROOF_CHECKOUT_FORMAT')) define('BULLETPROOF_CHECKOUT_FORMAT', 'raw');
if (!defined('BULLETPROOF_BPCHECKOUT_GATEWAY')) define('BULLETPROOF_BPCHECKOUT_GATEWAY', 'BPCHECKOUT');
// If the Official Mobile App will be used you will need to disable BULLETPROOF_CHECKOUT_ADDORDERLISTCOLUMNS
// In the Official Mobile App BulletProof does not support Authorize and Capture later
if (!defined('BULLETPROOF_CHECKOUT_ADDORDERLISTCOLUMNS')) define('BULLETPROOF_CHECKOUT_ADDORDERLISTCOLUMNS', false);
// Some hosting providers auto-enabled JetPack SSO which is buggy with the Official Mobile App
if (!defined('BULLETPROOF_CHECKOUT_DISABLEJETPACKSSO')) define('BULLETPROOF_CHECKOUT_DISABLEJETPACKSSO', false);
/**
* Check if WooCommerce is active and include the necessary files.
*/
if (!function_exists('bulletproof_payment_integration')) {
/**
* Plugin initialization: Checks if WooCommerce is active and includes necessary files.
*/
add_action('plugins_loaded', 'bulletproof_payment_integration');
function bulletproof_payment_integration()
{
/**
* Filter the active plugins to check if WooCommerce is active.
*
* @since 1.0.0
* @param array $active_plugins An array of active plugin filenames.
* @return bool Whether WooCommerce is active or not.
*/
if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
// Include the BulletProof Payment Gateway Lite class file.
include_once plugin_dir_path(__FILE__) . 'includes/class-wc-bulletproof-payment-gateway-lite.php';
include_once plugin_dir_path(__FILE__) . 'includes/class-wc-bulletproof-shop-orders.php';
include_once plugin_dir_path(__FILE__) . 'includes/class-wc-bulletproof-webhook.php';
include_once plugin_dir_path(__FILE__) . 'includes/common.php';
} else {
// Display an admin notice if WooCommerce is not active.
add_action('admin_notices', 'bulletproof_payment_gateway_plugin_notice_not_activated');
}
}
}
// declares compatibility with HPOS (High Performance Orders)
add_action('before_woocommerce_init', function () {
if (class_exists(\Automattic\WooCommerce\Utilities\FeaturesUtil::class)) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', __FILE__, true);
}
});
// Register activation hook to flush rewrite rules on plugin activation.
register_activation_hook(__FILE__, 'bulletproof_flush_rewrite_rules_on_activation');
/**
* Flush rewrite rules on plugin activation.
*/
if (!function_exists('bulletproof_flush_rewrite_rules_on_activation')) {
function bulletproof_flush_rewrite_rules_on_activation()
{
// Flush WordPress rewrite rules.
flush_rewrite_rules();
}
}
// Hook into WooCommerce payment gateways to add BulletProof Payment Gateway class.
add_filter('woocommerce_payment_gateways', 'bulletproof_add_gateway_class');
/**
* Add BulletProof Payment Gateway class to WooCommerce payment gateways.
*
* @param array $gateways
* @return array
*/
if (!function_exists('bulletproof_add_gateway_class')) {
function bulletproof_add_gateway_class($gateways)
{
$gateways[] = 'Bulletproof_Payment_Gateway_Lite';
return $gateways;
}
}
/**
* Display an admin notice if WooCommerce is not active.
*/
if (!function_exists('bulletproof_payment_gateway_plugin_notice_not_activated')) {
function bulletproof_payment_gateway_plugin_notice_not_activated()
{
bulletproof_payment_gateway_plugin_notice("Please activate WooCommerce to use Custom WooCommerce Plugin.");
}
}
add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'bulletproof_gateway_lite_2024_visitweb');
if (!function_exists('bulletproof_gateway_lite_2024_visitweb')) {
function bulletproof_gateway_lite_2024_visitweb($settings)
{
// Create the link.
$settings_link = '<a href="https://bulletproof-checkout.com">Visit Site</a>';
// Adds the link to the end of the array.
array_push(
$settings,
$settings_link
);
return $settings;
}
}
// Load plugin textdomain for translations at the proper time
add_action('init', 'bulletproof_load_textdomain');
if (!function_exists('bulletproof_load_textdomain')) {
function bulletproof_load_textdomain()
{
load_plugin_textdomain('bulletproof-checkout-lite', false, dirname(plugin_basename(__FILE__)) . '/languages');
}
}