Skip to content

Commit

Permalink
fix: error message rendering on tokenized PRBs (#9189)
Browse files Browse the repository at this point in the history
Co-authored-by: Timur Karimov <[email protected]>
  • Loading branch information
frosso and timur27 committed Aug 1, 2024
1 parent ada8639 commit 121e032
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions changelog/fix-tokenized-prb-failure-message
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fix
Comment: fix: error message rendering on tokenized PRBs


8 changes: 7 additions & 1 deletion client/tokenized-payment-request/payment-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,16 @@ export default class WooPaymentsPaymentRequest {
'.woocommerce-notices-wrapper'
).first();

// the error thrown could have different formats, depending if it was a Store API failure or an ajax failure.
const errorMessage =
response.message ||
response.payment_result?.payment_details.find(
( detail ) => detail.key === 'errorMessage'
)?.value;
if ( $container.length ) {
$container.append(
jQuery( '<div class="woocommerce-error" />' ).text(
response.message
errorMessage
)
);

Expand Down

0 comments on commit 121e032

Please sign in to comment.