PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | paypal/controllers/FrmPayPalLiteAppController.php +17 -34 6.31 → trunk View file →
@@ -230,8 +230,9 @@
230 230 $payer = self::get_payer_data_from_posted_values( $action );
231 231 $shipping = self::get_shipping_data_from_posted_values( $action );
232 232 $shipping_preference = self::get_shipping_preference( $action );
233 233 $pricing_data = self::get_pricing_data_from_posted_values( $form_id );
234 + $description = self::process_shortcodes_for_action( $action->post_content['description'] ?? '', $action );
234 235
235 236 if ( 0.0 === floatval( $amount ) ) {
236 237 wp_send_json_error( __( 'Order amount cannot be zero.', 'formidable' ) );
237 238 }
@@ -239,9 +240,9 @@
239 240 // PayPal expects the amount in a format like 10.00, so format it.
240 241 $amount = number_format( floatval( $amount ), 2, '.', '' );
241 242 $currency = strtoupper( $action->post_content['currency'] );
242 243
243 - $order_response = FrmPayPalLiteConnectHelper::create_order( $amount, $currency, $payment_source, $payer, $shipping_preference, $pricing_data, $shipping );
244 + $order_response = FrmPayPalLiteConnectHelper::create_order( $amount, $currency, $payment_source, $payer, $shipping_preference, $pricing_data, $shipping, $description );
244 245
245 246 if ( class_exists( 'FrmLog' ) ) {
246 247 $log = new FrmLog();
247 248 $log->add(
@@ -397,9 +398,9 @@
397 398 *
398 399 * @return array|false The formatted address array, or false if invalid.
399 400 */
400 401 private static function format_address_for_paypal( $address, $address_field_id ) {
401 - if ( ! is_array( $address ) || ! isset( $address['line1'] ) || ! is_callable( 'FrmProAddressesController::get_country_code' ) ) {
402 + if ( ! is_array( $address ) || ! isset( $address['line1'] ) ) {
402 403 return false;
403 404 }
404 405
405 406 $address_field = FrmField::getOne( $address_field_id );
@@ -410,9 +411,9 @@
410 411
411 412 if ( 'us' === $address_field->field_options['address_type'] ) {
412 413 $country_code = 'US';
413 414 } else {
414 - $country_code = FrmProAddressesController::get_country_code( $address['country'] );
415 + $country_code = FrmAddressesController::get_country_code( $address['country'] );
415 416 }
416 417
417 418 if ( ! $address['line1'] || ! $address['city'] || ! $address['state'] || ! $address['zip'] || ! $country_code ) {
418 419 return false;
@@ -460,9 +461,9 @@
460 461 *
461 462 * @return void
462 463 */
463 464 private static function maybe_add_address_data( &$payer, $address, $address_field_id ) {
464 - if ( ! is_array( $address ) || ! isset( $address['line1'] ) || ! is_callable( 'FrmProAddressesController::get_country_code' ) ) {
465 + if ( ! is_array( $address ) || ! isset( $address['line1'] ) ) {
465 466 return;
466 467 }
467 468
468 469 $address_field = FrmField::getOne( $address_field_id );
@@ -473,9 +474,9 @@
473 474
474 475 if ( 'us' === $address_field->field_options['address_type'] ) {
475 476 $country_code = 'US';
476 477 } else {
477 - $country_code = FrmProAddressesController::get_country_code( $address['country'] );
478 + $country_code = FrmAddressesController::get_country_code( $address['country'] );
478 479 }
479 480
480 481 if ( ! $address['line1'] || ! $address['city'] || ! $address['state'] || ! $address['zip'] || ! $country_code ) {
481 482 return;
@@ -623,9 +624,9 @@
623 624 $currency = strtoupper( $action->post_content['currency'] );
624 625
625 626 // Pass $product_name, $interval and $interval_count to the helper
626 627 // As well as trial period and the maximum number of payments.
627 - // Also send subscriber email.
628 + // Also send subscriber email and description.
628 629 $product_name = self::process_shortcodes_for_action( $action->post_content['product_name'] ?? '', $action );
629 630 $interval = $action->post_content['interval'] ?? '';
630 631 $interval_count = $action->post_content['interval_count'] ?? 1;
631 632 $trial_period = $action->post_content['trial_interval_count'] ?? '';
@@ -630,8 +631,9 @@
630 631 $interval_count = $action->post_content['interval_count'] ?? 1;
631 632 $trial_period = $action->post_content['trial_interval_count'] ?? '';
632 633 $payment_limit = $action->post_content['payment_limit'] ?? '';
633 634 $product_type = $action->post_content['product_type'] ?? 'SERVICE';
635 + $description = self::process_shortcodes_for_action( $action->post_content['description'] ?? '', $action );
634 636
635 637 if ( ! $product_name ) {
636 638 wp_send_json_error( __( 'A product name is required for subscriptions. Please update your PayPal action settings.', 'formidable' ) );
637 639 }
@@ -654,16 +656,11 @@
654 656 'trial_period' => $trial_period,
655 657 'payment_limit' => $payment_limit,
656 658 'payer' => self::get_payer_data_from_posted_values( $action ),
657 659 'shipping_preference' => self::get_shipping_preference( $action ),
660 + 'description' => $description,
658 661 );
659 662
660 - $vault_setup_token = FrmAppHelper::get_post_param( 'vault_setup_token', '', 'sanitize_text_field' );
661 -
662 - if ( $vault_setup_token ) {
663 - $data['vault_setup_token'] = $vault_setup_token;
664 - }
665 -
666 663 $response = FrmPayPalLiteConnectHelper::create_subscription( $data );
667 664
668 665 if ( false === $response ) {
669 666 $error = FrmPayPalLiteConnectHelper::get_latest_error_from_paypal_api();
@@ -681,30 +678,8 @@
681 678
682 679 wp_send_json_success( array( 'subscriptionID' => $response->subscription_id ) );
683 680 }
684 681
685 - public static function create_vault_setup_token() {
686 - check_ajax_referer( 'frm_paypal_ajax', 'nonce' );
687 -
688 - $payment_source = FrmAppHelper::get_post_param( 'payment_source', 'card', 'sanitize_text_field' );
689 -
690 - $data = array(
691 - 'payment_source' => $payment_source,
692 - );
693 -
694 - $response = FrmPayPalLiteConnectHelper::create_vault_setup_token( $data );
695 -
696 - if ( false === $response ) {
697 - wp_send_json_error( 'Failed to create PayPal vault setup token' );
698 - }
699 -
700 - if ( ! isset( $response->token ) ) {
701 - wp_send_json_error( 'Failed to create PayPal vault setup token' );
702 - }
703 -
704 - wp_send_json_success( array( 'token' => $response->token ) );
705 - }
706 -
707 682 /**
708 683 * Handle a PayPal error reported by the frontend JavaScript.
709 684 *
710 685 * Logs the debug ID and error details, then returns a display message
@@ -870,6 +845,14 @@
870 845 return array(
871 846 'message' => $clean_message ? $clean_message : $fallback,
872 847 'debug_id' => $matches[1],
873 848 );
849 + }
850 +
851 + /**
852 + * @deprecated 6.32.1
853 + */
854 + public static function create_vault_setup_token() {
855 + _deprecated_function( __METHOD__, '6.32.1' );
856 + wp_send_json_error( 'This API endpoint is no longer in use.' );
874 857 }
875 858 }