PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 6.2.2
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v6.2.2
6.2.14 6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 All 196 releases
fluentform / app / Modules / Payments / PaymentMethods / Stripe / API / Customer.php

Customer.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 6.2.2, at app/Modules/Payments/PaymentMethods/Stripe/API/Customer.php

73 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentForm\App\Modules\Payments\PaymentMethods\Stripe\API;
4
5 use FluentForm\App\Modules\Payments\PaymentMethods\Stripe\StripeSettings;
6
7 if (!defined('ABSPATH')) {
8 exit;
9 }
10
11 class Customer
12 {
13 use RequestProcessor;
14
15 public static function createCustomer($customerArgs, $formId)
16 {
17 $errors = static::validate($customerArgs);
18
19 if ($errors) {
20 return static::errorHandler('validation_failed', __('Payment data validation failed', 'fluentform'), $errors);
21 }
22
23 try {
24 $secretKey = apply_filters_deprecated(
25 'fluentform-payment_stripe_secret_key',
26 [
27 StripeSettings::getSecretKey($formId),
28 $formId
29 ],
30 FLUENTFORM_FRAMEWORK_UPGRADE,
31 'fluentform/payment_stripe_secret_key',
32 'Use fluentform/payment_stripe_secret_key instead of fluentform-payment_stripe_secret_key.'
33 );
34 $secretKey = apply_filters('fluentform/payment_stripe_secret_key', $secretKey, $formId);
35
36 ApiRequest::set_secret_key($secretKey);
37
38 $response = ApiRequest::request($customerArgs, 'customers');
39
40 $response = static::processResponse($response);
41
42 do_action_deprecated(
43 'fluentform_stripe_customer_created',
44 [
45 $response,
46 $customerArgs
47 ],
48 FLUENTFORM_FRAMEWORK_UPGRADE,
49 'fluentform/stripe_customer_created',
50 'Use fluentform/stripe_customer_created instead of fluentform_stripe_customer_created.'
51 );
52
53 do_action('fluentform/stripe_customer_created', $response, $customerArgs);
54
55 return $response;
56 } catch (\Exception $e) {
57 // Something else happened, completely unrelated to Stripe
58 return static::errorHandler('non_stripe', esc_html__('General Error', 'fluentform') . ': ' . $e->getMessage());
59 }
60 }
61
62 public static function validate($args)
63 {
64 $errors = [];
65
66 if (empty($args['source']) && empty($args['payment_method'])) {
67 $errors['source'] = __('Stripe token/payment_method is required', 'fluentform');
68 }
69
70 return $errors;
71 }
72 }
73