Skip to content

Commit

Permalink
Change to setup_intents.
Browse files Browse the repository at this point in the history
  • Loading branch information
scottyzen committed Mar 27, 2024
1 parent 93398f6 commit f861b10
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 54 deletions.
6 changes: 3 additions & 3 deletions plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "woonuxt Settings",
"version": "1.0.53",
"download_url": "https://github.com/scottyzen/woonuxt-settings/releases/download/1.0.53/woonuxt-settings.zip",
"version": "1.0.54",
"download_url": "https://github.com/scottyzen/woonuxt-settings/releases/download/1.0.54/woonuxt-settings.zip",

"homepage": "https://woonuxt.com/",
"tested": "6.4.3",
Expand All @@ -13,7 +13,7 @@
"sections": {
"description": "WooNuxt is unmatched when it comes to performance and scalability. Reap the benefits of having a online store that out performs all of your competitors.",
"installation": "(Recommended) Installation instructions.",
"changelog": "<h2>1.0.53</h2>Add stripePaymentIntent for 3d secure.<p></p><h2>1.0.52</h2>Bump version.<p></p><h2>1.0.51</h2><p>Inhance Social media fileds and schema.</p><<h2>1.0.50</h2><p>Add SEO settings</p><h2>1.0.49</h2><p>Add functionality to increase max query amount if there are more than 100 products</p><h2>1.0.45</h2><p>Fix error when WooCommerce is disabled or not installed</p>"
"changelog": "<h2>1.0.54</h2>Change to setup_intents.<p><h2>1.0.53</h2>Add stripePaymentIntent for 3d secure.<p></p><h2>1.0.52</h2>Bump version.<p></p><h2>1.0.51</h2><p>Inhance Social media fileds and schema.</p><<h2>1.0.50</h2><p>Add SEO settings</p><h2>1.0.49</h2><p>Add functionality to increase max query amount if there are more than 100 products</p><h2>1.0.45</h2><p>Fix error when WooCommerce is disabled or not installed</p>"
},

"icons": {
Expand Down
100 changes: 49 additions & 51 deletions woonuxt.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Author: Scott Kennedy
Author URI: http://scottyzen.com
Plugin URI: https://github.com/scottyzen/woonuxt-settings
Version: 1.0.53
Version: 1.0.54
Text Domain: woonuxt
GitHub Plugin URI: scottyzen/woonuxt-settings
GitHub Plugin URI: https://github.com/scottyzen/woonuxt-settings
Expand All @@ -16,7 +16,7 @@
exit();
}

