Skip to content

Commit

Permalink
Merge pull request #194 from awesomemotive/release/4.7.0
Browse files Browse the repository at this point in the history
`release/4.7.0`
  • Loading branch information
spencerfinnell authored Feb 28, 2023
2 parents 4e325c8 + 45f0977 commit 02fcc4a
Show file tree
Hide file tree
Showing 200 changed files with 8,168 additions and 1,227 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
}
},
"require": {
"berlindb/core": "2.0",
"berlindb/core": "2.0.1",
"league/container": "2.5.0",
"psr/container": "1.0.0",
"stripe/stripe-php": "7.97.0"
"stripe/stripe-php": "10.6.0-beta.1"
},
"scripts": {
"mozart": "~/.composer/vendor/bin/mozart compose && composer dump-autoload"
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions data/templates/overlay-payment-form.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
},
{
"type": "checkout_button"
},
{
"type": "payment_button"
}
],
"prices": [
Expand Down
38 changes: 36 additions & 2 deletions includes/core/abstracts/abstract-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ abstract class Form {
*/
public $payment_success_page = '';

/**
* Payment Confirmation: Cancel.
*
* @since 3.0.0
* @var string
*/
public $payment_cancelled_page = '';

/**
* Payment Confirmation: Failure.
*
Expand All @@ -110,6 +118,14 @@ abstract class Form {
*/
public $locale = '';

/**
* Stripe Checkout submit type.
*
* @since 4.7.0
* @var string
*/
public $checkout_submit_type = 'pay';

/**
* Country code.
*
Expand Down Expand Up @@ -194,9 +210,17 @@ abstract class Form {
* Stripe Checkout: Billing address
*
* @since 3.0.0
* @var string
* @var bool
*/
public $enable_billing_address = '';
public $enable_billing_address = false;

/**
* Stripe Checkout: Shipping address
*
* @since 3.0.0
* @var bool
*/
public $enable_shipping_address = false;

/**
* Form ID.
Expand Down Expand Up @@ -747,6 +771,16 @@ public function get_stripe_script_variables() {
return apply_filters( 'simpay_stripe_script_variables', array_merge( $strings, $bools ) );
}

/**
* Determines if the payment form has fee recovery enabled for any of the payment methods.
*
* @since 4.7.0
*
* @param \SimplePay\Core\Abstracts\Form $form The payment form.
* @return bool
*/
abstract public function has_fee_recovery();

/**
* Determines if the payment form forces fee recovery to be paid.
*
Expand Down
37 changes: 32 additions & 5 deletions includes/core/admin/class-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,30 @@ public function register() {
'simpay-admin',
'simpayAdmin',
array(
'siteTitle' => get_bloginfo( 'name' ),
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'simpay-admin' ),
'licenseLevel' => simpay_get_license()->get_level(),
'i18n' => array(
'siteTitle' => get_bloginfo( 'name' ),
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'simpay-admin' ),
'licenseLevel' => simpay_get_license()->get_level(),
'currency' => simpay_get_setting( 'currency', 'USD' ),
'currencySymbol' => html_entity_decode(
simpay_get_saved_currency_symbol()
),
'currencyPosition' => simpay_get_currency_position(),
'decimalSeparator' => simpay_get_decimal_separator(),
'thousandSeparator' => simpay_get_thousand_separator(),
'decimalPlaces' => simpay_get_decimal_places(),
'minAmount' => simpay_global_minimum_amount(),
'isUpe' => simpay_is_upe(),
'i18n' => array(
'dateFormat' => simpay_get_date_format(),
'mediaTitle' => esc_html__(
'Insert Media',
'stripe'
),
'mediaButtonText' => esc_html__(
'Use Image',
'stripe'
),
'leavePageConfirm' => esc_html__(
'The changes you made will be lost if you navigate away from this page.',
'stripe'
Expand Down Expand Up @@ -228,6 +246,15 @@ public function register() {
'Warning: Removing a payment form will prevent active subscriptions from sending upcoming invoice and invoice receipt emails. It is recommended to leave payment forms that have accepted Live Mode payments published.',
'stripe'
),
/* translators: Minimum payment amount. */
'customAmountLabel' => esc_html__( 'starting at %s', 'stripe' ),
'recurringIntervals' => simpay_get_recurring_intervals(),
/* translators: %1$s Recurring amount. %2$s Recurring interval count. %3$s Recurring interval. */
'recurringIntervalDisplay' => esc_html_x(
'%1$s every %2$s %3$s',
'recurring interval',
'stripe'
),
),
)
);
Expand Down
4 changes: 2 additions & 2 deletions includes/core/admin/fields/class-checkbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function html() {
}

?>
<fieldset class="<?php echo $this->class; ?>" <?php echo ! empty( $this->style ) ? 'style="' . $this->style . '"' : ''; ?>>
<fieldset <?php echo ! empty( $this->style ) ? 'style="' . $this->style . '"' : ''; ?>>
<?php

