Edit File by line
/home/zeestwma/ceyloniy.../wp-conte.../plugins/wpforms-.../src/Integrat.../Stripe
File: Process.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace WPForms\Integrations\Stripe;
[2] Fix | Delete
[3] Fix | Delete
use Stripe\Exception\ApiErrorException;
[4] Fix | Delete
use WPForms\Helpers\Transient;
[5] Fix | Delete
use WPForms\Vendor\Stripe\SubscriptionSchedule;
[6] Fix | Delete
[7] Fix | Delete
/**
[8] Fix | Delete
* Stripe payment processing.
[9] Fix | Delete
*
[10] Fix | Delete
* @since 1.8.2
[11] Fix | Delete
*/
[12] Fix | Delete
class Process {
[13] Fix | Delete
[14] Fix | Delete
/**
[15] Fix | Delete
* Payment amount.
[16] Fix | Delete
*
[17] Fix | Delete
* @since 1.8.2
[18] Fix | Delete
*
[19] Fix | Delete
* @var string
[20] Fix | Delete
*/
[21] Fix | Delete
public $amount = '';
[22] Fix | Delete
[23] Fix | Delete
/**
[24] Fix | Delete
* Form ID.
[25] Fix | Delete
*
[26] Fix | Delete
* @since 1.8.2
[27] Fix | Delete
*
[28] Fix | Delete
* @var int
[29] Fix | Delete
*/
[30] Fix | Delete
public $form_id = 0;
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* Form Stripe payment settings.
[34] Fix | Delete
*
[35] Fix | Delete
* @since 1.8.2
[36] Fix | Delete
*
[37] Fix | Delete
* @var array
[38] Fix | Delete
*/
[39] Fix | Delete
public $settings = [];
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* Sanitized submitted field values and data.
[43] Fix | Delete
*
[44] Fix | Delete
* @since 1.8.2
[45] Fix | Delete
*
[46] Fix | Delete
* @var array
[47] Fix | Delete
*/
[48] Fix | Delete
public $fields = [];
[49] Fix | Delete
[50] Fix | Delete
/**
[51] Fix | Delete
* Form data and settings.
[52] Fix | Delete
*
[53] Fix | Delete
* @since 1.8.2
[54] Fix | Delete
*
[55] Fix | Delete
* @var array
[56] Fix | Delete
*/
[57] Fix | Delete
public $form_data = [];
[58] Fix | Delete
[59] Fix | Delete
/**
[60] Fix | Delete
* Rate Limit object.
[61] Fix | Delete
*
[62] Fix | Delete
* @since 1.8.2
[63] Fix | Delete
*
[64] Fix | Delete
* @var RateLimit
[65] Fix | Delete
*/
[66] Fix | Delete
private $rate_limit;
[67] Fix | Delete
[68] Fix | Delete
/**
[69] Fix | Delete
* Api interface.
[70] Fix | Delete
*
[71] Fix | Delete
* @since 1.8.2
[72] Fix | Delete
*
[73] Fix | Delete
* @var Api\ApiInterface
[74] Fix | Delete
*/
[75] Fix | Delete
protected $api;
[76] Fix | Delete
[77] Fix | Delete
/**
[78] Fix | Delete
* Whether the payment has been processed.
[79] Fix | Delete
*
[80] Fix | Delete
* @since 1.8.3
[81] Fix | Delete
*
[82] Fix | Delete
* @var bool
[83] Fix | Delete
*/
[84] Fix | Delete
protected $is_payment_processed = false;
[85] Fix | Delete
[86] Fix | Delete
/**
[87] Fix | Delete
* Save matched subscription settings.
[88] Fix | Delete
*
[89] Fix | Delete
* @since 1.8.4
[90] Fix | Delete
*
[91] Fix | Delete
* @var array
[92] Fix | Delete
*/
[93] Fix | Delete
private $subscription_settings = [];
[94] Fix | Delete
[95] Fix | Delete
/**
[96] Fix | Delete
* Save the matched plan id.
[97] Fix | Delete
*
[98] Fix | Delete
* @since 1.9.6
[99] Fix | Delete
*
[100] Fix | Delete
* @var string|null
[101] Fix | Delete
*/
[102] Fix | Delete
private $plan_id = null;
[103] Fix | Delete
[104] Fix | Delete
/**
[105] Fix | Delete
* Initialize.
[106] Fix | Delete
*
[107] Fix | Delete
* @since 1.8.2
[108] Fix | Delete
*
[109] Fix | Delete
* @param Api\ApiInterface $api Api interface.
[110] Fix | Delete
*/
[111] Fix | Delete
public function init( $api ) {
[112] Fix | Delete
[113] Fix | Delete
$this->api = $api;
[114] Fix | Delete
[115] Fix | Delete
$this->hooks();
[116] Fix | Delete
}
[117] Fix | Delete
[118] Fix | Delete
/**
[119] Fix | Delete
* Hooks.
[120] Fix | Delete
*
[121] Fix | Delete
* @since 1.8.2
[122] Fix | Delete
*/
[123] Fix | Delete
private function hooks() {
[124] Fix | Delete
[125] Fix | Delete
add_action( 'wpforms_process', [ $this, 'process_entry' ], 10, 3 );
[126] Fix | Delete
add_action( 'wpforms_process_payment_saved', [ $this, 'process_payment_saved' ], 10, 3 );
[127] Fix | Delete
add_action( 'wpformsstripe_api_common_set_error_from_exception', [ $this, 'process_card_error' ] );
[128] Fix | Delete
add_filter( 'wpforms_forms_submission_prepare_payment_data', [ $this, 'prepare_payment_data' ] );
[129] Fix | Delete
add_filter( 'wpforms_forms_submission_prepare_payment_meta', [ $this, 'prepare_payment_meta' ], 10, 3 );
[130] Fix | Delete
add_action( 'wpforms_process_entry_saved', [ $this, 'process_entry_data' ], 10, 4 );
[131] Fix | Delete
}
[132] Fix | Delete
[133] Fix | Delete
/**
[134] Fix | Delete
* Check if a payment exists with an entry, if so validate and process.
[135] Fix | Delete
*
[136] Fix | Delete
* @since 1.8.2
[137] Fix | Delete
*
[138] Fix | Delete
* @param array $fields Final/sanitized submitted field data.
[139] Fix | Delete
* @param array $entry Copy of original $_POST.
[140] Fix | Delete
* @param array $form_data Form data and settings.
[141] Fix | Delete
*/
[142] Fix | Delete
public function process_entry( $fields, $entry, $form_data ) {
[143] Fix | Delete
[144] Fix | Delete
// Check if payment method exists and is enabled.
[145] Fix | Delete
if ( ! Helpers::has_stripe_enabled( [ $form_data ] ) ) {
[146] Fix | Delete
return;
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
$this->form_id = (int) $form_data['id'];
[150] Fix | Delete
$this->fields = $fields;
[151] Fix | Delete
$this->form_data = $form_data;
[152] Fix | Delete
$this->settings = $form_data['payments']['stripe'];
[153] Fix | Delete
$this->amount = wpforms_get_total_payment( $this->fields );
[154] Fix | Delete
$this->rate_limit = new RateLimit();
[155] Fix | Delete
[156] Fix | Delete
$this->rate_limit->init();
[157] Fix | Delete
[158] Fix | Delete
if ( $this->is_process_entry_error() ) {
[159] Fix | Delete
return;
[160] Fix | Delete
}
[161] Fix | Delete
[162] Fix | Delete
if ( $this->is_submitted_payment_data_corrupted( $entry ) ) {
[163] Fix | Delete
return;
[164] Fix | Delete
}
[165] Fix | Delete
[166] Fix | Delete
$this->api->set_payment_tokens( $entry );
[167] Fix | Delete
[168] Fix | Delete
$error = $this->get_entry_errors();
[169] Fix | Delete
[170] Fix | Delete
// Before proceeding, check if any basic errors were detected.
[171] Fix | Delete
if ( $error ) {
[172] Fix | Delete
$this->log_error( $error );
[173] Fix | Delete
$this->display_error( $error );
[174] Fix | Delete
[175] Fix | Delete
return;
[176] Fix | Delete
}
[177] Fix | Delete
[178] Fix | Delete
$this->process_payment();
[179] Fix | Delete
}
[180] Fix | Delete
[181] Fix | Delete
/**
[182] Fix | Delete
* Bypass captcha if payment has been processed.
[183] Fix | Delete
*
[184] Fix | Delete
* @since 1.8.3
[185] Fix | Delete
* @deprecated 1.9.6
[186] Fix | Delete
*
[187] Fix | Delete
* @param bool $bypass_captcha Whether to bypass captcha.
[188] Fix | Delete
*
[189] Fix | Delete
* @return bool
[190] Fix | Delete
*/
[191] Fix | Delete
public function bypass_captcha( $bypass_captcha ) {
[192] Fix | Delete
[193] Fix | Delete
_deprecated_function( __METHOD__, '1.9.6 of the WPForms plugin' );
[194] Fix | Delete
[195] Fix | Delete
if ( $bypass_captcha ) {
[196] Fix | Delete
return $bypass_captcha;
[197] Fix | Delete
}
[198] Fix | Delete
[199] Fix | Delete
return $this->is_payment_processed;
[200] Fix | Delete
}
[201] Fix | Delete
[202] Fix | Delete
/**
[203] Fix | Delete
* Check on process entry errors.
[204] Fix | Delete
*
[205] Fix | Delete
* @since 1.8.2
[206] Fix | Delete
*
[207] Fix | Delete
* @return bool
[208] Fix | Delete
*/
[209] Fix | Delete
protected function is_process_entry_error() {
[210] Fix | Delete
[211] Fix | Delete
// Check for processing errors.
[212] Fix | Delete
if ( ! empty( wpforms()->obj( 'process' )->errors[ $this->form_id ] ) || ! $this->is_card_field_visibility_ok() ) {
[213] Fix | Delete
return true;
[214] Fix | Delete
}
[215] Fix | Delete
[216] Fix | Delete
// Check rate limit.
[217] Fix | Delete
if ( ! $this->is_rate_limit_ok() ) {
[218] Fix | Delete
wpforms()->obj( 'process' )->errors[ $this->form_id ]['footer'] = esc_html__( 'Unable to process payment, please try again later.', 'wpforms-lite' );
[219] Fix | Delete
[220] Fix | Delete
return true;
[221] Fix | Delete
}
[222] Fix | Delete
[223] Fix | Delete
return false;
[224] Fix | Delete
}
[225] Fix | Delete
[226] Fix | Delete
/**
[227] Fix | Delete
* Add meta for a successful payment.
[228] Fix | Delete
*
[229] Fix | Delete
* @since 1.8.2
[230] Fix | Delete
*
[231] Fix | Delete
* @param array $payment_meta Payment meta.
[232] Fix | Delete
* @param array $fields Final/sanitized submitted field data.
[233] Fix | Delete
* @param array $form_data Form data and settings.
[234] Fix | Delete
*
[235] Fix | Delete
* @noinspection PhpMissingParamTypeInspection
[236] Fix | Delete
* @noinspection PhpUnusedParameterInspection
[237] Fix | Delete
*/
[238] Fix | Delete
public function prepare_payment_meta( $payment_meta, $fields, $form_data ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
[239] Fix | Delete
[240] Fix | Delete
$payment = $this->api->get_payment();
[241] Fix | Delete
[242] Fix | Delete
if ( empty( $payment->id ) ) {
[243] Fix | Delete
return $payment_meta;
[244] Fix | Delete
}
[245] Fix | Delete
[246] Fix | Delete
$charge_details = $this->api->get_charge_details( [ 'type', 'name', 'last4', 'brand', 'exp_month', 'exp_year' ] );
[247] Fix | Delete
[248] Fix | Delete
$payment_meta['method_type'] = $this->get_payment_type( $charge_details );
[249] Fix | Delete
$payment_meta['customer_name'] = $this->get_customer_name();
[250] Fix | Delete
$payment_meta['customer_email'] = $this->get_customer_email();
[251] Fix | Delete
[252] Fix | Delete
$subscription = $this->api->get_subscription();
[253] Fix | Delete
[254] Fix | Delete
if ( ! empty( $subscription->id ) ) {
[255] Fix | Delete
$payment_meta['subscription_period'] = sanitize_text_field( $this->subscription_settings['period'] );
[256] Fix | Delete
}
[257] Fix | Delete
[258] Fix | Delete
if ( ! empty( $charge_details['brand'] ) ) {
[259] Fix | Delete
$payment_meta['credit_card_method'] = $charge_details['brand'];
[260] Fix | Delete
}
[261] Fix | Delete
[262] Fix | Delete
if ( ! empty( $charge_details['name'] ) ) {
[263] Fix | Delete
$payment_meta['credit_card_name'] = $charge_details['name'];
[264] Fix | Delete
}
[265] Fix | Delete
[266] Fix | Delete
if ( ! empty( $charge_details['last4'] ) ) {
[267] Fix | Delete
$payment_meta['credit_card_last4'] = $charge_details['last4'];
[268] Fix | Delete
}
[269] Fix | Delete
[270] Fix | Delete
if ( ! empty( $charge_details['exp_month'] ) && ! empty( $charge_details['exp_year'] ) ) {
[271] Fix | Delete
$payment_meta['credit_card_expires'] = sprintf( '%s/%s', $charge_details['exp_month'], $charge_details['exp_year'] );
[272] Fix | Delete
}
[273] Fix | Delete
[274] Fix | Delete
$log = [
[275] Fix | Delete
'value' => $payment->object === 'payment_intent' ? sprintf( 'Stripe payment intent created. (Payment Intent ID: %s)', $payment->id ) : 'Stripe payment was created.',
[276] Fix | Delete
'date' => gmdate( 'Y-m-d H:i:s' ),
[277] Fix | Delete
];
[278] Fix | Delete
[279] Fix | Delete
$payment_meta['log'] = wp_json_encode( $log );
[280] Fix | Delete
[281] Fix | Delete
return $payment_meta;
[282] Fix | Delete
}
[283] Fix | Delete
[284] Fix | Delete
/**
[285] Fix | Delete
* Get payment method type.
[286] Fix | Delete
*
[287] Fix | Delete
* @since 1.8.2.1
[288] Fix | Delete
*
[289] Fix | Delete
* @param array $charge_details Get details from a saved Charge object.
[290] Fix | Delete
*
[291] Fix | Delete
* @return string
[292] Fix | Delete
*/
[293] Fix | Delete
private function get_payment_type( $charge_details ) {
[294] Fix | Delete
[295] Fix | Delete
if ( empty( $charge_details['last4'] ) ) {
[296] Fix | Delete
return 'link';
[297] Fix | Delete
}
[298] Fix | Delete
[299] Fix | Delete
if ( ! empty( $charge_details['type'] ) ) {
[300] Fix | Delete
return sanitize_text_field( $charge_details['type'] );
[301] Fix | Delete
}
[302] Fix | Delete
[303] Fix | Delete
return 'card';
[304] Fix | Delete
}
[305] Fix | Delete
[306] Fix | Delete
/**
[307] Fix | Delete
* Add payment info for successful payment.
[308] Fix | Delete
*
[309] Fix | Delete
* @since 1.8.2
[310] Fix | Delete
*
[311] Fix | Delete
* @param int $payment_id Payment ID.
[312] Fix | Delete
* @param array $fields Final/sanitized submitted field data.
[313] Fix | Delete
* @param array $form_data Form data and settings.
[314] Fix | Delete
*/
[315] Fix | Delete
public function process_payment_saved( $payment_id, $fields, $form_data ) {
[316] Fix | Delete
[317] Fix | Delete
$payment = $this->api->get_payment();
[318] Fix | Delete
[319] Fix | Delete
if ( empty( $payment->id ) ) {
[320] Fix | Delete
return;
[321] Fix | Delete
}
[322] Fix | Delete
[323] Fix | Delete
$payment_url = add_query_arg(
[324] Fix | Delete
[
[325] Fix | Delete
'page' => 'wpforms-payments',
[326] Fix | Delete
'view' => 'payment',
[327] Fix | Delete
'payment_id' => $payment_id,
[328] Fix | Delete
],
[329] Fix | Delete
admin_url( 'admin.php' )
[330] Fix | Delete
);
[331] Fix | Delete
[332] Fix | Delete
// Update the Stripe charge metadata to include the Payment ID.
[333] Fix | Delete
$payment->metadata['payment_id'] = $payment_id;
[334] Fix | Delete
$payment->metadata['payment_url'] = esc_url_raw( $payment_url );
[335] Fix | Delete
[336] Fix | Delete
// Clean up spam reason in case it was set before.
[337] Fix | Delete
$payment->metadata['spam_reason'] = null;
[338] Fix | Delete
[339] Fix | Delete
$custom_metadata = $this->get_mapped_custom_metadata( 'payment' );
[340] Fix | Delete
[341] Fix | Delete
array_walk(
[342] Fix | Delete
$custom_metadata,
[343] Fix | Delete
static function ( &$value, $key ) use ( $payment ) {
[344] Fix | Delete
$payment->metadata[ $key ] = $value;
[345] Fix | Delete
}
[346] Fix | Delete
);
[347] Fix | Delete
[348] Fix | Delete
/**
[349] Fix | Delete
* Allow to add additional payment metadata to the Stripe payment.
[350] Fix | Delete
*
[351] Fix | Delete
* @since 1.8.2.2
[352] Fix | Delete
*
[353] Fix | Delete
* @param array $additional_meta Additional metadata.
[354] Fix | Delete
* @param int $payment_id Payment ID.
[355] Fix | Delete
* @param array $fields Final/sanitized submitted field data.
[356] Fix | Delete
* @param array $form_data Form data and settings.
[357] Fix | Delete
*/
[358] Fix | Delete
$additional_meta = (array) apply_filters( 'wpforms_integrations_stripe_process_additional_metadata', [], $payment_id, $fields, $form_data );
[359] Fix | Delete
[360] Fix | Delete
array_walk(
[361] Fix | Delete
$additional_meta,
[362] Fix | Delete
static function ( $meta, $key ) use ( &$payment ) {
[363] Fix | Delete
$payment->metadata[ $key ] = $meta;
[364] Fix | Delete
}
[365] Fix | Delete
);
[366] Fix | Delete
[367] Fix | Delete
$payment->update( $payment->id, $payment->serializeParameters(), Helpers::get_auth_opts() );
[368] Fix | Delete
[369] Fix | Delete
$subscription = $this->api->get_subscription();
[370] Fix | Delete
[371] Fix | Delete
// Update the Stripe subscription metadata to include the Payment ID.
[372] Fix | Delete
if ( ! empty( $subscription->id ) ) {
[373] Fix | Delete
$subscription->metadata['payment_id'] = $payment_id;
[374] Fix | Delete
$subscription->metadata['payment_url'] = esc_url_raw( $payment_url );
[375] Fix | Delete
[376] Fix | Delete
$this->maybe_set_subscription_schedule( $subscription );
[377] Fix | Delete
[378] Fix | Delete
// Clean up cycles value.
[379] Fix | Delete
$subscription->metadata['cycles'] = null;
[380] Fix | Delete
[381] Fix | Delete
$subscription->update( $subscription->id, $subscription->serializeParameters(), Helpers::get_auth_opts() );
[382] Fix | Delete
}
[383] Fix | Delete
[384] Fix | Delete
wpforms()->obj( 'payment_meta' )->add_log(
[385] Fix | Delete
$payment_id,
[386] Fix | Delete
sprintf(
[387] Fix | Delete
'Stripe charge processed. (Charge ID: %1$s)',
[388] Fix | Delete
isset( $payment->latest_charge ) ? $payment->latest_charge : $payment->id
[389] Fix | Delete
)
[390] Fix | Delete
);
[391] Fix | Delete
[392] Fix | Delete
/**
[393] Fix | Delete
* Fire when processing is complete.
[394] Fix | Delete
*
[395] Fix | Delete
* @since 1.8.2
[396] Fix | Delete
*
[397] Fix | Delete
* @param array $fields Final/sanitized submitted field data.
[398] Fix | Delete
* @param array $form_data Form data and settings.
[399] Fix | Delete
* @param int $payment_id Payment ID.
[400] Fix | Delete
* @param mixed $payment Stripe payment object.
[401] Fix | Delete
* @param mixed $subscription Stripe subscription object.
[402] Fix | Delete
* @param mixed $customer Stripe customer object.
[403] Fix | Delete
*/
[404] Fix | Delete
do_action( 'wpforms_stripe_process_complete', $fields, $form_data, $payment_id, $payment, $subscription, $this->api->get_customer() ); // phpcs:ignore WPForms.PHP.ValidateHooks.InvalidHookName
[405] Fix | Delete
}
[406] Fix | Delete
[407] Fix | Delete
/**
[408] Fix | Delete
* Get mapped custom metadata.
[409] Fix | Delete
*
[410] Fix | Delete
* @since 1.9.6
[411] Fix | Delete
*
[412] Fix | Delete
* @param string $type Object type ( e.g 'customer', 'payment' ).
[413] Fix | Delete
*
[414] Fix | Delete
* @return array
[415] Fix | Delete
*/
[416] Fix | Delete
private function get_mapped_custom_metadata( string $type ): array {
[417] Fix | Delete
[418] Fix | Delete
$settings_key = ! is_null( $this->plan_id ) ? 'recurring_custom_metadata_' . $this->plan_id : 'custom_metadata';
[419] Fix | Delete
[420] Fix | Delete
if ( empty( $this->form_data['payments']['stripe'][ $settings_key ] ) ) {
[421] Fix | Delete
return [];
[422] Fix | Delete
}
[423] Fix | Delete
[424] Fix | Delete
$metadata = [];
[425] Fix | Delete
[426] Fix | Delete
foreach ( $this->form_data['payments']['stripe'][ $settings_key ] as $data ) {
[427] Fix | Delete
[428] Fix | Delete
// Skip if the field type not set or the meta-key is empty.
[429] Fix | Delete
if ( $data['object_type'] !== $type || empty( $data['meta_key'] ) ) {
[430] Fix | Delete
continue;
[431] Fix | Delete
}
[432] Fix | Delete
[433] Fix | Delete
// Skip if either the key or value is empty.
[434] Fix | Delete
if ( ! $data['meta_key'] || ! $data['meta_value'] ) {
[435] Fix | Delete
continue;
[436] Fix | Delete
}
[437] Fix | Delete
[438] Fix | Delete
$field_id = $data['meta_value'];
[439] Fix | Delete
[440] Fix | Delete
if ( ! isset( $this->fields[ $field_id ]['value'] ) || wpforms_is_empty_string( $this->fields[ $field_id ]['value'] ) ) {
[441] Fix | Delete
continue;
[442] Fix | Delete
}
[443] Fix | Delete
[444] Fix | Delete
// Add quantity for the field value.
[445] Fix | Delete
if ( wpforms_payment_has_quantity( $this->fields[ $field_id ], $this->form_data ) ) {
[446] Fix | Delete
$field_value = wpforms_payment_format_quantity( $this->fields[ $field_id ] );
[447] Fix | Delete
} else {
[448] Fix | Delete
$field_value = $this->fields[ $field_id ]['value'];
[449] Fix | Delete
}
[450] Fix | Delete
[451] Fix | Delete
// Key length limited to 40 characters long by Stripe API.
[452] Fix | Delete
$key = wp_html_excerpt( sanitize_text_field( $data['meta_key'] ), 40 );
[453] Fix | Delete
[454] Fix | Delete
// Check whether the meta-key is empty once again after sanitization.
[455] Fix | Delete
if ( empty( $key ) ) {
[456] Fix | Delete
continue;
[457] Fix | Delete
}
[458] Fix | Delete
[459] Fix | Delete
// Value length limited to 500 characters long by Stripe API.
[460] Fix | Delete
$metadata[ $key ] = wp_html_excerpt( wpforms_decode_string( $field_value ), 500 );
[461] Fix | Delete
}
[462] Fix | Delete
[463] Fix | Delete
return $metadata;
[464] Fix | Delete
}
[465] Fix | Delete
[466] Fix | Delete
/**
[467] Fix | Delete
* Add details to payment data.
[468] Fix | Delete
*
[469] Fix | Delete
* @since 1.8.2
[470] Fix | Delete
*
[471] Fix | Delete
* @param array $payment_data Payment data args.
[472] Fix | Delete
*
[473] Fix | Delete
* @return array
[474] Fix | Delete
*/
[475] Fix | Delete
public function prepare_payment_data( $payment_data ) {
[476] Fix | Delete
[477] Fix | Delete
$payment = $this->api->get_payment();
[478] Fix | Delete
[479] Fix | Delete
if ( empty( $payment->id ) ) {
[480] Fix | Delete
return $payment_data;
[481] Fix | Delete
}
[482] Fix | Delete
[483] Fix | Delete
$customer = $this->api->get_customer();
[484] Fix | Delete
$subscription = $this->api->get_subscription();
[485] Fix | Delete
[486] Fix | Delete
$payment_data['status'] = 'processed';
[487] Fix | Delete
$payment_data['gateway'] = 'stripe';
[488] Fix | Delete
$payment_data['mode'] = Helpers::get_stripe_mode();
[489] Fix | Delete
$payment_data['transaction_id'] = sanitize_text_field( $payment->id );
[490] Fix | Delete
$payment_data['customer_id'] = ! empty( $customer->id ) ? sanitize_text_field( $customer->id ) : '';
[491] Fix | Delete
$payment_data['title'] = $this->get_payment_title();
[492] Fix | Delete
[493] Fix | Delete
if ( ! empty( $subscription->id ) ) {
[494] Fix | Delete
$payment_data['subscription_id'] = sanitize_text_field( $subscription->id );
[495] Fix | Delete
$payment_data['subscription_status'] = 'not-synced';
[496] Fix | Delete
}
[497] Fix | Delete
[498] Fix | Delete
return $payment_data;
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function