Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../public_h.../wp-conte.../plugins/wpforms-.../src/Integrat.../Stripe
File: Process.php
* @return bool
[1000] Fix | Delete
*/
[1001] Fix | Delete
protected function is_recurring_settings_ok( $settings ) {
[1002] Fix | Delete
[1003] Fix | Delete
$error = '';
[1004] Fix | Delete
[1005] Fix | Delete
// Check subscription settings are provided.
[1006] Fix | Delete
if ( empty( $settings['period'] ) || empty( $settings['email'] ) ) {
[1007] Fix | Delete
$error = esc_html__( 'Stripe subscription payment stopped, missing form settings.', 'wpforms-lite' );
[1008] Fix | Delete
}
[1009] Fix | Delete
[1010] Fix | Delete
// Check for required customer email.
[1011] Fix | Delete
if ( ! $error && empty( $this->fields[ $settings['email'] ]['value'] ) ) {
[1012] Fix | Delete
$error = esc_html__( 'Stripe subscription payment stopped, customer email not found.', 'wpforms-lite' );
[1013] Fix | Delete
}
[1014] Fix | Delete
[1015] Fix | Delete
// Before proceeding, check if any basic errors were detected.
[1016] Fix | Delete
if ( $error ) {
[1017] Fix | Delete
$this->log_error( $error );
[1018] Fix | Delete
$this->display_error( $error );
[1019] Fix | Delete
[1020] Fix | Delete
return false;
[1021] Fix | Delete
}
[1022] Fix | Delete
[1023] Fix | Delete
return true;
[1024] Fix | Delete
}
[1025] Fix | Delete
[1026] Fix | Delete
/**
[1027] Fix | Delete
* Process subscription API call.
[1028] Fix | Delete
*
[1029] Fix | Delete
* @since 1.8.4
[1030] Fix | Delete
*
[1031] Fix | Delete
* @param array $args Prepared subscription arguments.
[1032] Fix | Delete
*/
[1033] Fix | Delete
protected function process_subscription( $args ) {
[1034] Fix | Delete
[1035] Fix | Delete
$this->subscription_settings = $args['settings'];
[1036] Fix | Delete
[1037] Fix | Delete
if ( ! Helpers::is_license_ok() && Helpers::is_application_fee_supported() ) {
[1038] Fix | Delete
$args['application_fee_percent'] = 3;
[1039] Fix | Delete
}
[1040] Fix | Delete
[1041] Fix | Delete
$this->api->process_subscription( $args );
[1042] Fix | Delete
[1043] Fix | Delete
// Set payment processing flag.
[1044] Fix | Delete
$this->is_payment_processed = true;
[1045] Fix | Delete
[1046] Fix | Delete
// Update the credit card field value to contain basic details.
[1047] Fix | Delete
$this->update_credit_card_field_value();
[1048] Fix | Delete
[1049] Fix | Delete
$this->process_api_error( 'subscription' );
[1050] Fix | Delete
}
[1051] Fix | Delete
[1052] Fix | Delete
/**
[1053] Fix | Delete
* Get base subscription arguments.
[1054] Fix | Delete
*
[1055] Fix | Delete
* @since 1.8.4
[1056] Fix | Delete
*
[1057] Fix | Delete
* @return array
[1058] Fix | Delete
*/
[1059] Fix | Delete
protected function get_base_subscription_args() {
[1060] Fix | Delete
[1061] Fix | Delete
return [
[1062] Fix | Delete
'form_id' => $this->form_id,
[1063] Fix | Delete
'form_title' => sanitize_text_field( $this->form_data['settings']['form_title'] ),
[1064] Fix | Delete
'amount' => $this->amount * Helpers::get_decimals_amount(),
[1065] Fix | Delete
];
[1066] Fix | Delete
}
[1067] Fix | Delete
[1068] Fix | Delete
/**
[1069] Fix | Delete
* Map WPForms Address field to Stripe format.
[1070] Fix | Delete
*
[1071] Fix | Delete
* @since 1.8.8
[1072] Fix | Delete
*
[1073] Fix | Delete
* @param array $submitted_data Submitted address data.
[1074] Fix | Delete
* @param string $field_id Address field ID.
[1075] Fix | Delete
*
[1076] Fix | Delete
* @return array
[1077] Fix | Delete
*/
[1078] Fix | Delete
private function map_address_field( array $submitted_data, string $field_id ): array {
[1079] Fix | Delete
[1080] Fix | Delete
$line = sanitize_text_field( $submitted_data['address1'] );
[1081] Fix | Delete
$country = '';
[1082] Fix | Delete
[1083] Fix | Delete
if ( isset( $submitted_data['address2'] ) ) {
[1084] Fix | Delete
$line .= ' ' . sanitize_text_field( $submitted_data['address2'] );
[1085] Fix | Delete
}
[1086] Fix | Delete
[1087] Fix | Delete
if ( isset( $submitted_data['country'] ) ) {
[1088] Fix | Delete
$country = sanitize_text_field( $submitted_data['country'] );
[1089] Fix | Delete
} elseif ( $this->form_data['fields'][ $field_id ]['scheme'] !== 'international' ) {
[1090] Fix | Delete
$country = 'US';
[1091] Fix | Delete
}
[1092] Fix | Delete
[1093] Fix | Delete
return [
[1094] Fix | Delete
'line1' => $line,
[1095] Fix | Delete
'state' => isset( $submitted_data['state'] ) ? sanitize_text_field( $submitted_data['state'] ) : '',
[1096] Fix | Delete
'city' => sanitize_text_field( $submitted_data['city'] ),
[1097] Fix | Delete
'postal_code' => sanitize_text_field( $submitted_data['postal'] ),
[1098] Fix | Delete
'country' => $country,
[1099] Fix | Delete
];
[1100] Fix | Delete
}
[1101] Fix | Delete
[1102] Fix | Delete
/**
[1103] Fix | Delete
* Check the submitted payment data whether it was corrupted.
[1104] Fix | Delete
* If so, refund a payment / cancel subscription.
[1105] Fix | Delete
*
[1106] Fix | Delete
* @since 1.8.8.2
[1107] Fix | Delete
*
[1108] Fix | Delete
* @param array $entry Submitted entry data.
[1109] Fix | Delete
*
[1110] Fix | Delete
* @return bool
[1111] Fix | Delete
*/
[1112] Fix | Delete
private function is_submitted_payment_data_corrupted( array $entry ): bool {
[1113] Fix | Delete
[1114] Fix | Delete
// Bail early if there are no payment intents.
[1115] Fix | Delete
if ( empty( $entry['payment_intent_id'] ) ) {
[1116] Fix | Delete
return false;
[1117] Fix | Delete
}
[1118] Fix | Delete
[1119] Fix | Delete
// Get stored corrupted payment intents if exist.
[1120] Fix | Delete
$corrupted_intents = (array) Transient::get( 'corrupted-stripe-intents' );
[1121] Fix | Delete
[1122] Fix | Delete
// We must prevent a processing if payment intent was identified as corrupted.
[1123] Fix | Delete
// Also if the transaction ID exists in DB (transaction ID is unique value).
[1124] Fix | Delete
if ( in_array( $entry['payment_intent_id'], $corrupted_intents, true ) || wpforms()->get( 'payment' )->get_by( 'transaction_id', $entry['payment_intent_id'] ) ) {
[1125] Fix | Delete
wpforms()->get( 'process' )->errors[ $this->form_id ]['footer'] = esc_html__( 'Secondary form submission was declined.', 'wpforms-lite' );
[1126] Fix | Delete
[1127] Fix | Delete
return true;
[1128] Fix | Delete
}
[1129] Fix | Delete
[1130] Fix | Delete
$intent = $this->api->retrieve_payment_intent(
[1131] Fix | Delete
$entry['payment_intent_id'],
[1132] Fix | Delete
[
[1133] Fix | Delete
'expand' => [ 'invoice.subscription' ],
[1134] Fix | Delete
]
[1135] Fix | Delete
);
[1136] Fix | Delete
[1137] Fix | Delete
// Round to the nearest whole number because $this->amount can contain a number close to,
[1138] Fix | Delete
// but slightly under it, due to how it is stored in the memory.
[1139] Fix | Delete
$submitted_amount = round( $this->amount * Helpers::get_decimals_amount() );
[1140] Fix | Delete
[1141] Fix | Delete
// Prevent form submission if a mismatch of the payment amount is detected.
[1142] Fix | Delete
if ( ! empty( $intent ) && (int) $submitted_amount !== (int) $intent->amount ) {
[1143] Fix | Delete
wpforms()->get( 'process' )->errors[ $this->form_id ]['footer'] = esc_html__( 'Irregular activity detected. Your submission has been declined and payment refunded.', 'wpforms-lite' );
[1144] Fix | Delete
[1145] Fix | Delete
$args = [
[1146] Fix | Delete
'reason' => 'fraudulent',
[1147] Fix | Delete
];
[1148] Fix | Delete
[1149] Fix | Delete
// We can't cancel a payment because it's already paid.
[1150] Fix | Delete
// So we can perform a refund only.
[1151] Fix | Delete
$this->api->refund_payment( $entry['payment_intent_id'], $args );
[1152] Fix | Delete
[1153] Fix | Delete
// Cancel subscription if exists.
[1154] Fix | Delete
if ( ! empty( $intent->invoice->subscription ) ) {
[1155] Fix | Delete
$this->api->cancel_subscription( $intent->invoice->subscription->id );
[1156] Fix | Delete
}
[1157] Fix | Delete
[1158] Fix | Delete
// This payment indent is identified as corrupted.
[1159] Fix | Delete
// Store it in order to prevent re-using it (form re-submitting).
[1160] Fix | Delete
if ( ! in_array( $entry['payment_intent_id'], $corrupted_intents, true ) ) {
[1161] Fix | Delete
$corrupted_intents[] = $entry['payment_intent_id'];
[1162] Fix | Delete
[1163] Fix | Delete
Transient::set( 'corrupted-stripe-intents', $corrupted_intents, WEEK_IN_SECONDS );
[1164] Fix | Delete
}
[1165] Fix | Delete
[1166] Fix | Delete
return true;
[1167] Fix | Delete
}
[1168] Fix | Delete
[1169] Fix | Delete
return false;
[1170] Fix | Delete
}
[1171] Fix | Delete
}
[1172] Fix | Delete
[1173] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function