PluginProbe
The Innovative Form Builder – IvyForms / 1.5
The Innovative Form Builder – IvyForms v1.5
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
← All changes | backend/src/Controllers/Form/FormSubmissionController.php +26 -0 1.4.1 → 1.5 View file →
@@ -15,8 +15,9 @@
15 15 use IvyForms\Controllers\Controller;
16 16 use IvyForms\Infrastructure\WP\REST\SubmissionMultipartReader;
17 17 use IvyForms\Services\Submission\FormSubmissionService;
18 18 use IvyForms\Services\Submission\SubmissionPayloadParser;
19 +use IvyForms\Services\Translations\BackendStrings;
19 20 use WP_REST_Request;
20 21 use WP_REST_Response;
21 22
22 23 /**
@@ -50,8 +51,33 @@
50 51 Sanitizer::verifySubmissionNonce(isset($params['nonce']) ? (string) $params['nonce'] : null, $formId);
51 52
52 53 $uploadedFiles = SubmissionMultipartReader::resolveUploadedFiles($data);
53 54 $result = $this->formSubmissionService->processSubmission($params, $uploadedFiles);
55 +
56 + if (!empty($result['requires_action'])) {
57 + return new WP_REST_Response([
58 + 'message' => BackendStrings::getCommonStrings()['ok'],
59 + 'data' => [
60 + 'success' => false,
61 + 'requires_action' => true,
62 + 'client_secret' => $result['client_secret'] ?? null,
63 + 'payment_intent_id' => $result['payment_intent_id'] ?? null,
64 + 'payment_method' => $result['payment_method'] ?? 'stripe',
65 + ],
66 + ], 200);
67 + }
68 +
69 + if (!empty($result['payment_error'])) {
70 + return new WP_REST_Response([
71 + 'message' => (string) (
72 + $result['message'] ?? BackendStrings::getPaymentStrings()['payment_failed']
73 + ),
74 + 'data' => [
75 + 'success' => false,
76 + 'payment_error' => true,
77 + ],
78 + ], 200);
79 + }
54 80
55 81 return new WP_REST_Response([
56 82 'data' => $result,
57 83 ], 200);