-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix PHP Warnings in PPCP Gateway #29
Fix PHP Warnings in PPCP Gateway #29
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
add_filter( 'sift_for_woocommerce_ppcp-gateway_cvv_result_code', fn( $value, $ppcp_data ) => $ppcp_data['order']?->purchase_units()[0]?->payments()?->authorizations()[0]?->fraud_processor_response()->cvv_code() ?? $value, 10, 2 ); | ||
add_filter( 'sift_for_woocommerce_ppcp-gateway_verification_status', fn( $value, $ppcp_data ) => $ppcp_data['order']?->purchase_units()[0]?->payments()?->authorizations()[0]?->status()->name() ?? $value, 10, 2 ); | ||
add_filter( 'sift_for_woocommerce_ppcp-gateway_decline_reason_code', fn( $value, $ppcp_data ) => $ppcp_data['order']?->purchase_units()[0]?->payments()?->authorizations()[0]?->to_array()['reason_code'] ?? $value, 10, 2 ); | ||
add_filter( 'sift_for_woocommerce_ppcp-gateway_avs_result_code', fn( $value, $ppcp_data ) => select_first_payments_authorization( $ppcp_data['order'] )?->fraud_processor_response()->avs_code() ?? $value, 10, 2 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So
add_filter( 'sift_for_woocommerce_ppcp-gateway_avs_result_code', fn( $value, $ppcp_data ) => $ppcp_data['order']?->purchase_units()?[0]?->payments()?->authorizations()[0]?->fraud_processor_response()->avs_code() ?? $value
Would not work? I did not know...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was my first thought, but no - it's a syntax error. There is an alternative, but I'm not sure if we want to use it as it's a bit harder to read. (context: p1737057534401999-slack-C6JKZ8MLK):
print_r( ( ( ( $ppcp_data['order'] ?? null )?->purchase_units() ?? [ null ] )[0]?->payments()?->authorizations() ?? [ null ] )[0]?->to_array()['reason_code'] ?? $value );
or
print_r( ( ( ( $ppcp_data['order'] ?? null )?->purchase_units()[0] ?? null )?->payments()?->authorizations()[0] ?? null )?->to_array()['reason_code'] ?? $value );
(replacing print_r
with the filter and function)
Definitely even less readable. Let’s keep your original version.Maybe throw a unit test on your helper function for sanity?Le 17 janv. 2025 à 20:49, Chris McCluskey ***@***.***> a écrit :
@chrismccluskey commented on this pull request.
In src/inc/payment-gateways/ppcp-gateway.php:
add_filter( 'sift_for_woocommerce_ppcp-gateway_payment_method_details_from_order', __NAMESPACE__ . '\get_from_order', 10, 2 );
add_filter( 'sift_for_woocommerce_ppcp-gateway_charge_details_from_order', __NAMESPACE__ . '\get_from_order', 10, 2 );
add_filter( 'sift_for_woocommerce_ppcp-gateway_payment_type_string', fn( $value, $ppcp_gateway_payment_type ) => 'ppcp' === $ppcp_gateway_payment_type ? '$third_party_processor' : $value );
add_filter( 'sift_for_woocommerce_ppcp-gateway_card_last4', fn( $value, $ppcp_data ) => $ppcp_data['wc_order']?->get_meta_data( PayPalGateway::FRAUD_RESULT_META_KEY )['card_last_digits'] ?? $value, 10, 2 );
-add_filter( 'sift_for_woocommerce_ppcp-gateway_avs_result_code', fn( $value, $ppcp_data ) => $ppcp_data['order']?->purchase_units()[0]?->payments()?->authorizations()[0]?->fraud_processor_response()->avs_code() ?? $value, 10, 2 );
-add_filter( 'sift_for_woocommerce_ppcp-gateway_cvv_result_code', fn( $value, $ppcp_data ) => $ppcp_data['order']?->purchase_units()[0]?->payments()?->authorizations()[0]?->fraud_processor_response()->cvv_code() ?? $value, 10, 2 );
-add_filter( 'sift_for_woocommerce_ppcp-gateway_verification_status', fn( $value, $ppcp_data ) => $ppcp_data['order']?->purchase_units()[0]?->payments()?->authorizations()[0]?->status()->name() ?? $value, 10, 2 );
-add_filter( 'sift_for_woocommerce_ppcp-gateway_decline_reason_code', fn( $value, $ppcp_data ) => $ppcp_data['order']?->purchase_units()[0]?->payments()?->authorizations()[0]?->to_array()['reason_code'] ?? $value, 10, 2 );
+add_filter( 'sift_for_woocommerce_ppcp-gateway_avs_result_code', fn( $value, $ppcp_data ) => select_first_payments_authorization( $ppcp_data['order'] )?->fraud_processor_response()->avs_code() ?? $value, 10, 2 );
That was my first thought, but no - it's a syntax error. There is an alternative, but I'm not sure if we want to use it as it's a bit harder to read. (context: p1737057534401999-slack-C6JKZ8MLK):
print_r( ( ( ( $ppcp_data['order'] ?? null )?->purchase_units() ?? [ null ] )[0]?->payments()?->authorizations() ?? [ null ] )[0]?->to_array()['reason_code'] ?? $value );
or
print_r( ( ( ( $ppcp_data['order'] ?? null )?->purchase_units()[0] ?? null )?->payments()?->authorizations()[0] ?? null )?->to_array()['reason_code'] ?? $value );
(replacing print_r with the filter and function)
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: ***@***.***>
|
Changes proposed in this Pull Request
Testing instructions
Alternatively, automated tests should cover this already.
Closes 602-gh-automattic/gold