Skip to content

Commit

Permalink
Sync from Pro
Browse files Browse the repository at this point in the history
  • Loading branch information
prappo committed Jul 29, 2024
1 parent 60bb579 commit c6ebf0b
Show file tree
Hide file tree
Showing 118 changed files with 3,119 additions and 1,122 deletions.
41 changes: 0 additions & 41 deletions data/templates/giropay-payment-button.json

This file was deleted.

47 changes: 0 additions & 47 deletions data/templates/giropay-payment-form.json

This file was deleted.

11 changes: 2 additions & 9 deletions data/templates/multiple-payment-methods-form.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@
"updated_at": "2022-11-01 00:00:00",
"license": [ "personal", "plus", "professional", "ultimate", "elite" ],
"categories": [ "features-functionality" ],
"keywords": [
"on-site",
"payment-methods",
"card",
"alipay",
"ach-debit",
"giropay"
],
"keywords": [ "on-site", "payment-methods", "card", "alipay", "ach-debit" ],
"slug": "multiple-payment-methods-form",
"name": "Multiple Payment Methods Form",
"description": "Present multiple payment methods and allow the customer to choose which one to use.",
Expand All @@ -20,7 +13,7 @@
"title": "Multiple Payment Methods Form",
"description": "",
"type": "embedded",
"payment_methods": [ "card", "alipay", "ach-debit", "giropay" ],
"payment_methods": [ "card", "alipay", "ach-debit" ],
"fields": [
{
"type": "payment_request_button"
Expand Down
113 changes: 109 additions & 4 deletions includes/core/abstracts/abstract-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,102 @@ abstract class Form {
*/
public $custom_fields = array();

/**
* Form subscription amount.
*
* @since 4.11.0
* @var int|float
*/
public $subscription_amount;

/**
* Form subscription plans.
*
* @since 4.11.0
* @var array
*/
public $plans = array();

/**
* Form subscription plan.
*
* @since 4.11.0
* @var mixed
*/
public $single_plan;

/**
* Form subscription plan.
*
* @since 4.11.0
* @var mixed
*/
public $default_plan;

/**
* Form subscription display type.
*
* @since 4.11.0
* @var mixed
*/
public $subscription_display_type;

/**
* Form subscription custom amount label.
*
* @since 4.11.0
* @var string
*/
public $subscription_custom_amount_label;

/**
* Form subscription default amount.
*
* @since 4.11.0
* @var mixed
*/
public $subscription_default_amount;

/**
* Form subscription max charges.
*
* @since 4.11.0
* @var mixed
*/
public $subscription_max_charges;

/**
* Form recurring tax amount.
*
* @since 4.11.0
* @var float
*/
public $recurring_tax_amount;

/**
* Form recurring total amount.
*
* @since 4.11.0
* @var float
*/
public $recurring_total_amount;

/**
* Form recurring total amount.
*
* @since 4.11.0
* @var bool
*/
public $has_max_charges;

/**
* Form prices.
*
* @since 4.11.0
* @var mixed
*/
public $prices;

/**
* Form constructor.
*
Expand Down Expand Up @@ -305,7 +401,6 @@ public function maybe_register_hooks() {

$simpay_displayed_form_ids[ $this->id ] = true;
}

}

/**
Expand Down Expand Up @@ -725,7 +820,7 @@ private function set_bool_value( $option, $check = '' ) {
public function get_stripe_script_variables() {

// Key is required so we always include it.
$strings['strings']['key'] = $this->publishable_key;
$strings['strings']['key'] = $this->publishable_key;
$strings['strings']['stripe_api_version'] = SIMPLE_PAY_STRIPE_API_VERSION;

// Redirect URLs.
Expand Down Expand Up @@ -796,7 +891,7 @@ abstract public function has_fee_recovery();
public function has_forced_fee_recovery() {
$fee_recovery_toggle = array_filter(
$this->custom_fields,
function( $field ) {
function ( $field ) {
return 'fee_recovery_toggle' === $field['type'];
}
);
Expand Down Expand Up @@ -836,7 +931,7 @@ public function has_available_inventory() {
$individual = $this->get_individual_inventory_data();
$in_stock = array_filter(
$individual,
function( $price_option ) {
function ( $price_option ) {
return $price_option['available'] > 0;
}
);
Expand Down Expand Up @@ -1091,4 +1186,14 @@ public function get_email_notification_message() {
return get_post_meta( $this->id, '_email_notification_message', true );
}

/**
* Returns the form's multiple line items setting.
*
* @since 4.11.0
*
* @return bool
*/
public function allows_multiple_line_items() {
return 'yes' === get_post_meta( $this->id, '_allow_purchasing_multiple_line_items', true );
}
}
8 changes: 8 additions & 0 deletions includes/core/admin/class-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,14 @@ public function register() {
'recurring interval',
'stripe'
),
'priceOptionalRecurring' => esc_html__(
'Allow price to optionally be purchased as a subscription',
'stripe'
),
'priceRecurring' => esc_html__(
'Automatically activate a recurring subscription',
'stripe'
),

),
)
Expand Down
76 changes: 76 additions & 0 deletions includes/core/api/invoiceitems.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php
/**
* API: Invoice Items
*
* @package SimplePay\Core\Payments\Invoices
* @copyright Copyright (c) 2024, Sandhills Development, LLC
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 4.11.0
*/

namespace SimplePay\Core\API\InvoiceItems;

use SimplePay\Core\Payments\Stripe_API;

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

/**
* Creates a InvoiceItem.
*
* @since 4.11.0
*
* @param array $invoice_items Optional arguments used to create a invoice item.
* @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\InvoiceItem
*/
function create( $invoice_items, $api_request_args = array() ) {
return Stripe_API::request(
'InvoiceItem',
'create',
$invoice_items,
$api_request_args
);
}

/**
* Retrieves a InvoiceItem.
*
* @since 4.11.0
*
* @param string|array $invoice_item Invoice Item ID or {
* Arguments used to retrieve a InvoiceItem.
*
* @type string $id Invoice Item 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.
* }
* @param array<mixed> $opts Per-request options, default empty.
* @return \SimplePay\Vendor\Stripe\InvoiceItem
*/
function retrieve( $invoice_item, $api_request_args = array(), $opts = array() ) {
if ( false === is_array( $invoice_item ) ) {
$invoice_item_args = array(
'id' => $invoice_item,
);
} else {
$invoice_item_args = $invoice_item;
}

return Stripe_API::request(
'InvoiceItem',
'retrieve',
$invoice_item_args,
$api_request_args,
$opts
);
}
Loading

0 comments on commit c6ebf0b

Please sign in to comment.