PluginProbe ʕ •ᴥ•ʔ
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments / 2.13.0
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments v2.13.0
4.4.2 4.4.1 4.4.0 4.3.3 4.3.2 4.3.1 4.3.0 4.2.3 4.2.2 4.2.1 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.15 1.1.16 1.1.17 1.1.18 1.1.19 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.11.0 1.11.1 1.11.2 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.9.0 1.9.1 1.9.2 1.9.3 1.9.4 1.9.5 2.0.0 2.0.1 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.10.0 2.10.1 2.11.0 2.11.1 2.11.2 2.11.3 2.11.4 2.12.0 2.13.0 2.14.0 2.14.1 2.15.0 2.15.1 2.16.0 2.16.1 2.16.2 2.16.3 2.17.0 2.17.1 2.17.2 2.18.0 2.19.0 2.19.2 2.19.3 2.19.4 2.2.0 2.2.1 2.20.0 2.20.1 2.20.2 2.20.3 2.20.4 2.20.5 2.20.6 2.21.0 2.22.0 2.22.1 2.23.0 2.24.0 2.25.0 2.25.1 2.25.2 2.26.0 2.27.0 2.27.1 2.28.0 2.29.0 2.29.1 2.29.2 2.29.3 2.29.4 2.3.0 2.3.1 2.30.0 2.31.0 2.31.1 2.31.2 2.31.3 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.40.0 2.40.1 2.5.0 2.5.1 2.5.2 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.9.0 3.0.0 3.0.0-RC1 3.0.0-RC2 3.0.0-beta1 3.0.0-beta2 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.10.0 3.10.1 3.11.0 3.12.0 3.13.0 3.13.1 3.13.2 3.13.3 3.13.4 3.14.0 3.15.0 3.15.1 3.15.2 3.15.3 3.15.4 3.15.5 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.16.6 3.16.7 3.16.8 3.17.0 3.17.1 3.17.2 3.17.3 3.17.4 3.17.5 3.17.6 3.18.0 3.19.0 3.19.1 3.19.2 3.2.0 3.2.1 3.2.2 3.20.0 3.20.1 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 3.7.0 3.7.1 3.7.2 3.7.3 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 4.0.0 4.0.1 4.0.2 4.0.3 trunk 4.1.0 0.2.19.1 4.1.1 1.0.0 4.2.0 1.0.1 1.0.2
surecart / packages / blocks / Controllers / SubscriptionController.php
surecart / packages / blocks / Controllers Last commit date
BaseController.php 3 years ago ChargeController.php 3 years ago CustomerController.php 3 years ago DownloadController.php 3 years ago InvoiceController.php 3 years ago OrderController.php 2 years ago PaymentMethodController.php 2 years ago SubscriptionController.php 2 years ago UserController.php 3 years ago
SubscriptionController.php
644 lines
1 <?php
2 namespace SureCartBlocks\Controllers;
3
4 use SureCart\Models\Component;
5 use SureCart\Models\Price;
6 use SureCart\Models\Product;
7 use SureCart\Models\Subscription;
8 use SureCart\Models\SubscriptionProtocol;
9 use SureCart\Models\User;
10
11 /**
12 * The subscription controller.
13 */
14 class SubscriptionController extends BaseController {
15 /**
16 * Render the block
17 *
18 * @param array $attributes Block attributes.
19 * @return function
20 */
21 public function preview( $attributes = [] ) {
22 return wp_kses_post(
23 Component::tag( 'sc-subscriptions-list' )
24 ->id( 'customer-subscriptions-preview' )
25 ->with(
26 [
27 'heading' => $attributes['title'] ?? null,
28 'isCustomer' => User::current()->isCustomer(),
29 'allLink' => add_query_arg(
30 [
31 'tab' => $this->getTab(),
32 'model' => 'subscription',
33 'action' => 'index',
34 ],
35 remove_query_arg( array_keys( $_GET ) ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
36 ),
37 'query' => [
38 'customer_ids' => array_values( User::current()->customerIds() ),
39 'status' => [ 'active', 'trialing', 'past_due', 'canceled' ],
40 'page' => 1,
41 'per_page' => 5,
42 ],
43 ]
44 )->render( $attributes['title'] ? "<span slot='heading'>" . $attributes['title'] . '</span>' : '' )
45 );
46 }
47
48 /**
49 * Render the block
50 *
51 * @return function
52 */
53 public function index() {
54 \SureCart::assets()->addComponentData(
55 'sc-subscriptions-list',
56 '#customer-subscriptions-index',
57 [
58 'heading' => $attributes['title'] ?? __( 'Plans', 'surecart' ),
59 'isCustomer' => User::current()->isCustomer(),
60 'query' => [
61 'customer_ids' => array_values( User::current()->customerIds() ),
62 'status' => [ 'active', 'trialing', 'canceled' ],
63 'page' => 1,
64 'per_page' => 20,
65 ],
66 ]
67 );
68 ob_start();
69 ?>
70 <sc-spacing style="--spacing: var(--sc-spacing-large)">
71 <sc-breadcrumbs>
72 <sc-breadcrumb href="<?php echo esc_url( add_query_arg( [ 'tab' => $this->getTab() ], remove_query_arg( array_keys( $_GET ) ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended ?>">
73 <?php esc_html_e( 'Dashboard', 'surecart' ); ?>
74 </sc-breadcrumb>
75 <sc-breadcrumb>
76 <?php esc_html_e( 'Plans', 'surecart' ); ?>
77 </sc-breadcrumb>
78 </sc-breadcrumbs>
79 <sc-subscriptions-list id="customer-subscriptions-index"></sc-subscriptions-list>
80 </sc-spacing>
81 <?php
82 return ob_get_clean();
83 }
84
85 /**
86 * Show and individual checkout session.
87 *
88 * @return function
89 */
90 public function edit() {
91 $id = $this->getId();
92
93 if ( ! $id ) {
94 return $this->notFound();
95 }
96
97 // fetch subscription.
98 $subscription = Subscription::with(
99 [
100 'price',
101 'price.product',
102 'product.product_group',
103 'current_period',
104 'period.checkout',
105 'purchase',
106 'discount',
107 'discount.coupon',
108 'purchase.license',
109 'license.activations',
110 ]
111 )->find( $id );
112
113 $should_delay_cancellation = $subscription->shouldDelayCancellation();
114 ob_start();
115 ?>
116
117 <sc-spacing style="--spacing: var(--sc-spacing-large)">
118 <sc-breadcrumbs>
119 <sc-breadcrumb href="<?php echo esc_url( add_query_arg( [ 'tab' => $this->getTab() ], remove_query_arg( array_keys( $_GET ) ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended ?>">
120 <?php esc_html_e( 'Dashboard', 'surecart' ); ?>
121 </sc-breadcrumb>
122 <sc-breadcrumb href="
123 <?php
124 echo esc_url(
125 add_query_arg(
126 [
127 'tab' => $this->getTab(),
128 'action' => 'index',
129 'model' => 'subscription',
130 ],
131 remove_query_arg( array_keys( $_GET ) ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
132 )
133 );
134 ?>
135 ">
136 <?php esc_html_e( 'Plans', 'surecart' ); ?>
137 </sc-breadcrumb>
138 <sc-breadcrumb>
139 <?php esc_html_e( 'Plan', 'surecart' ); ?>
140 </sc-breadcrumb>
141 </sc-breadcrumbs>
142
143 <?php
144 echo wp_kses_post(
145 Component::tag( 'sc-subscription' )
146 ->id( 'customer-subscription-edit' )
147 ->with(
148 [
149 'heading' => __( 'Current Plan', 'surecart' ),
150 'showCancel' => \SureCart::account()->portal_protocol->subscription_cancellations_enabled && ! $subscription->remaining_period_count && ! $should_delay_cancellation,
151 'protocol' => SubscriptionProtocol::with( [ 'preservation_coupon' ] )->find(), // \SureCart::account()->subscription_protocol,
152 'subscription' => $subscription,
153 ]
154 )->render()
155 );
156 ?>
157
158 <?php
159 // show switch if we can change it.
160 if ( $subscription->canBeSwitched() ) :
161 echo wp_kses_post(
162 Component::tag( 'sc-subscription-switch' )
163 ->id( 'customer-subscription-switch' )
164 ->with(
165 [
166 'heading' => __( 'Update Plan', 'surecart' ),
167 'productId' => $subscription->price->product->id,
168 'productGroupId' => $subscription->price->product->product_group->archived ? null : $subscription->price->product->product_group->id,
169 'subscription' => $subscription,
170 ]
171 )->render()
172 );
173 endif;
174 ?>
175
176 </sc-spacing>
177
178 <?php
179 return ob_get_clean();
180 }
181
182 /**
183 * Update the subscription payment method
184 *
185 * @return string
186 */
187 public function update_payment_method() {
188 $id = $this->getId();
189
190 if ( ! $id ) {
191 return $this->notFound();
192 }
193
194 // fetch subscription.
195 $subscription = Subscription::with(
196 [
197 'price',
198 'price.product',
199 'current_period',
200 'period.checkout',
201 'discount',
202 'discount.coupon',
203 ]
204 )->find( $id );
205
206 ob_start();
207 ?>
208
209 <sc-spacing style="--spacing: var(--sc-spacing-large)">
210 <sc-breadcrumbs>
211 <sc-breadcrumb href="<?php echo esc_url( add_query_arg( [ 'tab' => $this->getTab() ], remove_query_arg( array_keys( $_GET ) ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended ?>">
212 <?php esc_html_e( 'Dashboard', 'surecart' ); ?>
213 </sc-breadcrumb>
214 <sc-breadcrumb href="
215 <?php
216 echo esc_url(
217 add_query_arg(
218 [
219 'tab' => $this->getTab(),
220 'action' => 'index',
221 'model' => 'subscription',
222 ],
223 remove_query_arg( array_keys( $_GET ) ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
224 )
225 );
226 ?>
227 ">
228 <?php esc_html_e( 'Plans', 'surecart' ); ?>
229 </sc-breadcrumb>
230 <sc-breadcrumb href="
231 <?php
232 echo esc_url(
233 add_query_arg(
234 [
235 'tab' => $this->getTab(),
236 'action' => 'edit',
237 'model' => 'subscription',
238 'id' => $this->getId(),
239 ],
240 remove_query_arg( array_keys( $_GET ) ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
241 )
242 );
243 ?>
244 ">
245 <?php esc_html_e( 'Plan', 'surecart' ); ?>
246 </sc-breadcrumb>
247 <sc-breadcrumb>
248 <?php esc_html_e( 'Update Payment Method', 'surecart' ); ?>
249 </sc-breadcrumb>
250 </sc-breadcrumbs>
251
252 <?php
253 echo wp_kses_post(
254 Component::tag( 'sc-subscription' )
255 ->id( 'customer-subscription-edit' )
256 ->with(
257 [
258 'heading' => __( 'Current Plan', 'surecart' ),
259 'showCancel' => false,
260 'subscription' => $subscription,
261 ]
262 )->render()
263 );
264 ?>
265
266 <?php
267 echo wp_kses_post(
268 Component::tag( 'sc-subscription-payment-method' )
269 ->id( 'customer-subscription-payment-method' )
270 ->with(
271 [
272 'heading' => __( 'Change Payment Method', 'surecart' ),
273 'subscription' => $subscription,
274 ]
275 )->render()
276 );
277 ?>
278
279 </sc-spacing>
280
281 <?php
282 return ob_get_clean();
283 }
284
285
286 /**
287 * Get the terms text.
288 */
289 public function getTermsText() {
290 $account = \SureCart::account();
291 $privacy_url = $account->portal_protocol->privacy_url ?? \get_privacy_policy_url();
292 $terms_url = $account->portal_protocol->terms_url ?? '';
293
294 if ( ! empty( $privacy_url ) && ! empty( $terms_url ) ) {
295 return sprintf( __( 'By updating or canceling your plan, you agree to the <a href="%1$1s" target="_blank">%2$2s</a> and <a href="%3$3s" target="_blank">%4$4s</a>', 'surecart' ), esc_url( $terms_url ), __( 'Terms', 'surecart' ), esc_url( $privacy_url ), __( 'Privacy Policy', 'surecart' ) );
296 }
297
298 if ( ! empty( $privacy_url ) ) {
299 return sprintf( __( 'By updating or canceling your plan, you agree to the <a href="%1$1s" target="_blank">%2$2s</a>', 'surecart' ), esc_url( $privacy_url ), __( 'Privacy Policy', 'surecart' ) );
300 }
301
302 if ( ! empty( $terms_url ) ) {
303 return sprintf( __( 'By updating or canceling your plan, you agree to the <a href="%1$1s" target="_blank">%2$2s</a>', 'surecart' ), esc_url( $terms_url ), __( 'Terms', 'surecart' ) );
304 }
305
306 return '';
307 }
308
309 /**
310 * Confirm the ad_hoc amount.
311 *
312 * @return void
313 */
314 public function confirm_amount() {
315 $price = Price::find( $this->getParam( 'price_id' ) );
316 ob_start();
317 ?>
318
319 <sc-spacing style="--spacing: var(--sc-spacing-xx-large)">
320 <sc-breadcrumbs>
321 <sc-breadcrumb href="<?php echo esc_url( add_query_arg( [ 'tab' => $this->getTab() ], remove_query_arg( array_keys( $_GET ) ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended ?>">
322 <?php esc_html_e( 'Dashboard', 'surecart' ); ?>
323 </sc-breadcrumb>
324 <sc-breadcrumb href="
325 <?php
326 echo esc_url(
327 add_query_arg(
328 [
329 'tab' => $this->getTab(),
330 'action' => 'edit',
331 'model' => 'subscription',
332 'id' => $this->getId(),
333 ],
334 remove_query_arg( array_keys( $_GET ) ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
335 )
336 );
337 ?>
338 ">
339 <?php esc_html_e( 'Plan', 'surecart' ); ?>
340 </sc-breadcrumb>
341 <sc-breadcrumb>
342 <?php esc_html_e( 'Enter Amount', 'surecart' ); ?>
343 </sc-breadcrumb>
344 </sc-breadcrumbs>
345
346 <?php
347
348 echo wp_kses_post(
349 Component::tag( 'sc-subscription-ad-hoc-confirm' )
350 ->id( 'subscription-ad-hoc-confirm' )
351 ->with(
352 [
353 'heading' => __( 'Enter An Amount', 'surecart' ),
354 'price' => $price,
355 'variant' => $this->getParam( 'variant' ),
356 ]
357 )->render()
358 );
359 ?>
360
361 </sc-spacing>
362
363 <?php
364 return ob_get_clean();
365 }
366
367 /**
368 * Confirm the product variation.
369 *
370 * @return void
371 */
372 public function confirm_variation() {
373 $price = Price::find( $this->getParam( 'price_id' ) );
374 $id = $this->getId();
375
376 if ( ! $id ) {
377 return $this->notFound();
378 }
379
380 // fetch subscription.
381 $subscription = Subscription::with(
382 [
383 'price',
384 'price.product',
385 ]
386 )->find( $id );
387
388 if ( ! $subscription ) {
389 return $this->notFound();
390 }
391
392 // fetch subscription product.
393 $product = Product::with(
394 [
395 'variants',
396 'variant_options',
397 'prices',
398 ]
399 )->find( $price->product );
400
401 ob_start();
402 ?>
403
404 <sc-spacing style="--spacing: var(--sc-spacing-xx-large)">
405 <sc-breadcrumbs>
406 <sc-breadcrumb href="<?php echo esc_url( add_query_arg( [ 'tab' => $this->getTab() ], remove_query_arg( array_keys( $_GET ) ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended ?>">
407 <?php esc_html_e( 'Dashboard', 'surecart' ); ?>
408 </sc-breadcrumb>
409 <sc-breadcrumb href="
410 <?php
411 echo esc_url(
412 add_query_arg(
413 [
414 'tab' => $this->getTab(),
415 'action' => 'edit',
416 'model' => 'subscription',
417 'id' => $this->getId(),
418 ],
419 remove_query_arg( array_keys( $_GET ) ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
420 )
421 );
422 ?>
423 ">
424 <?php esc_html_e( 'Plan', 'surecart' ); ?>
425 </sc-breadcrumb>
426 <sc-breadcrumb>
427 <?php esc_html_e( 'Choose Variation', 'surecart' ); ?>
428 </sc-breadcrumb>
429 </sc-breadcrumbs>
430
431 <?php
432
433 echo wp_kses_post(
434 Component::tag( 'sc-subscription-variation-confirm' )
435 ->id( 'subscription-ad-hoc-confirm' )
436 ->with(
437 [
438 'heading' => __( 'Choose a Variation', 'surecart' ),
439 'product' => $product,
440 'subscription' => $subscription,
441 'price' => $price,
442 ]
443 )->render()
444 );
445 ?>
446
447 </sc-spacing>
448
449 <?php
450 return ob_get_clean();
451 }
452
453 /**
454 * Confirm changing subscription
455 *
456 * @return function
457 */
458 public function confirm() {
459 $back = add_query_arg( [ 'tab' => $this->getTab() ], remove_query_arg( array_keys( $_GET ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
460 ob_start();
461 ?>
462
463 <sc-spacing style="--spacing: var(--sc-spacing-xx-large)">
464 <sc-breadcrumbs>
465 <sc-breadcrumb href="<?php echo esc_url( add_query_arg( [ 'tab' => $this->getTab() ], remove_query_arg( array_keys( $_GET ) ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended ?>">
466 <?php esc_html_e( 'Dashboard', 'surecart' ); ?>
467 </sc-breadcrumb>
468 <sc-breadcrumb href="
469 <?php
470 echo esc_url(
471 add_query_arg(
472 [
473 'tab' => $this->getTab(),
474 'action' => 'edit',
475 'model' => 'subscription',
476 'id' => $this->getId(),
477 ],
478 remove_query_arg( array_keys( $_GET ) ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
479 )
480 );
481 ?>
482 ">
483 <?php esc_html_e( 'Plan', 'surecart' ); ?>
484 </sc-breadcrumb>
485 <sc-breadcrumb>
486 <?php esc_html_e( 'Confirm', 'surecart' ); ?>
487 </sc-breadcrumb>
488 </sc-breadcrumbs>
489
490 <?php
491 $terms = $this->getTermsText();
492 $quantity_enabled = (bool) \SureCart::account()->portal_protocol->subscription_quantity_updates_enabled;
493 if ( $this->getParam( 'ad_hoc_amount' ) ) {
494 $quantity_enabled = false;
495 }
496
497 echo wp_kses_post(
498 Component::tag( 'sc-upcoming-invoice' )
499 ->id( 'customer-upcoming-invoice' )
500 ->with(
501 [
502 'heading' => __( 'New Plan', 'surecart' ),
503 'subscriptionId' => $this->getId(),
504 'priceId' => $this->getParam( 'price_id' ),
505 'variantId' => $this->getParam( 'variant' ),
506 'adHocAmount' => $this->getParam( 'ad_hoc_amount' ),
507 'successUrl' => esc_url_raw( $back ),
508 'quantityUpdatesEnabled' => (bool) $quantity_enabled,
509 'quantity' => 1,
510 ]
511 )->render( $terms ? '<span slot="terms">' . wp_kses_post( $terms ) . '</span>' : '' )
512 );
513 ?>
514
515
516 </sc-spacing>
517
518 <?php
519 return ob_get_clean();
520
521 }
522
523 /**
524 * Confirm cancel subscription
525 *
526 * @return function
527 */
528 public function cancel() {
529 $back_url = add_query_arg( [ 'tab' => $this->getTab() ], remove_query_arg( array_keys( $_GET ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
530 $edit_subscription_url = add_query_arg(
531 [
532 'tab' => $this->getTab(),
533 'action' => 'edit',
534 'model' => 'subscription',
535 'id' => $this->getId(),
536 ],
537 remove_query_arg( array_keys( $_GET ) ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
538 );
539 ob_start();
540 ?>
541 <sc-spacing style="--spacing: var(--sc-spacing-xx-large)">
542 <sc-breadcrumbs>
543 <sc-breadcrumb href="<?php echo esc_url( $back_url ); ?>">
544 <?php esc_html_e( 'Dashboard', 'surecart' ); ?>
545 </sc-breadcrumb>
546 <sc-breadcrumb href="<?php echo esc_url( $edit_subscription_url ); ?>" >
547 <?php esc_html_e( 'Plan', 'surecart' ); ?>
548 </sc-breadcrumb>
549 <sc-breadcrumb>
550 <?php esc_html_e( 'Cancel', 'surecart' ); ?>
551 </sc-breadcrumb>
552 </sc-breadcrumbs>
553
554 <?php
555 echo wp_kses_post(
556 Component::tag( 'sc-subscription-cancel' )
557 ->id( 'customer-subscription-cancel' )
558 ->with(
559 [
560 'subscriptionId' => $this->getId(),
561 'backUrl' => esc_url_raw( $edit_subscription_url ),
562 'successUrl' => esc_url_raw( $back_url ),
563 ]
564 )->render()
565 );
566 ?>
567
568 </sc-spacing>
569 <?php
570 return ob_get_clean();
571 }
572
573 /**
574 * Update payment
575 *
576 * @return function
577 */
578 public function payment() {
579 $back_url = add_query_arg( [ 'tab' => $this->getTab() ], remove_query_arg( array_keys( $_GET ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
580
581 $edit_subscription_url = add_query_arg(
582 [
583 'tab' => $this->getTab(),
584 'action' => 'edit',
585 'model' => 'subscription',
586 'id' => $this->getId(),
587 ],
588 remove_query_arg( array_keys( $_GET ) ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
589 );
590
591 $confirm_subscription_url = add_query_arg(
592 [
593 'tab' => $this->getTab(),
594 'action' => 'confirm',
595 'model' => 'subscription',
596 'ad_hoc_amount' => $this->getParam( 'ad_hoc_amount' ),
597 'id' => $this->getId(),
598 'price_id' => $this->getParam( 'price_id' ),
599 ],
600 remove_query_arg( array_keys( $_GET ) ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
601 );
602
603 $subscription = Subscription::find( $this->getId() );
604 ob_start();
605 ?>
606
607 <sc-spacing style="--spacing: var(--sc-spacing-xx-large)">
608 <sc-breadcrumbs>
609 <sc-breadcrumb href="<?php echo esc_url( $back_url ); ?>">
610 <?php esc_html_e( 'Dashboard', 'surecart' ); ?>
611 </sc-breadcrumb>
612 <sc-breadcrumb href="<?php echo esc_url( $edit_subscription_url ); ?>">
613 <?php esc_html_e( 'Plan', 'surecart' ); ?>
614 </sc-breadcrumb>
615 <sc-breadcrumb href="<?php echo esc_url( $confirm_subscription_url ); ?>">
616 <?php esc_html_e( 'Confirm', 'surecart' ); ?>
617 </sc-breadcrumb>
618 <sc-breadcrumb>
619 <?php esc_html_e( 'Payment Method', 'surecart' ); ?>
620 </sc-breadcrumb>
621 </sc-breadcrumbs>
622
623 <?php
624 echo wp_kses_post(
625 Component::tag( 'sc-subscription-payment' )
626 ->id( 'customer-subscription-payment' )
627 ->with(
628 [
629 'customerIds' => $this->customerIds(),
630 'subscription' => $subscription,
631 'backUrl' => esc_url_raw( $confirm_subscription_url ),
632 'successUrl' => esc_url_raw( $confirm_subscription_url ),
633 'quantity' => 1,
634 ]
635 )->render()
636 );
637 ?>
638 </sc-spacing>
639
640 <?php
641 return ob_get_clean();
642 }
643 }
644