AfterPay gateway for WooCommerce. * Version: 4.3.0 * Author: AfterPay * Author URI: https://developer.afterpay.io * Text Domain: afterpay * Domain Path: /languages * WC requires at least: 4.5.0 * WC tested up to: 3.5.1 */ /** * Copyright (c) copyright 2011-2019 arvato Finance B.V. * * AfterPay reserves all rights in the Program as delivered. The Program * or any portion thereof may not be reproduced in any form whatsoever without * the written consent of AfterPay. * * Disclaimer: * THIS NOTICE MAY NOT BE REMOVED FROM THE PROGRAM BY ANY USER THEREOF. * THE PROGRAM IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE PROGRAM OR THE USE OR OTHER DEALINGS * IN THE PROGRAM. */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly.. } /** * Check if WooCommerce is active */ $woo_active = false; if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) { $woo_active = true; } if ( ! function_exists( 'is_plugin_active_for_network' ) ) { require_once ABSPATH . '/wp-admin/includes/plugin.php'; } if ( is_plugin_active_for_network( 'woocommerce/woocommerce.php' ) && true !== $woo_active ) { $woo_active = true; } if ( false === $woo_active ) { echo 'The WooCommerce plugin should be installed before using the AfterPay Woocommerce Plugin'; exit; } /** * Load AfterPay extension on the WC Coupons to add specific AfterPay Coupon * field needed for Customer Individual Score */ require_once 'class-afterpay-coupon.php'; /** * Initiate AfterPay Gateway, load necessary files and classes. * * @access public * @return void **/ function init_afterpay_gateway() { if ( ! class_exists( 'WC_Payment_Gateway' ) ) { return; } /** * Localisation */ load_plugin_textdomain( 'afterpay', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); // Define AfterPay root Dir. define( 'AFTERPAY_DIR', dirname( __FILE__ ) . '/' ); // Define AfterPay lib Dir. define( 'AFTERPAY_LIB', dirname( __FILE__ ) . '/vendor/payintegrator/afterpay/lib/' ); /** * AfterPay Payment Gateway * * @class WC_Gateway_Afterpay * @extends WC_Payment_Gateway * @package WooCommerce/Classes/Payment * @author Willem Fokkens */ class WC_Gateway_Afterpay extends WC_Payment_Gateway { /** * Constructor for the gateway. * * @access public * @return void */ public function __construct() { global $woocommerce; } } // Load the AfterPay Base class and then the country specific payment methods. require_once 'class-wc-gateway-afterpay-base.php'; // Netherlands. require_once 'class-wc-gateway-afterpay-nl-openinvoice.php'; require_once 'class-wc-gateway-afterpay-nl-directdebit.php'; require_once 'class-wc-gateway-afterpay-nl-business.php'; require_once 'class-wc-gateway-afterpay-nl-openinvoice-extra.php'; require_once 'class-wc-gateway-afterpay-nl-business-extra.php'; // Belgium. require_once 'class-wc-gateway-afterpay-be-openinvoice.php'; // Load the AfterPay Base class for the countries using REST interface. require_once 'class-wc-gateway-afterpay-base-rest.php'; // Netherlands. require_once 'class-wc-gateway-afterpay-nl-openinvoice-rest.php'; // Belgium. require_once 'class-wc-gateway-afterpay-be-openinvoice-rest.php'; // Germany. require_once 'class-wc-gateway-afterpay-de-openinvoice.php'; require_once 'class-wc-gateway-afterpay-de-installments.php'; require_once 'class-wc-gateway-afterpay-de-directdebit.php'; require_once 'class-wc-gateway-afterpay-de-openinvoice-extra.php'; // Austria. require_once 'class-wc-gateway-afterpay-at-openinvoice.php'; require_once 'class-wc-gateway-afterpay-at-installments.php'; require_once 'class-wc-gateway-afterpay-at-directdebit.php'; // Switzerland. require_once 'class-wc-gateway-afterpay-ch-openinvoice.php'; // Denmark. require_once 'class-wc-gateway-afterpay-dk-openinvoice.php'; // Sweden. require_once 'class-wc-gateway-afterpay-se-openinvoice.php'; require_once 'class-wc-gateway-afterpay-se-installments.php'; // Finland. require_once 'class-wc-gateway-afterpay-fi-openinvoice.php'; require_once 'class-wc-gateway-afterpay-fi-installments.php'; // Norway. require_once 'class-wc-gateway-afterpay-no-openinvoice.php'; require_once 'class-wc-gateway-afterpay-no-installments.php'; } // If plugins are loaded then initiate AfterPay Gateway. add_action( 'plugins_loaded', 'init_afterpay_gateway', 0 ); /** * Add the gateway to WooCommerce * * @access public * @param array $methods Woocommerce Payment Gateways. * @return array **/ function add_afterpay_gateway( $methods ) { // The Netherlands. $methods[] = 'WC_Gateway_Afterpay_Nl_Openinvoice'; $methods[] = 'WC_Gateway_Afterpay_Nl_Directdebit'; $methods[] = 'WC_Gateway_Afterpay_Nl_Business'; $methods[] = 'WC_Gateway_Afterpay_Nl_Openinvoice_Extra'; $methods[] = 'WC_Gateway_Afterpay_Nl_Business_Extra'; $methods[] = 'WC_Gateway_Afterpay_Nl_Openinvoice_Rest'; // Belgium. $methods[] = 'WC_Gateway_Afterpay_Be_Openinvoice'; $methods[] = 'WC_Gateway_Afterpay_Be_Openinvoice_Rest'; // Germany. $methods[] = 'WC_Gateway_Afterpay_De_Openinvoice'; $methods[] = 'WC_Gateway_Afterpay_De_Directdebit'; $methods[] = 'WC_Gateway_Afterpay_De_Installments'; $methods[] = 'WC_Gateway_Afterpay_De_Openinvoice_Extra'; // Austria. $methods[] = 'WC_Gateway_Afterpay_At_Openinvoice'; $methods[] = 'WC_Gateway_Afterpay_At_Installments'; $methods[] = 'WC_Gateway_Afterpay_At_Directdebit'; // Switzerland. $methods[] = 'WC_Gateway_Afterpay_Ch_Openinvoice'; // Denmark. $methods[] = 'WC_Gateway_Afterpay_Dk_Openinvoice'; // Sweden. $methods[] = 'WC_Gateway_Afterpay_Se_Openinvoice'; $methods[] = 'WC_Gateway_Afterpay_Se_Installments'; // Finland. $methods[] = 'WC_Gateway_Afterpay_Fi_Openinvoice'; $methods[] = 'WC_Gateway_Afterpay_Fi_Installments'; // Norway. $methods[] = 'WC_Gateway_Afterpay_No_Openinvoice'; $methods[] = 'WC_Gateway_Afterpay_No_Installments'; return $methods; } // Add AfterPay gateway to Woocommerce filters. add_filter( 'woocommerce_payment_gateways', 'add_afterpay_gateway' );