define('WOONUXT_SETTINGS_VERSION', '1.0.53');
define('WOONUXT_SETTINGS_VERSION', '1.0.54');
define('MY_WOOCOMMERCE_VERSION', '8.5.2');
define('WP_GRAPHQL_VERSION', '1.20.0');
define('WOO_GRAPHQL_VERSION', '0.19.0');
Expand Down Expand Up @@ -478,16 +478,16 @@ function global_setting_callback()
<tbody id="the-list">
<?php if (isset($options['wooNuxtSEO'])):
foreach ($options['wooNuxtSEO'] as $key => $value): ?>
<tr class="seo_item">
<td>
<span class="seo_item_provider"><?php echo $value['provider']; ?></span>
<input type="hidden" class="w-full" name="woonuxt_options[wooNuxtSEO][<?php echo $key; ?>][provider]" value="<?php echo $value['provider']; ?>" />
</td>
<td><input type="text" class="w-full" name="woonuxt_options[wooNuxtSEO][<?php echo $key; ?>][handle]" value="<?php echo $value['handle']; ?>" /></td>
<td><input type="text" class="w-full" name="woonuxt_options[wooNuxtSEO][<?php echo $key; ?>][url]" value="<?php echo $value['url']; ?>" /></td>
<td class="text-right"><a class="text-danger remove_seo_item">Delete</a></td>
</tr>
<?php endforeach;?>
<tr class="seo_item">
<td>
<span class="seo_item_provider"><?php echo $value['provider']; ?></span>
<input type="hidden" class="w-full" name="woonuxt_options[wooNuxtSEO][<?php echo $key; ?>][provider]" value="<?php echo $value['provider']; ?>" />
</td>
<td><input type="text" class="w-full" name="woonuxt_options[wooNuxtSEO][<?php echo $key; ?>][handle]" value="<?php echo $value['handle']; ?>" /></td>
<td><input type="text" class="w-full" name="woonuxt_options[wooNuxtSEO][<?php echo $key; ?>][url]" value="<?php echo $value['url']; ?>" /></td>
<td class="text-right"><a class="text-danger remove_seo_item">Delete</a></td>
</tr>
<?php endforeach;?>
<?php endif;?>
<!-- Add new line -->
<tr class="seo_item seo_item_new">
Expand Down Expand Up @@ -584,40 +584,40 @@ function global_setting_callback()
<tbody id="the-list">
<?php if (isset($options['global_attributes'])):
foreach ($options['global_attributes'] as $key => $value): ?>
<tr>
<td>
<input type="text" class="flex-1" name="woonuxt_options[global_attributes][<?php echo $key; ?>][label]" value="<?php echo $value['label']; ?>" placeholder="e.g. Filter by Color" />
</td>
<td>
<select name="woonuxt_options[global_attributes][<?php echo $key; ?>][slug]">
<?php foreach ($product_attributes as $attribute):
<tr>
<td>
<input type="text" class="flex-1" name="woonuxt_options[global_attributes][<?php echo $key; ?>][label]" value="<?php echo $value['label']; ?>" placeholder="e.g. Filter by Color" />
</td>
<td>
<select name="woonuxt_options[global_attributes][<?php echo $key; ?>][slug]">
<?php foreach ($product_attributes as $attribute):
$slected_attribute = $value['slug'] == 'pa_' . $attribute->attribute_name ? 'selected' : '';
?>
<option value="pa_<?php echo $attribute->attribute_name; ?>" <?php echo $slected_attribute; ?>>
<?php echo $attribute->attribute_label; ?>
</option>
<?php
<option value="pa_<?php echo $attribute->attribute_name; ?>" <?php echo $slected_attribute; ?>>
<?php echo $attribute->attribute_label; ?>
</option>
<?php
endforeach;?>
</select>
</td>
<td>
<input type="checkbox" name="woonuxt_options[global_attributes][<?php echo $key; ?>][showCount]" value="1" <?php echo isset($value['showCount']) ? 'checked' : ''; ?> />
</td>
<td>
<input type="checkbox" name="woonuxt_options[global_attributes][<?php echo $key; ?>][hideEmpty]" value="1" <?php echo isset($value['hideEmpty']) ? 'checked' : ''; ?> />
</td>
<td>
<input type="checkbox" name="woonuxt_options[global_attributes][<?php echo $key; ?>][openByDefault]" value="1" <?php echo isset($value['openByDefault']) ? 'checked' : ''; ?> />
</td>
<td>
<div class="text-right row-actions">
<a class="text-danger remove_global_attribute">Delete</a> |
<a title="Move Up" class="text-primary move_global_attribute_up">▲</a> |
<a title="Move Down" class="text-primary move_global_attribute_down">▼</a>
</div>
</td>
</tr>
<?php endforeach;?>
</select>
</td>
<td>
<input type="checkbox" name="woonuxt_options[global_attributes][<?php echo $key; ?>][showCount]" value="1" <?php echo isset($value['showCount']) ? 'checked' : ''; ?> />
</td>
<td>
<input type="checkbox" name="woonuxt_options[global_attributes][<?php echo $key; ?>][hideEmpty]" value="1" <?php echo isset($value['hideEmpty']) ? 'checked' : ''; ?> />
</td>
<td>
<input type="checkbox" name="woonuxt_options[global_attributes][<?php echo $key; ?>][openByDefault]" value="1" <?php echo isset($value['openByDefault']) ? 'checked' : ''; ?> />
</td>
<td>
<div class="text-right row-actions">
<a class="text-danger remove_global_attribute">Delete</a> |
<a title="Move Up" class="text-primary move_global_attribute_up">▲</a> |
<a title="Move Down" class="text-primary move_global_attribute_down">▼</a>
</div>
</td>
</tr>
<?php endforeach;?>
<?php
endif;?>
</tbody>
Expand Down Expand Up @@ -754,6 +754,7 @@ function global_setting_callback()
'resolve' => function () {
$amount = floatval(WC()->cart->get_total(false)) * 100;
$currency = get_woocommerce_currency();
$currency = strtoupper($currency);
$payment_intent = create_payment_intent($amount, $currency);

return [
Expand Down Expand Up @@ -809,23 +810,20 @@ function create_payment_intent($amount, $currency)
return new WP_Error('stripe_not_installed', 'Stripe is not installed');
}

$payment_intent = WC_Stripe_API::request(
$setup_intent = WC_Stripe_API::request(
[
'amount' => $amount,
'currency' => $currency,
'payment_method_types' => ['card'],
'capture_method' => 'automatic',
],
'payment_intents'
);
'setup_intents');

if (!empty($payment_intent->error)) {
if (!empty($setup_intent->error)) {
throw new Exception($payment_intent->error->message);
}

return [
'id' => $payment_intent->id,
'client_secret' => $payment_intent->client_secret,
// 'client_secret' => $payment_intent->client_secret,
'client_secret' => $setup_intent->client_secret,
'error' => $payment_intent->error,
];
}

0 comments on commit f861b10

Please sign in to comment.