forked from XedinUnknown/woocommerce-paypal-payments
-
Notifications
You must be signed in to change notification settings - Fork 0
/
woocommerce-paypal-payments.php
129 lines (114 loc) · 4.28 KB
/
woocommerce-paypal-payments.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
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
<?php
/**
* Plugin Name: WooCommerce PayPal Payments
* Plugin URI: https://woocommerce.com/products/woocommerce-paypal-payments/
* Description: PayPal's latest complete payments processing solution. Accept PayPal, PayPal Credit, credit/debit cards, alternative digital wallets local payment types and bank accounts. Turn on only PayPal options or process a full suite of payment methods. Enable global transaction with extensive currency and country coverage.
* Version: 1.1.0
* Author: WooCommerce
* Author URI: https://woocommerce.com/
* License: GPL-2.0
* WC requires at least: 3.9
* WC tested up to: 4.9
* Text Domain: woocommerce-paypal-payments
*
* @package WooCommerce\PayPalCommerce
*/
declare( strict_types = 1 );
namespace WooCommerce\PayPalCommerce;
use Dhii\Container\CachingContainer;
use Dhii\Container\CompositeCachingServiceProvider;
use Dhii\Container\DelegatingContainer;
use Dhii\Container\ProxyContainer;
use Dhii\Modular\Module\ModuleInterface;
define( 'PAYPAL_API_URL', 'https://api.paypal.com' );
define( 'PAYPAL_SANDBOX_API_URL', 'https://api.sandbox.paypal.com' );
define( 'PAYPAL_INTEGRATION_DATE', '2020-10-15' );
! defined( 'CONNECT_WOO_CLIENT_ID' ) && define( 'CONNECT_WOO_CLIENT_ID', 'AcCAsWta_JTL__OfpjspNyH7c1GGHH332fLwonA5CwX4Y10mhybRZmHLA0GdRbwKwjQIhpDQy0pluX_P' );
! defined( 'CONNECT_WOO_SANDBOX_CLIENT_ID' ) && define( 'CONNECT_WOO_SANDBOX_CLIENT_ID', 'AYmOHbt1VHg-OZ_oihPdzKEVbU3qg0qXonBcAztuzniQRaKE0w1Hr762cSFwd4n8wxOl-TCWohEa0XM_' );
! defined( 'CONNECT_WOO_MERCHANT_ID' ) && define( 'CONNECT_WOO_MERCHANT_ID', 'K8SKZ36LQBWXJ' );
! defined( 'CONNECT_WOO_SANDBOX_MERCHANT_ID' ) && define( 'CONNECT_WOO_SANDBOX_MERCHANT_ID', 'MPMFHQTVMBZ6G' );
! defined( 'CONNECT_WOO_URL' ) && define( 'CONNECT_WOO_URL', 'https://connect.woocommerce.com/ppc' );
! defined( 'CONNECT_WOO_SANDBOX_URL' ) && define( 'CONNECT_WOO_SANDBOX_URL', 'https://connect.woocommerce.com/ppcsandbox' );
( function () {
include __DIR__ . '/vendor/autoload.php';
/**
* Initialize the plugin and its modules.
*/
function init() {
if ( ! function_exists( 'is_plugin_active' ) ) {
require_once ABSPATH . '/wp-admin/includes/plugin.php';
}
if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
add_action(
'admin_notices',
function() {
/* translators: 1. URL link. */
echo '<div class="error"><p><strong>' . sprintf( esc_html__( 'WooCommerce PayPal Payments requires WooCommerce to be installed and active. You can download %s here.', 'woocommerce-paypal-payments' ), '<a href="https://woocommerce.com/" target="_blank">WooCommerce</a>' ) . '</strong></p></div>';
}
);
return;
}
static $initialized;
if ( ! $initialized ) {
$modules = array( new PluginModule() );
foreach ( glob( plugin_dir_path( __FILE__ ) . 'modules/*/module.php' ) as $module_file ) {
$modules[] = ( require $module_file )();
}
$providers = array();
foreach ( $modules as $module ) {
/* @var $module ModuleInterface module */
$providers[] = $module->setup();
}
$proxy = new ProxyContainer();
$provider = new CompositeCachingServiceProvider( $providers );
$container = new CachingContainer( new DelegatingContainer( $provider ) );
$proxy->setInnerContainer( $container );
foreach ( $modules as $module ) {
/* @var $module ModuleInterface module */
$module->run( $container );
}
$initialized = true;
}
}
add_action(
'plugins_loaded',
function () {
init();
}
);
register_activation_hook(
__FILE__,
function () {
init();
do_action( 'woocommerce_paypal_payments_gateway_activate' );
}
);
register_deactivation_hook(
__FILE__,
function () {
init();
do_action( 'woocommerce_paypal_payments_gateway_deactivate' );
}
);
// Add "Settings" link to Plugins screen.
add_filter(
'plugin_action_links_' . plugin_basename( __FILE__ ),
function( $links ) {
if ( ! function_exists( 'is_plugin_active' ) ) {
require_once ABSPATH . '/wp-admin/includes/plugin.php';
}
if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
return $links;
}
array_unshift(
$links,
sprintf(
'<a href="%1$s">%2$s</a>',
admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-gateway' ),
__( 'Settings', 'woocommerce-paypal-payments' )
)
);
return $links;
}
);
} )();