updated plugin Easy Digital Downloads
version 3.1.1.4.2
This commit is contained in:
@ -109,6 +109,11 @@ add_action( 'edd_checkout_user_error_checks', __NAMESPACE__ . '\send_ajax_errors
|
||||
* @return void
|
||||
*/
|
||||
function create_order( $purchase_data ) {
|
||||
|
||||
if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'edd-gateway' ) ) {
|
||||
wp_die( __( 'Nonce verification has failed', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
|
||||
}
|
||||
|
||||
edd_debug_log( 'PayPal - create_order()' );
|
||||
|
||||
if ( ! ready_to_accept_payments() ) {
|
||||
|
@ -1,3 +1,3 @@
|
||||
#edd-stripe-card-errors:not(:empty){margin:20px 0 0}:root{--edds-modal-grid-unit: 1rem;--edds-modal-overlay: rgba(0, 0, 0, 0.60)}.edds-modal__overlay{z-index:9999;position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0, 0, 0, 0.60);background:var(--edds-modal-overlay);display:flex;justify-content:center;align-items:center}.edds-modal__container{background-color:#fff;min-width:350px;max-width:90vw;max-height:90vh;box-sizing:border-box;overflow-y:auto}.admin-bar .edds-modal__container{margin-top:32px}.edds-modal__header{padding:calc(1rem*1.5);padding:calc(var(--edds-modal-grid-unit)*1.5);display:flex;justify-content:space-between;align-items:center;position:sticky;top:0;z-index:2;background:#fff;border-bottom:1px solid #eee}.edds-modal__title{text-align:left;font-size:150%;margin:0}.edds-modal__close{line-height:1;padding:1rem}.edds-modal__close:before{content:"✕"}.edds-modal__content{margin:calc(1rem*1.5);margin:calc(var(--edds-modal-grid-unit)*1.5)}@keyframes eddsSlideIn{from{transform:translateY(15%)}to{transform:translateY(0)}}@keyframes eddsSlideOut{from{transform:translateY(0)}to{transform:translateY(15%)}}.edds-modal.has-slide{display:none}.edds-modal.has-slide.is-open{display:block}.edds-modal.has-slide[aria-hidden=false] .edds-modal__container{animation:eddsSlideIn .3s cubic-bezier(0, 0, 0.2, 1)}.edds-modal.has-slide[aria-hidden=true] .edds-modal__container{animation:eddsSlideOut .3s cubic-bezier(0, 0, 0.2, 1)}.edds-modal.has-slide .edds-modal__container,.edds-modal.has-slide .edds-modal__overlay{will-change:transform}.edds-buy-now-modal{width:500px}.edds-buy-now-modal .edds-modal__close{padding:.5rem}.edds-buy-now-modal #edd_checkout_form_wrap input.edd-input,.edds-buy-now-modal #edd_checkout_form_wrap textarea.edd-input{width:100%}.edds-buy-now-modal #edd_checkout_form_wrap #edd_purchase_submit{margin-top:1.5rem;margin-bottom:0}.edds-buy-now-modal .edds-field-spacer-shim{margin-bottom:1rem}.edds-buy-now-modal .edd-alert-error{margin:20px 0}.edds-buy-now-modal #edd-stripe-card-errors:not(:empty){margin-bottom:20px}.edds-buy-now-modal #edd-stripe-card-errors:not(:empty) .edd-alert-error{margin:0}#edd_purchase_submit #edd-purchase-button[data-edd-button-state=disabled]{opacity:.5;cursor:not-allowed}#edd_purchase_submit #edd-purchase-button[data-edd-button-state=updating],#edd_purchase_submit #edd-purchase-button [data-edd-button-state=processing]{opacity:.5;cursor:wait}
|
||||
#edd-stripe-card-errors:not(:empty){margin:20px 0 0}:root{--edds-modal-grid-unit: 1rem;--edds-modal-overlay: rgba(0, 0, 0, 0.60)}.edds-modal__overlay{z-index:9999;position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0, 0, 0, 0.60);background:var(--edds-modal-overlay);display:flex;justify-content:center;align-items:center}.edds-modal__container{background-color:#fff;min-width:350px;max-width:90vw;max-height:90vh;box-sizing:border-box;overflow-y:auto}.admin-bar .edds-modal__container{margin-top:32px}.edds-modal__header{padding:calc(1rem*1.5);padding:calc(var(--edds-modal-grid-unit)*1.5);display:flex;justify-content:space-between;align-items:center;position:sticky;top:0;z-index:2;background:#fff;border-bottom:1px solid #eee}.edds-modal__title{text-align:left;font-size:150%;margin:0}.edds-modal__close{line-height:1;padding:1rem}.edds-modal__close:before{content:"✕"}.edds-modal__content{margin:calc(1rem*1.5);margin:calc(var(--edds-modal-grid-unit)*1.5)}@keyframes eddsSlideIn{from{transform:translateY(15%)}to{transform:translateY(0)}}@keyframes eddsSlideOut{from{transform:translateY(0)}to{transform:translateY(15%)}}.edds-modal.has-slide{display:none}.edds-modal.has-slide.is-open{display:block}.edds-modal.has-slide[aria-hidden=false] .edds-modal__container{animation:eddsSlideIn .3s cubic-bezier(0, 0, 0.2, 1)}.edds-modal.has-slide[aria-hidden=true] .edds-modal__container{animation:eddsSlideOut .3s cubic-bezier(0, 0, 0.2, 1)}.edds-modal.has-slide .edds-modal__container,.edds-modal.has-slide .edds-modal__overlay{will-change:transform}.edds-buy-now-modal{width:500px}.edds-buy-now-modal .edds-modal__close{padding:.5rem}.edds-buy-now-modal #edd_checkout_form_wrap input.edd-input,.edds-buy-now-modal #edd_checkout_form_wrap textarea.edd-input{width:100%}.edds-buy-now-modal #edd_checkout_form_wrap #edd_purchase_submit{margin-top:1.5rem;margin-bottom:0}.edds-buy-now-modal .edds-field-spacer-shim{margin-bottom:1rem}.edds-buy-now-modal .edd-alert-error{margin:20px 0}.edds-buy-now-modal #edd-stripe-card-errors:not(:empty){margin-bottom:20px}.edds-buy-now-modal #edd-stripe-card-errors:not(:empty) .edd-alert-error{margin:0}#edd_purchase_submit #edd-purchase-button[data-edd-button-state=disabled]{opacity:.5;cursor:not-allowed}#edd_purchase_submit #edd-purchase-button[data-edd-button-state=updating],#edd_purchase_submit #edd-purchase-button [data-edd-button-state=processing]{opacity:.5;cursor:wait}#card_name,.card-name{padding:8px !important;width:100% !important;box-sizing:border-box}
|
||||
|
||||
/*# sourceMappingURL=paymentelements.min.css.map*/
|
@ -1 +1 @@
|
||||
{"version":3,"sources":["webpack:///./assets/css/src/payment-elements.scss"],"names":[],"mappings":"AAAA,oCAAoC,gBAAgB,MAAM,6BAA6B,0CAA0C,qBAAqB,aAAa,eAAe,MAAM,OAAO,QAAQ,SAAS,+BAA+B,qCAAqC,aAAa,uBAAuB,mBAAmB,uBAAuB,sBAAsB,gBAAgB,eAAe,gBAAgB,sBAAsB,gBAAgB,kCAAkC,gBAAgB,oBAAoB,uBAAuB,8CAA8C,aAAa,8BAA8B,mBAAmB,gBAAgB,MAAM,UAAU,gBAAgB,6BAA6B,mBAAmB,gBAAgB,eAAe,SAAS,mBAAmB,cAAc,aAAa,0BAA0B,YAAY,qBAAqB,sBAAsB,6CAA6C,uBAAuB,KAAK,0BAA0B,GAAG,yBAAyB,wBAAwB,KAAK,wBAAwB,GAAG,2BAA2B,sBAAsB,aAAa,8BAA8B,cAAc,gEAAgE,qDAAqD,+DAA+D,sDAAsD,wFAAwF,sBAAsB,oBAAoB,YAAY,uCAAuC,cAAc,2HAA2H,WAAW,iEAAiE,kBAAkB,gBAAgB,4CAA4C,mBAAmB,qCAAqC,cAAc,wDAAwD,mBAAmB,yEAAyE,SAAS,0EAA0E,WAAW,mBAAmB,uJAAuJ,WAAW,Y","file":"assets/css/build/paymentelements.min.css","sourcesContent":["#edd-stripe-card-errors:not(:empty){margin:20px 0 0}:root{--edds-modal-grid-unit: 1rem;--edds-modal-overlay: rgba(0, 0, 0, 0.60)}.edds-modal__overlay{z-index:9999;position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0, 0, 0, 0.60);background:var(--edds-modal-overlay);display:flex;justify-content:center;align-items:center}.edds-modal__container{background-color:#fff;min-width:350px;max-width:90vw;max-height:90vh;box-sizing:border-box;overflow-y:auto}.admin-bar .edds-modal__container{margin-top:32px}.edds-modal__header{padding:calc(1rem*1.5);padding:calc(var(--edds-modal-grid-unit)*1.5);display:flex;justify-content:space-between;align-items:center;position:sticky;top:0;z-index:2;background:#fff;border-bottom:1px solid #eee}.edds-modal__title{text-align:left;font-size:150%;margin:0}.edds-modal__close{line-height:1;padding:1rem}.edds-modal__close:before{content:\"✕\"}.edds-modal__content{margin:calc(1rem*1.5);margin:calc(var(--edds-modal-grid-unit)*1.5)}@keyframes eddsSlideIn{from{transform:translateY(15%)}to{transform:translateY(0)}}@keyframes eddsSlideOut{from{transform:translateY(0)}to{transform:translateY(15%)}}.edds-modal.has-slide{display:none}.edds-modal.has-slide.is-open{display:block}.edds-modal.has-slide[aria-hidden=false] .edds-modal__container{animation:eddsSlideIn .3s cubic-bezier(0, 0, 0.2, 1)}.edds-modal.has-slide[aria-hidden=true] .edds-modal__container{animation:eddsSlideOut .3s cubic-bezier(0, 0, 0.2, 1)}.edds-modal.has-slide .edds-modal__container,.edds-modal.has-slide .edds-modal__overlay{will-change:transform}.edds-buy-now-modal{width:500px}.edds-buy-now-modal .edds-modal__close{padding:.5rem}.edds-buy-now-modal #edd_checkout_form_wrap input.edd-input,.edds-buy-now-modal #edd_checkout_form_wrap textarea.edd-input{width:100%}.edds-buy-now-modal #edd_checkout_form_wrap #edd_purchase_submit{margin-top:1.5rem;margin-bottom:0}.edds-buy-now-modal .edds-field-spacer-shim{margin-bottom:1rem}.edds-buy-now-modal .edd-alert-error{margin:20px 0}.edds-buy-now-modal #edd-stripe-card-errors:not(:empty){margin-bottom:20px}.edds-buy-now-modal #edd-stripe-card-errors:not(:empty) .edd-alert-error{margin:0}#edd_purchase_submit #edd-purchase-button[data-edd-button-state=disabled]{opacity:.5;cursor:not-allowed}#edd_purchase_submit #edd-purchase-button[data-edd-button-state=updating],#edd_purchase_submit #edd-purchase-button [data-edd-button-state=processing]{opacity:.5;cursor:wait}"],"sourceRoot":""}
|
||||
{"version":3,"sources":["webpack:///./assets/css/src/payment-elements.scss"],"names":[],"mappings":"AAAA,oCAAoC,gBAAgB,MAAM,6BAA6B,0CAA0C,qBAAqB,aAAa,eAAe,MAAM,OAAO,QAAQ,SAAS,+BAA+B,qCAAqC,aAAa,uBAAuB,mBAAmB,uBAAuB,sBAAsB,gBAAgB,eAAe,gBAAgB,sBAAsB,gBAAgB,kCAAkC,gBAAgB,oBAAoB,uBAAuB,8CAA8C,aAAa,8BAA8B,mBAAmB,gBAAgB,MAAM,UAAU,gBAAgB,6BAA6B,mBAAmB,gBAAgB,eAAe,SAAS,mBAAmB,cAAc,aAAa,0BAA0B,YAAY,qBAAqB,sBAAsB,6CAA6C,uBAAuB,KAAK,0BAA0B,GAAG,yBAAyB,wBAAwB,KAAK,wBAAwB,GAAG,2BAA2B,sBAAsB,aAAa,8BAA8B,cAAc,gEAAgE,qDAAqD,+DAA+D,sDAAsD,wFAAwF,sBAAsB,oBAAoB,YAAY,uCAAuC,cAAc,2HAA2H,WAAW,iEAAiE,kBAAkB,gBAAgB,4CAA4C,mBAAmB,qCAAqC,cAAc,wDAAwD,mBAAmB,yEAAyE,SAAS,0EAA0E,WAAW,mBAAmB,uJAAuJ,WAAW,YAAY,sBAAsB,uBAAuB,sBAAsB,sB","file":"assets/css/build/paymentelements.min.css","sourcesContent":["#edd-stripe-card-errors:not(:empty){margin:20px 0 0}:root{--edds-modal-grid-unit: 1rem;--edds-modal-overlay: rgba(0, 0, 0, 0.60)}.edds-modal__overlay{z-index:9999;position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0, 0, 0, 0.60);background:var(--edds-modal-overlay);display:flex;justify-content:center;align-items:center}.edds-modal__container{background-color:#fff;min-width:350px;max-width:90vw;max-height:90vh;box-sizing:border-box;overflow-y:auto}.admin-bar .edds-modal__container{margin-top:32px}.edds-modal__header{padding:calc(1rem*1.5);padding:calc(var(--edds-modal-grid-unit)*1.5);display:flex;justify-content:space-between;align-items:center;position:sticky;top:0;z-index:2;background:#fff;border-bottom:1px solid #eee}.edds-modal__title{text-align:left;font-size:150%;margin:0}.edds-modal__close{line-height:1;padding:1rem}.edds-modal__close:before{content:\"✕\"}.edds-modal__content{margin:calc(1rem*1.5);margin:calc(var(--edds-modal-grid-unit)*1.5)}@keyframes eddsSlideIn{from{transform:translateY(15%)}to{transform:translateY(0)}}@keyframes eddsSlideOut{from{transform:translateY(0)}to{transform:translateY(15%)}}.edds-modal.has-slide{display:none}.edds-modal.has-slide.is-open{display:block}.edds-modal.has-slide[aria-hidden=false] .edds-modal__container{animation:eddsSlideIn .3s cubic-bezier(0, 0, 0.2, 1)}.edds-modal.has-slide[aria-hidden=true] .edds-modal__container{animation:eddsSlideOut .3s cubic-bezier(0, 0, 0.2, 1)}.edds-modal.has-slide .edds-modal__container,.edds-modal.has-slide .edds-modal__overlay{will-change:transform}.edds-buy-now-modal{width:500px}.edds-buy-now-modal .edds-modal__close{padding:.5rem}.edds-buy-now-modal #edd_checkout_form_wrap input.edd-input,.edds-buy-now-modal #edd_checkout_form_wrap textarea.edd-input{width:100%}.edds-buy-now-modal #edd_checkout_form_wrap #edd_purchase_submit{margin-top:1.5rem;margin-bottom:0}.edds-buy-now-modal .edds-field-spacer-shim{margin-bottom:1rem}.edds-buy-now-modal .edd-alert-error{margin:20px 0}.edds-buy-now-modal #edd-stripe-card-errors:not(:empty){margin-bottom:20px}.edds-buy-now-modal #edd-stripe-card-errors:not(:empty) .edd-alert-error{margin:0}#edd_purchase_submit #edd-purchase-button[data-edd-button-state=disabled]{opacity:.5;cursor:not-allowed}#edd_purchase_submit #edd-purchase-button[data-edd-button-state=updating],#edd_purchase_submit #edd-purchase-button [data-edd-button-state=processing]{opacity:.5;cursor:wait}#card_name,.card-name{padding:8px !important;width:100% !important;box-sizing:border-box}"],"sourceRoot":""}
|
File diff suppressed because one or more lines are too long
@ -2,8 +2,8 @@
|
||||
/**
|
||||
* Plugin Name: Easy Digital Downloads - Stripe Pro Payment Gateway
|
||||
* Plugin URI: https://easydigitaldownloads.com/downloads/stripe-gateway/
|
||||
* Description: Adds a payment gateway for Stripe.com
|
||||
* Version: 2.9.2.1
|
||||
* Description: Adds support for pre-authorized credit card payments and removes additional transaction fees.
|
||||
* Version: 2.9.2.2
|
||||
* Requires at least: 5.4
|
||||
* Requires PHP: 7.1
|
||||
* Author: Easy Digital Downloads
|
||||
@ -44,7 +44,7 @@ function edd_stripe_core_bootstrap() {
|
||||
}
|
||||
|
||||
if ( ! defined( 'EDD_STRIPE_VERSION' ) ) {
|
||||
define( 'EDD_STRIPE_VERSION', '2.9.2.1' );
|
||||
define( 'EDD_STRIPE_VERSION', '2.9.2.2' );
|
||||
}
|
||||
|
||||
if ( ! defined( 'EDD_STRIPE_API_VERSION' ) ) {
|
||||
|
@ -26,14 +26,14 @@ add_filter( 'edd_settings_sections_gateways', 'edds_settings_section' );
|
||||
*/
|
||||
function edds_add_settings( $settings ) {
|
||||
$stripe_settings = array(
|
||||
'stripe_connect_button' => array(
|
||||
'stripe_connect_button' => array(
|
||||
'id' => 'stripe_connect_button',
|
||||
'name' => __( 'Connection Status', 'easy-digital-downloads' ),
|
||||
'desc' => edds_stripe_connect_setting_field(),
|
||||
'type' => 'descriptive_text',
|
||||
'class' => 'edd-stripe-connect-row',
|
||||
),
|
||||
'test_publishable_key' => array(
|
||||
'test_publishable_key' => array(
|
||||
'id' => 'test_publishable_key',
|
||||
'name' => __( 'Test Publishable Key', 'easy-digital-downloads' ),
|
||||
'desc' => __( 'Enter your test publishable key, found in your Stripe Account Settings', 'easy-digital-downloads' ),
|
||||
@ -49,7 +49,7 @@ function edds_add_settings( $settings ) {
|
||||
'size' => 'regular',
|
||||
'class' => 'edd-hidden edds-api-key-row',
|
||||
),
|
||||
'live_publishable_key' => array(
|
||||
'live_publishable_key' => array(
|
||||
'id' => 'live_publishable_key',
|
||||
'name' => __( 'Live Publishable Key', 'easy-digital-downloads' ),
|
||||
'desc' => __( 'Enter your live publishable key, found in your Stripe Account Settings', 'easy-digital-downloads' ),
|
||||
@ -57,7 +57,7 @@ function edds_add_settings( $settings ) {
|
||||
'size' => 'regular',
|
||||
'class' => 'edd-hidden edds-api-key-row',
|
||||
),
|
||||
'live_secret_key' => array(
|
||||
'live_secret_key' => array(
|
||||
'id' => 'live_secret_key',
|
||||
'name' => __( 'Live Secret Key', 'easy-digital-downloads' ),
|
||||
'desc' => __( 'Enter your live secret key, found in your Stripe Account Settings', 'easy-digital-downloads' ),
|
||||
@ -65,7 +65,7 @@ function edds_add_settings( $settings ) {
|
||||
'size' => 'regular',
|
||||
'class' => 'edd-hidden edds-api-key-row',
|
||||
),
|
||||
'stripe_webhook_description' => array(
|
||||
'stripe_webhook_description' => array(
|
||||
'id' => 'stripe_webhook_description',
|
||||
'type' => 'descriptive_text',
|
||||
'name' => __( 'Webhooks', 'easy-digital-downloads' ),
|
||||
@ -93,7 +93,7 @@ function edds_add_settings( $settings ) {
|
||||
) .
|
||||
'</p>',
|
||||
),
|
||||
'stripe_billing_fields' => array(
|
||||
'stripe_billing_fields' => array(
|
||||
'id' => 'stripe_billing_fields',
|
||||
'name' => __( 'Billing Address Display', 'easy-digital-downloads' ),
|
||||
'desc' => __( 'Select how you would like to display the billing address fields on the checkout form. <p><strong>Notes</strong>:</p><p>If taxes are enabled, this option cannot be changed from "Full address".</p><p>If set to "No address fields", you <strong>must</strong> disable "zip code verification" in your Stripe account.</p>', 'easy-digital-downloads' ),
|
||||
@ -105,13 +105,13 @@ function edds_add_settings( $settings ) {
|
||||
'none' => __( 'No address fields', 'easy-digital-downloads' ),
|
||||
),
|
||||
),
|
||||
'stripe_statement_descriptor' => array(
|
||||
'stripe_statement_descriptor' => array(
|
||||
'id' => 'stripe_statement_descriptor',
|
||||
'name' => __( 'Statement Descriptor', 'easy-digital-downloads' ),
|
||||
'desc' => __( 'Choose how charges will appear on customer\'s credit card statements. <em>Max 22 characters</em>', 'easy-digital-downloads' ),
|
||||
'type' => 'text',
|
||||
),
|
||||
'stripe_restrict_assets' => array(
|
||||
'stripe_restrict_assets' => array(
|
||||
'id' => 'stripe_restrict_assets',
|
||||
'name' => ( __( 'Restrict Stripe Assets', 'easy-digital-downloads' ) ),
|
||||
'check' => ( __( 'Only load Stripe.com hosted assets on pages that specifically utilize Stripe functionality.', 'easy-digital-downloads' ) ),
|
||||
|
@ -420,4 +420,17 @@ class EDD_Stripe_Rate_Limiting {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the error message to display when the card error limit has been hit.
|
||||
*
|
||||
* @since 2.9.2.2
|
||||
* @return string The error message.
|
||||
*/
|
||||
public function get_rate_limit_error_message() {
|
||||
return esc_html__(
|
||||
'We are unable to process your payment at this time, please try again later or contact support.',
|
||||
'easy-digital-downloads'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,6 +36,22 @@ class EDD_Stripe {
|
||||
*/
|
||||
public $rate_limiting;
|
||||
|
||||
/**
|
||||
* Has Regional Support.
|
||||
*
|
||||
* @since 2.9.2.2
|
||||
* @var bool
|
||||
*/
|
||||
public $has_regional_support = false;
|
||||
|
||||
/**
|
||||
* Regional Support class.
|
||||
*
|
||||
* @since 2.9.2.2
|
||||
* @var EDD_Stripe_Country_Base
|
||||
*/
|
||||
public $regional_support;
|
||||
|
||||
/**
|
||||
* Instantiates or returns the singleton instance.
|
||||
*
|
||||
@ -52,27 +68,15 @@ class EDD_Stripe {
|
||||
self::$instance->filters();
|
||||
|
||||
if ( true === edds_is_pro() ) {
|
||||
if ( class_exists( '\\EDD\\Extensions\\ExtensionRegistry' ) ) {
|
||||
add_action( 'edd_extension_license_init', function( \EDD\Extensions\ExtensionRegistry $registry ) {
|
||||
$registry->addExtension(
|
||||
EDD_STRIPE_PLUGIN_FILE,
|
||||
'Stripe Pro Payment Gateway',
|
||||
167,
|
||||
EDD_STRIPE_VERSION,
|
||||
'stripe_license_key'
|
||||
);
|
||||
} );
|
||||
} elseif ( class_exists( 'EDD_License' ) ) {
|
||||
new EDD_License(
|
||||
add_action( 'edd_extension_license_init', function( \EDD\Extensions\ExtensionRegistry $registry ) {
|
||||
$registry->addExtension(
|
||||
EDD_STRIPE_PLUGIN_FILE,
|
||||
'Stripe Pro Payment Gateway',
|
||||
167,
|
||||
EDD_STRIPE_VERSION,
|
||||
'Easy Digital Downloads',
|
||||
'stripe_license_key',
|
||||
null,
|
||||
167
|
||||
'stripe_license_key'
|
||||
);
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,6 +177,9 @@ class EDD_Stripe {
|
||||
require_once EDDS_PLUGIN_DIR . '/includes/integrations/edd-auto-register.php';
|
||||
}
|
||||
|
||||
// Load Regional Support.
|
||||
$this->load_regional_support();
|
||||
|
||||
// Pro.
|
||||
$pro = EDDS_PLUGIN_DIR . '/includes/pro/index.php';
|
||||
|
||||
@ -293,4 +300,33 @@ class EDD_Stripe {
|
||||
return $gateways;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads regional support.
|
||||
*
|
||||
* @since 2.9.2.2
|
||||
*/
|
||||
private function load_regional_support() {
|
||||
|
||||
$base_country = edd_get_option( 'base_country', 'US' );
|
||||
$regions_needing_support = array( 'IN' );
|
||||
if ( ! in_array( $base_country, $regions_needing_support, true ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$possible_region_file = 'class-edd-stripe-region-' . strtolower( $base_country ) . '.php';
|
||||
$possible_region_path = EDDS_PLUGIN_DIR . 'includes/utils/regional-support/' . $possible_region_file;
|
||||
if ( ! file_exists( $possible_region_path ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Regional Support is needed.
|
||||
require_once EDDS_PLUGIN_DIR . 'includes/utils/regional-support/class-edd-stripe-region-base.php';
|
||||
require_once $possible_region_path;
|
||||
$possible_region_class = 'EDD_Stripe_Region_' . strtoupper( $base_country );
|
||||
if ( class_exists( $possible_region_class ) ) {
|
||||
$this->has_regional_support = true;
|
||||
require_once EDDS_PLUGIN_DIR . 'includes/utils/regional-support/' . $possible_region_file;
|
||||
$this->regional_support = new $possible_region_class();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ function edds_get_stripe_payment_elements_theme() {
|
||||
*
|
||||
* @link https://stripe.com/docs/elements/appearance-api#theme
|
||||
*
|
||||
* @see assets/js/src/frontend/payment-elements/index.php::generateElementStyles
|
||||
* @see assets/js/src/frontend/payment-elements/index.js::generateElementStyles
|
||||
*
|
||||
* @param array $payment_elements_theme The theme to use for the Payment Element object.
|
||||
*/
|
||||
@ -42,7 +42,7 @@ function edds_get_stripe_payment_elements_variables() {
|
||||
*
|
||||
* @link https://stripe.com/docs/elements/appearance-api?platform=web#variables
|
||||
*
|
||||
* @see assets/js/src/frontend/payment-elements/index.php::generateElementStyles
|
||||
* @see assets/js/src/frontend/payment-elements/index.js::generateElementStyles
|
||||
*
|
||||
* @param array $payment_elements_variables Variables used for the Payment Elements.
|
||||
*/
|
||||
@ -95,7 +95,7 @@ function edds_get_stripe_payment_elements_layout() {
|
||||
*
|
||||
* @link https://stripe.com/docs/js/elements_object/create_payment_element#payment_element_create-options-layout
|
||||
*
|
||||
* @see assets/js/src/frontend/payment-elements/index.php::generateElementStyles
|
||||
* @see assets/js/src/frontend/payment-elements/index.js::generateElementStyles
|
||||
*
|
||||
* @param array $payment_elements_layout Layout values used to create Stripe Elements object.
|
||||
*/
|
||||
@ -121,7 +121,7 @@ function edds_get_stripe_payment_elements_wallets() {
|
||||
*
|
||||
* @link https://stripe.com/docs/js/elements_object/create_payment_element#payment_element_create-options-wallets
|
||||
*
|
||||
* @see assets/js/src/frontend/payment-elements/index.php::generateElementStyles
|
||||
* @see assets/js/src/frontend/payment-elements/index.js::generateElementStyles
|
||||
*
|
||||
* @param bool If wallets should be disabled.
|
||||
*/
|
||||
@ -151,7 +151,7 @@ function edds_get_stripe_payment_elements_wallets() {
|
||||
*
|
||||
* @link https://stripe.com/docs/js/elements_object/create_payment_element#payment_element_create-options-wallets
|
||||
*
|
||||
* @see assets/js/src/frontend/payment-elements/index.php::generateElementStyles
|
||||
* @see assets/js/src/frontend/payment-elements/index.js::generateElementStyles
|
||||
*
|
||||
* @param array $enabled_wallets Allowed wallets payment methods ot use on the Payment Element.
|
||||
*/
|
||||
@ -177,7 +177,7 @@ function edds_get_stripe_payment_elements_label_style() {
|
||||
*
|
||||
* @link https://stripe.com/docs/elements/appearance-api?platform=web#others
|
||||
*
|
||||
* @see assets/js/src/frontend/payment-elements/index.php::generateElementStyles
|
||||
* @see assets/js/src/frontend/payment-elements/index.js::generateElementStyles
|
||||
*
|
||||
* @param array $label_style The style to use for the Payment Elements labels.
|
||||
*/
|
||||
@ -204,7 +204,7 @@ function edds_get_stripe_payment_elements_fonts() {
|
||||
* @link https://stripe.com/docs/js/appendix/css_font_source_object
|
||||
* @link https://stripe.com/docs/js/appendix/custom_font_source_object
|
||||
*
|
||||
* @see assets/js/src/frontend/payment-elements/index.php::generateElementStyles
|
||||
* @see assets/js/src/frontend/payment-elements/index.js::generateElementStyles
|
||||
*
|
||||
* @param array $fonts The style to use for the Payment Elements labels.
|
||||
*/
|
||||
@ -212,6 +212,44 @@ function edds_get_stripe_payment_elements_fonts() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows passing custom fields into the Stripe Elements.
|
||||
*
|
||||
* @since 2.9.2.2
|
||||
*/
|
||||
function edds_get_stripe_payment_elements_fields() {
|
||||
$default_fields = array(
|
||||
'billingDetails' => array(
|
||||
'name' => 'auto',
|
||||
'email' => 'never', // It is not advised to change this to auto, as it will create duplicate email fields on checkout.
|
||||
'phone' => 'never',
|
||||
'address' => 'never',
|
||||
),
|
||||
);
|
||||
|
||||
// By default, if the store has the address fields required, don't include them in the Payment Element.
|
||||
if ( 'none' !== edd_get_option( 'stripe_billing_fields', 'none' ) ) {
|
||||
$default_fields['billingDetails']['address'] = 'never';
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows passing custom fields into the Stripe Elements.
|
||||
*
|
||||
* This needs to be an array. The default fields hold our values for the billingDetails fields. Fields can have a value of
|
||||
* either 'auto' or 'never'. If you want to disable a field, set it to 'never'. When set to 'auto', Stripe will attempt to
|
||||
* determine if the field is necessary based on a combination of currency, country, and account.
|
||||
*
|
||||
* @since 2.9.2.2
|
||||
*
|
||||
* @link https://stripe.com/docs/js/elements_object/create_payment_element#payment_element_create-options-fields
|
||||
*
|
||||
* @see assets/js/src/frontend/payment-elements/index.js::createAndMountElement
|
||||
*
|
||||
* @param array $default_fields The default fields and their values.
|
||||
*/
|
||||
return apply_filters( 'edds_stripe_payment_elements_fields', $default_fields );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gathers all the possible customizations for the Stripe Payment Elements.
|
||||
*
|
||||
@ -234,6 +272,7 @@ function edds_gather_payment_element_customizations() {
|
||||
'labels' => edds_get_stripe_payment_elements_label_style(),
|
||||
'fonts' => edds_get_stripe_payment_elements_fonts(),
|
||||
'paymentMethodTypes' => edds_payment_element_payment_method_types(),
|
||||
'fields' => edds_get_stripe_payment_elements_fields(),
|
||||
'i18n' => array(
|
||||
'errorMessages' => edds_get_localized_error_messages(),
|
||||
),
|
||||
|
@ -6,13 +6,21 @@
|
||||
* @since 2.7.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* If regional support is enabled, check if the card name field is required.
|
||||
*/
|
||||
function edds_maybe_disable_card_name() {
|
||||
// We no longer need a card name field.
|
||||
add_filter( 'edd_purchase_form_required_fields', function( $required_fields ) {
|
||||
unset( $required_fields['card_name'] );
|
||||
return $required_fields;
|
||||
} );
|
||||
remove_action( 'edd_checkout_error_checks', 'edds_process_post_data' );
|
||||
// We no longer need a card name field for some regions, so remove the requirement if it's not needed.
|
||||
if ( false === edd_stripe()->has_regional_support || false === edd_stripe()->regional_support->requires_card_name ) {
|
||||
add_filter(
|
||||
'edd_purchase_form_required_fields',
|
||||
function( $required_fields ) {
|
||||
unset( $required_fields['card_name'] );
|
||||
return $required_fields;
|
||||
}
|
||||
);
|
||||
remove_action( 'edd_checkout_error_checks', 'edds_process_post_data' );
|
||||
}
|
||||
}
|
||||
add_action( 'edd_pre_process_purchase', 'edds_maybe_disable_card_name' );
|
||||
|
||||
@ -48,12 +56,7 @@ function edds_process_purchase_form( $purchase_data ) {
|
||||
|
||||
try {
|
||||
if ( edd_stripe()->rate_limiting->has_hit_card_error_limit() ) {
|
||||
throw new \EDD_Stripe_Gateway_Exception(
|
||||
esc_html__(
|
||||
'We are unable to process your payment at this time, please try again later or contact support.',
|
||||
'easy-digital-downloads'
|
||||
)
|
||||
);
|
||||
throw new \EDD_Stripe_Gateway_Exception( edd_stripe()->rate_limiting->get_rate_limit_error_message() );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,8 +73,12 @@ function edds_process_purchase_form( $purchase_data ) {
|
||||
*
|
||||
* We're also going to attempt to restrict this to a single subscription and no mixed carts, for the time being.
|
||||
*/
|
||||
$cart_contains_subscription = false;
|
||||
|
||||
if ( function_exists( 'edd_recurring' ) ) {
|
||||
if ( ( count( edd_get_cart_contents() ) > 1 && edd_recurring()->cart_contains_recurring() ) || edd_recurring()->cart_is_mixed() ) {
|
||||
$cart_contains_subscription = edd_recurring()->cart_contains_recurring();
|
||||
|
||||
if ( ( count( edd_get_cart_contents() ) > 1 && $cart_contains_subscription ) || edd_recurring()->cart_is_mixed() ) {
|
||||
throw new \EDD_Stripe_Gateway_Exception( edds_get_single_subscription_cart_error() );
|
||||
}
|
||||
|
||||
@ -146,23 +153,23 @@ function edds_process_purchase_form( $purchase_data ) {
|
||||
'edd_payment_fees' => esc_html( edd_get_cart_fee_total() ),
|
||||
'edd_payment_total' => esc_html( $purchase_data['price'] ),
|
||||
'edd_payment_items' => esc_html( implode( ', ', $payment_items ) ),
|
||||
'zero_decimal_amount' => $amount,
|
||||
),
|
||||
);
|
||||
|
||||
if ( ! empty( $_REQUEST['payment_method_id'] ) ) {
|
||||
$intent_args['payment_method'] = sanitize_text_field( $_REQUEST['payment_method_id'] );
|
||||
} else {
|
||||
$payment_method_types = edds_payment_element_payment_method_types();
|
||||
$payment_method = $_REQUEST['payment_method'];
|
||||
|
||||
if ( ! empty( $payment_method_types ) ) {
|
||||
$intent_args['payment_method_types'] = $payment_method_types;
|
||||
} else {
|
||||
$intent_args['automatic_payment_methods'] = array( 'enabled' => true );
|
||||
}
|
||||
}
|
||||
// Attach the payment method.
|
||||
$intent_args['payment_method'] = sanitize_text_field( $payment_method['id'] );
|
||||
|
||||
// Set to automatic payment methods so any of the supported methods can be used here.
|
||||
$intent_args['automatic_payment_methods'] = array( 'enabled' => true );
|
||||
|
||||
// We need the intent type later, so we'll set it here.
|
||||
$intent_type = ( edds_is_preapprove_enabled() || 0 === $amount ) ? 'SetupIntent' : 'PaymentIntent';
|
||||
|
||||
// Create a SetupIntent for a non-payment carts.
|
||||
if ( edds_is_preapprove_enabled() || 0 === $amount ) {
|
||||
if ( 'SetupIntent' === $intent_type ) {
|
||||
$intent_args = array_merge(
|
||||
array(
|
||||
'description' => edds_get_payment_description( $purchase_data['cart_details'] ),
|
||||
@ -171,8 +178,6 @@ function edds_process_purchase_form( $purchase_data ) {
|
||||
$intent_args
|
||||
);
|
||||
|
||||
$intent_type = 'SetupIntent';
|
||||
|
||||
/**
|
||||
* BETA Functionality.
|
||||
*
|
||||
@ -229,8 +234,6 @@ function edds_process_purchase_form( $purchase_data ) {
|
||||
$intent_args
|
||||
);
|
||||
|
||||
$intent_type = 'PaymentIntent';
|
||||
|
||||
$stripe_connect_account_id = edd_get_option( 'stripe_connect_account_id' );
|
||||
|
||||
if (
|
||||
@ -270,7 +273,29 @@ function edds_process_purchase_form( $purchase_data ) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If purchasing a subscription with a card, we need to add the subscription mandate data.
|
||||
*
|
||||
* This will ensure that any cards that require mandates like INR payments or India based cards will correctly add
|
||||
* the mandates necessary for recurring payments.
|
||||
*
|
||||
* We do this after we check for an existing intent ID, because the mandate data will change depending on the 'timestamp'.
|
||||
*/
|
||||
if ( 'card' === $payment_method['type'] && true === $cart_contains_subscription ) {
|
||||
require_once EDDS_PLUGIN_DIR . 'includes/utils/class-edd-stripe-mandates.php';
|
||||
$mandates = new EDD_Stripe_Mandates( $purchase_data, $intent_type );
|
||||
$mandate_options = $mandates->mandate_options;
|
||||
|
||||
// Add the mandate options to the intent arguments.
|
||||
$intent_args['payment_method_options']['card']['mandate_options'] = $mandate_options;
|
||||
}
|
||||
|
||||
if ( ! empty( $existing_intent ) ) {
|
||||
// Existing intents need to not have the automatic_payment_methods flag set.
|
||||
if ( ! empty( $intent_args['automatic_payment_methods'] ) ) {
|
||||
unset( $intent_args['automatic_payment_methods'] );
|
||||
}
|
||||
|
||||
edds_api_request( $intent_type, 'update', $intent->id, $intent_args );
|
||||
$intent = edds_api_request( $intent_type, 'retrieve', $intent->id );
|
||||
} else {
|
||||
@ -520,6 +545,27 @@ function edds_create_and_complete_order() {
|
||||
)
|
||||
);
|
||||
|
||||
// The returned Intent charges might contain a mandate ID, so let's save that and make a note.
|
||||
if ( ! empty( $intent->charges->data ) ) {
|
||||
foreach ( $intent->charges->data as $charge ) {
|
||||
if ( empty( $charge->payment_method_details->card->mandate ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$mandate_id = $charge->payment_method_details->card->mandate;
|
||||
edd_update_order_meta( $order->id, '_edds_stripe_mandate', $mandate_id );
|
||||
|
||||
edd_add_note(
|
||||
array(
|
||||
'object_id' => $order->id,
|
||||
'content' => 'Stripe Mandate ID: ' . $mandate_id,
|
||||
'user_id' => is_admin() ? get_current_user_id() : 0,
|
||||
'object_type' => 'order',
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Attach the \Stripe\Customer ID to the \EDD_Customer meta if one exists.
|
||||
$edd_customer = new EDD_Customer( $purchase_data['user_email'] );
|
||||
|
||||
@ -682,7 +728,13 @@ add_action( 'wp_ajax_nopriv_edds_create_and_complete_order', 'edds_create_and_co
|
||||
function edds_payment_elements_rate_limit_tick() {
|
||||
// Increase the card error count.
|
||||
edd_stripe()->rate_limiting->increment_card_error_count();
|
||||
exit();
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
'is_at_limit' => edd_stripe()->rate_limiting->has_hit_card_error_limit(),
|
||||
'message' => edd_stripe()->rate_limiting->get_rate_limit_error_message(),
|
||||
)
|
||||
);
|
||||
}
|
||||
add_action( 'wp_ajax_edds_payment_elements_rate_limit_tick', 'edds_payment_elements_rate_limit_tick' );
|
||||
add_action( 'wp_ajax_nopriv_edds_payment_elements_rate_limit_tick', 'edds_payment_elements_rate_limit_tick' );
|
||||
@ -698,7 +750,7 @@ add_action( 'wp_ajax_nopriv_edds_payment_elements_rate_limit_tick', 'edds_paymen
|
||||
function edds_get_payment_description( $cart_details ) {
|
||||
$purchase_summary = '';
|
||||
|
||||
if( is_array( $cart_details ) && ! empty( $cart_details ) ) {
|
||||
if ( is_array( $cart_details ) && ! empty( $cart_details ) ) {
|
||||
foreach( $cart_details as $item ) {
|
||||
$purchase_summary .= $item['name'];
|
||||
$price_id = isset( $item['item_number']['options']['price_id'] )
|
||||
@ -715,7 +767,7 @@ function edds_get_payment_description( $cart_details ) {
|
||||
$purchase_summary = rtrim( $purchase_summary, ', ' );
|
||||
}
|
||||
|
||||
// Stripe has a maximum of 999 characters in the charge description
|
||||
// Stripe has a maximum of 999 characters in the charge description.
|
||||
$purchase_summary = substr( $purchase_summary, 0, 1000 );
|
||||
|
||||
return html_entity_decode( $purchase_summary, ENT_COMPAT, 'UTF-8' );
|
||||
|
@ -135,6 +135,15 @@ function edds_output_payment_elements_form() {
|
||||
?>
|
||||
|
||||
<div id="edd-card-wrap">
|
||||
<?php if ( edd_stripe()->has_regional_support && edd_stripe()->regional_support->requires_card_name ) : ?>
|
||||
<p id="edd-card-name-wrap">
|
||||
<label for="card_name" class="edd-label">
|
||||
<?php esc_html_e( 'Name on the Card', 'easy-digital-downloads' ); ?>
|
||||
<span class="edd-required-indicator">*</span>
|
||||
</label>
|
||||
<input type="text" name="card_name" id="card_name" class="card-name edd-input required" placeholder="<?php esc_attr_e( 'Card name', 'easy-digital-downloads' ); ?>" autocomplete="cc-name" required/>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
<div id="edd-stripe-payment-element"></div>
|
||||
<p class="edds-field-spacer-shim"></p><!-- Extra spacing -->
|
||||
</div>
|
||||
|
@ -0,0 +1,225 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Adds support for Stripe Mandates.
|
||||
*
|
||||
* Mandates are added to the Payment and Setup Intents whenever a subscription is being purchased
|
||||
* to accommodate for banking regulations to assist in renewal payments.
|
||||
*
|
||||
* @since 2.9.2.2
|
||||
*/
|
||||
class EDD_Stripe_Mandates {
|
||||
/**
|
||||
* The purchase data.
|
||||
*
|
||||
* @since 2.9.2.2
|
||||
* @var array
|
||||
*/
|
||||
protected $purchase_data = array();
|
||||
|
||||
/**
|
||||
* The intent type.
|
||||
*
|
||||
* @since 2.9.2.2
|
||||
* @var string
|
||||
*/
|
||||
protected $intent_type = '';
|
||||
|
||||
/**
|
||||
* The amount to charge.
|
||||
*
|
||||
* @since 2.9.2.2
|
||||
* @var int
|
||||
*/
|
||||
protected $amount = 0;
|
||||
|
||||
/**
|
||||
* The currency to charge.
|
||||
*
|
||||
* @since 2.9.2.2
|
||||
* @var string
|
||||
*/
|
||||
protected $currency = '';
|
||||
|
||||
/**
|
||||
* The amount type.
|
||||
*
|
||||
* @since 2.9.2.2
|
||||
* @var string
|
||||
*/
|
||||
protected $amount_type = 'maximum';
|
||||
|
||||
/**
|
||||
* The interval.
|
||||
*
|
||||
* @since 2.9.2.2
|
||||
* @var string
|
||||
*/
|
||||
protected $interval = '';
|
||||
|
||||
/**
|
||||
* The interval count.
|
||||
*
|
||||
* @since 2.9.2.2
|
||||
* @var int
|
||||
*/
|
||||
protected $interval_count = 0;
|
||||
|
||||
/**
|
||||
* The reference.
|
||||
*
|
||||
* @since 2.9.2.2
|
||||
* @var string
|
||||
*/
|
||||
protected $reference = '';
|
||||
|
||||
/**
|
||||
* The mandate options.
|
||||
*
|
||||
* @since 2.9.2.2
|
||||
* @var array
|
||||
*/
|
||||
public $mandate_options = array();
|
||||
|
||||
/**
|
||||
* Instaniate the class to generate mandates.
|
||||
*
|
||||
* @since 2.9.2.2
|
||||
*
|
||||
* @param array $purchase_data The purchase data.
|
||||
* @param string $intent_type The intent type.
|
||||
*/
|
||||
public function __construct( $purchase_data = array(), $intent_type = 'PaymentIntent' ) {
|
||||
// Save the purchase data locally, for use later.
|
||||
$this->purchase_data = $purchase_data;
|
||||
$this->intent_type = $intent_type;
|
||||
|
||||
$this->amount = $this->format_amount();
|
||||
$this->currency = edd_get_currency();
|
||||
$this->reference = $purchase_data['purchase_key'];
|
||||
|
||||
// Generate the interval and interval count.
|
||||
$this->get_interval_and_count( $purchase_data );
|
||||
|
||||
// Now that all the data has been determined, generate the mandate options.
|
||||
$this->generate_mandate_arguments();
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the amount into a Stripe-friendly format.
|
||||
*
|
||||
* @since 2.9.2.2
|
||||
*
|
||||
* @return int The formatted amount.
|
||||
*/
|
||||
private function format_amount() {
|
||||
$amount = $this->purchase_data['price'];
|
||||
|
||||
if ( edds_is_zero_decimal_currency() ) {
|
||||
return $amount;
|
||||
}
|
||||
|
||||
return round( $amount * 100, 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the interval and interval count for the mandate.
|
||||
*
|
||||
* @since 2.9.2.2
|
||||
*/
|
||||
private function get_interval_and_count() {
|
||||
/**
|
||||
* Setup intervals based on the Recurring Payment periods.
|
||||
*
|
||||
* We use a foreach here, but with Payment Elements, it's only a single subscription, we just
|
||||
* want to properly itterate on them.
|
||||
*/
|
||||
$period = false;
|
||||
foreach ( $this->purchase_data['downloads'] as $download ) {
|
||||
|
||||
// This is a non-recurring download. Move along.
|
||||
if ( ! isset( $download['options']['recurring'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$period = $download['options']['recurring']['period'];
|
||||
break;
|
||||
}
|
||||
|
||||
// Setup intervals for the mandate based on the Recurring Payment periods.
|
||||
switch ( $period ) {
|
||||
case 'day':
|
||||
$interval = 'day';
|
||||
$interval_count = 1;
|
||||
break;
|
||||
case 'week':
|
||||
$interval = 'week';
|
||||
$interval_count = 1;
|
||||
break;
|
||||
case 'month':
|
||||
$interval = 'month';
|
||||
$interval_count = 1;
|
||||
break;
|
||||
case 'quarter':
|
||||
$interval = 'month';
|
||||
$interval_count = 3;
|
||||
break;
|
||||
case 'semi-year':
|
||||
$interval = 'month';
|
||||
$interval_count = 6;
|
||||
break;
|
||||
case 'year':
|
||||
$interval = 'year';
|
||||
$interval_count = 1;
|
||||
break;
|
||||
default:
|
||||
$interval = 'sporadic';
|
||||
$interval_count = false;
|
||||
break;
|
||||
}
|
||||
|
||||
$this->interval = $interval;
|
||||
|
||||
if ( false !== $interval_count ) {
|
||||
$this->interval_count = $interval_count;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the mandate options for use with an intent.
|
||||
*
|
||||
* @since 2.9.2.2
|
||||
*/
|
||||
private function generate_mandate_arguments() {
|
||||
$mandate_options = array(
|
||||
'reference' => $this->reference,
|
||||
'amount' => $this->amount,
|
||||
'start_date' => current_time( 'timestamp' ),
|
||||
'amount_type' => 'maximum',
|
||||
'supported_types' => array( 'india' ),
|
||||
'interval' => $this->interval,
|
||||
);
|
||||
|
||||
if ( false !== $this->interval_count ) {
|
||||
$mandate_options['interval_count'] = $this->interval_count;
|
||||
}
|
||||
|
||||
// SetupIntent types require the currency to be passed with the mandate_options.
|
||||
if ( 'SetupIntent' === $this->intent_type ) {
|
||||
$mandate_options['currency'] = edd_get_currency();
|
||||
}
|
||||
|
||||
/**
|
||||
* Alllows further customization of the mandate options sent with the intent.
|
||||
*
|
||||
* @since 2.9.2.2
|
||||
*
|
||||
* @param array $mandate_options The set of mandate options we've generated.
|
||||
* @param array $purchase_data The purchase data being processed.
|
||||
* @param string $intent_type The intent type (either SetupIntent or PaymentIntent).
|
||||
*/
|
||||
$mandate_options = apply_filters( 'edds_mandate_options', $mandate_options, $this->purchase_data, $this->intent_type );
|
||||
|
||||
$this->mandate_options = $mandate_options;
|
||||
}
|
||||
}
|
@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Generic Regionality functionality class for EDD Stripe.
|
||||
*
|
||||
* @package EDD_Stripe
|
||||
* @since 2.9.2.2
|
||||
*/
|
||||
abstract class EDD_Stripe_Region_Base {
|
||||
|
||||
/**
|
||||
* Country code.
|
||||
*
|
||||
* @since 2.9.2.2
|
||||
* @var string
|
||||
*/
|
||||
public $country_code;
|
||||
|
||||
/**
|
||||
* If the country requires a card name.
|
||||
*
|
||||
* @since 2.9.2.2
|
||||
* @var bool
|
||||
*/
|
||||
public $requires_card_name;
|
||||
|
||||
/**
|
||||
* If the country requires a card address.
|
||||
*
|
||||
* @since 2.9.2.2
|
||||
* @var bool
|
||||
*/
|
||||
public $requires_card_address;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 2.9.2.2
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->setup_filters();
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies various filters.
|
||||
*/
|
||||
protected function setup_filters() {
|
||||
// Possibly add a message above the address fields if they are required.
|
||||
add_filter( 'edd_settings_gateways', array( $this, 'add_billing_address_message' ), 30 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a descriptive text setting prior to the address fields setting if a region requires card address.
|
||||
*
|
||||
* @since 2.9.2.2
|
||||
*
|
||||
* @param array $settings The current registered settings.
|
||||
*
|
||||
* @return array The settings with the new descriptive text, if necessary.
|
||||
*/
|
||||
public function add_billing_address_message( $settings ) {
|
||||
// The current region does not require card address.
|
||||
if ( ! $this->requires_card_address ) {
|
||||
return $settings;
|
||||
}
|
||||
|
||||
$current_billing_fields_option = edd_get_option( 'stripe_billing_fields' );
|
||||
// The current region requires card address, but the billing fields option is set to "full" already.
|
||||
if ( 'full' === $current_billing_fields_option ) {
|
||||
return $settings;
|
||||
}
|
||||
|
||||
$setting = array(
|
||||
'id' => 'stripe_billing_address_message',
|
||||
'name' => '',
|
||||
'desc' => $this->get_billing_fields_message_output(),
|
||||
'type' => 'descriptive_text',
|
||||
'class' => 'edd-stripe-connect-row',
|
||||
);
|
||||
|
||||
$position = array_search(
|
||||
'stripe_billing_fields',
|
||||
array_keys(
|
||||
$settings['edd-stripe']
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
array_splice(
|
||||
$settings['edd-stripe'],
|
||||
$position,
|
||||
0,
|
||||
array(
|
||||
'stripe_billing_address_message' => $setting,
|
||||
)
|
||||
);
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output a message concerning regions that should collect 'full address' information.
|
||||
*
|
||||
* @since 2.9.2.2
|
||||
*/
|
||||
protected function get_billing_fields_message_output() {
|
||||
ob_start();
|
||||
?>
|
||||
<div id="edds-stripe-billing-fields-message" class="notice inline notice-warning">
|
||||
<p>
|
||||
<?php
|
||||
printf(
|
||||
esc_html__( 'Based on your store\'s base country of %s, it is recommended to set your Billing Address Display to use the "Full Address" option to ensure payments are completed successfully.', 'easy-digital-downloads' ),
|
||||
edd_get_country_name( edd_get_option( 'base_country', 'US' ) )
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* India Regionality functionality class for EDD Stripe.
|
||||
*/
|
||||
class EDD_Stripe_Region_IN extends EDD_Stripe_Region_Base {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->country_code = 'IN';
|
||||
$this->requires_card_name = true;
|
||||
$this->requires_card_address = true;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
@ -429,7 +429,8 @@ class ClassLoader
|
||||
public function loadClass($class)
|
||||
{
|
||||
if ($file = $this->findFile($class)) {
|
||||
(self::$includeFile)($file);
|
||||
$includeFile = self::$includeFile;
|
||||
$includeFile($file);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -560,7 +561,10 @@ class ClassLoader
|
||||
return false;
|
||||
}
|
||||
|
||||
private static function initializeIncludeClosure(): void
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
private static function initializeIncludeClosure()
|
||||
{
|
||||
if (self::$includeFile !== null) {
|
||||
return;
|
||||
@ -574,8 +578,8 @@ class ClassLoader
|
||||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
self::$includeFile = static function($file) {
|
||||
self::$includeFile = \Closure::bind(static function($file) {
|
||||
include $file;
|
||||
};
|
||||
}, null, null);
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ class InstalledVersions
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (isset($installed['versions'][$packageName])) {
|
||||
return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
|
||||
return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,7 +119,7 @@ class InstalledVersions
|
||||
*/
|
||||
public static function satisfies(VersionParser $parser, $packageName, $constraint)
|
||||
{
|
||||
$constraint = $parser->parseConstraints($constraint);
|
||||
$constraint = $parser->parseConstraints((string) $constraint);
|
||||
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
|
||||
|
||||
return $provided->matches($constraint);
|
||||
@ -328,7 +328,9 @@ class InstalledVersions
|
||||
if (isset(self::$installedByVendor[$vendorDir])) {
|
||||
$installed[] = self::$installedByVendor[$vendorDir];
|
||||
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
||||
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
|
||||
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
||||
$required = require $vendorDir.'/composer/installed.php';
|
||||
$installed[] = self::$installedByVendor[$vendorDir] = $required;
|
||||
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
|
||||
self::$installed = $installed[count($installed) - 1];
|
||||
}
|
||||
@ -340,12 +342,17 @@ class InstalledVersions
|
||||
// only require the installed.php file if this file is loaded from its dumped location,
|
||||
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
||||
if (substr(__DIR__, -8, 1) !== 'C') {
|
||||
self::$installed = require __DIR__ . '/installed.php';
|
||||
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
||||
$required = require __DIR__ . '/installed.php';
|
||||
self::$installed = $required;
|
||||
} else {
|
||||
self::$installed = array();
|
||||
}
|
||||
}
|
||||
$installed[] = self::$installed;
|
||||
|
||||
if (self::$installed !== array()) {
|
||||
$installed[] = self::$installed;
|
||||
}
|
||||
|
||||
return $installed;
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php return array(
|
||||
'root' => array(
|
||||
'name' => 'easy-digital-downloads/edd-stripe',
|
||||
'pretty_version' => 'dev-master',
|
||||
'version' => 'dev-master',
|
||||
'reference' => '47178f1567076390fc6f41a5c5ebdf986b915165',
|
||||
'pretty_version' => '2.9.2.2',
|
||||
'version' => '2.9.2.2',
|
||||
'reference' => '7e59ac4f4357cb3b388182e0601056f60f0b2407',
|
||||
'type' => 'wordpress-plugin',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
@ -11,9 +11,9 @@
|
||||
),
|
||||
'versions' => array(
|
||||
'easy-digital-downloads/edd-stripe' => array(
|
||||
'pretty_version' => 'dev-master',
|
||||
'version' => 'dev-master',
|
||||
'reference' => '47178f1567076390fc6f41a5c5ebdf986b915165',
|
||||
'pretty_version' => '2.9.2.2',
|
||||
'version' => '2.9.2.2',
|
||||
'reference' => '7e59ac4f4357cb3b388182e0601056f60f0b2407',
|
||||
'type' => 'wordpress-plugin',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
|
Reference in New Issue
Block a user