if ( ! empty( $this->title ) ) {
Expand All @@ -65,7 +65,7 @@ public function html() {
<label for="<?php echo $this->id . '-' . trim( strval( $option ) ); ?>">
<input name="<?php echo $this->name; ?>"
id="<?php echo $this->id . '-' . trim( strval( $option ) ); ?>"
class="simpay-field simpay-field-checkbox"
class="simpay-field simpay-field-checkbox <?php echo $this->class; ?>"
type="checkbox"
value="<?php echo trim( strval( $option ) ); ?>"
<?php checked( $this->value, 'yes', true ); ?>
Expand Down
18 changes: 10 additions & 8 deletions includes/core/admin/fields/class-radio.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ public function html() {
if ( ! empty( $this->options ) && is_array( $this->options ) && count( $this->options ) > 0 ) {
?>

<fieldset id="<?php echo $this->id; ?>"
class="<?php echo $this->class; ?>"
<?php echo $this->style ? 'style="' . $this->style . '"' : ''; ?>>
<fieldset
id="<?php echo $this->id; ?>"
<?php echo $this->style ? 'style="' . $this->style . '"' : ''; ?>
>
<?php

if ( ! empty( $this->title ) ) :
Expand All @@ -79,11 +80,12 @@ class="<?php echo $this->class; ?>"
<?php foreach ( $this->options as $option => $name ) : ?>
<li>
<label for="<?php echo $this->id . '-' . trim( strval( $option ) ); ?>">
<input name="<?php echo $this->name; ?>"
id="<?php echo $this->id . '-' . trim( strval( $option ) ); ?>"
class="simpay-field simpay-field-radio"
type="radio"
value="<?php echo trim( strval( $option ) ); ?>"
<input
name="<?php echo $this->name; ?>"
id="<?php echo $this->id . '-' . trim( strval( $option ) ); ?>"
class="simpay-field simpay-field-radio <?php echo $this->class; ?>"
type="radio"
value="<?php echo trim( strval( $option ) ); ?>"
<?php echo $this->attributes; ?>
<?php checked( $option, $this->value, true ); ?>
/>
Expand Down
121 changes: 121 additions & 0 deletions includes/core/api/charges.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<?php
/**
* API: Charges
*
* @package SimplePay
* @copyright Copyright (c) 2023, Sandhills Development, LLC
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 4.7.0
*/

namespace SimplePay\Core\API\Charges;

use SimplePay\Core\Payments\Stripe_API;

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}

/**
* Retrieves a Charge.
*
* @since 3.9.0
*
* @param string|array $charge Charge ID or {
* Arguments used to retrieve a Charge.
*
* @type string $id Charge ID.
* }
* @param array $api_request_args {
* Additional request arguments to send to the Stripe API when making a request.
*
* @type string $api_key API Secret Key to use.
* }
* @return \SimplePay\Vendor\Stripe\Charge
*/
function retrieve( $charge, $api_request_args = array() ) {
return Stripe_API::request(
'Charge',
'retrieve',
$charge,
$api_request_args
);
}

/**
* Retrieves Charges.
*
* @since 3.9.0
*
* @param array $charges Optional arguments used when listing Charges.
* @param array $api_request_args {
* Additional request arguments to send to the Stripe API when making a request.
*
* @type string $api_key API Secret Key to use.
* }
* @return \SimplePay\Vendor\Stripe\Charge[]
*/
function all( $charges = array(), $api_request_args = array() ) {
return Stripe_API::request(
'Charge',
'all',
$charges,
$api_request_args
);
}

/**
* Creates a Charge.
*
* @since 3.9.0
*
* @param array $charge_args Arguments used to create a Charge.
* @param array $api_request_args {
* Additional request arguments to send to the Stripe API when making a request.
*
* @type string $api_key API Secret Key to use.
* }
* @return \SimplePay\Vendor\Stripe\Charge
*/
function create( $charge_args, $api_request_args = array() ) {
$defaults = array();
$charge_args = wp_parse_args( $charge_args, $defaults );

/**
* Filter the arguments used to generate a Charge.
*
* @since 3.9.0
*
* @param array $charge_args Arguemnts used to generate a Charge.
*/
$charge_args = apply_filters( 'simpay_create_charge_args', $charge_args );

/**
* Allows processing before a PaymentIntenet is created.
*
* @since 3.9.0
*
* @param array $charge_args Arguments used to create a Charge.
*/
do_action( 'simpay_before_charge_created', $charge_args );

// Create Charge.
$charge = Stripe_API::request(
'Charge',
'create',
$charge_args,
$api_request_args
);

/**
* Allows further processing after a Charge has been created.
*
* @since 3.9.0
*
* @param \SimplePay\Vendor\Stripe\Charge $charge Charge.
*/
do_action( 'simpay_after_charge_created', $charge );

return $charge;
}
Loading

0 comments on commit 02fcc4a

Please sign in to comment.