-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix payment method section missing for Affirm and Afterpay on transac…
…tion details page (#7345)
- Loading branch information
Showing
4 changed files
with
196 additions
and
7 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
...g-payment-details-section-in-payment-details-page-for-affirm-and-afterpay-payment-methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: fix | ||
|
||
Payment method section missing for Affirm and Afterpay on transaction details page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/** @format **/ | ||
|
||
/** | ||
* External dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies. | ||
*/ | ||
import Detail from '../detail'; | ||
|
||
/** | ||
* Extracts and formats payment method details from a charge. | ||
* | ||
* @param {Object} charge The charge object. | ||
* @return {Object} A flat hash of all necessary values. | ||
*/ | ||
const formatPaymentMethodDetails = ( charge ) => { | ||
const { billing_details: billingDetails, payment_method: id } = charge; | ||
|
||
const { name, email, formatted_address: formattedAddress } = billingDetails; | ||
|
||
return { | ||
id, | ||
name, | ||
email, | ||
formattedAddress, | ||
}; | ||
}; | ||
|
||
/** | ||
* Placeholders to display while loading. | ||
*/ | ||
const paymentMethodPlaceholders = { | ||
id: 'id placeholder', | ||
name: 'name placeholder', | ||
email: 'email placeholder', | ||
formattedAddress: 'address placeholder', | ||
}; | ||
|
||
const CardDetails = ( { charge = {}, isLoading } ) => { | ||
const details = | ||
charge && charge.payment_method_details | ||
? formatPaymentMethodDetails( charge ) | ||
: paymentMethodPlaceholders; | ||
|
||
const { id, name, email, formattedAddress } = details; | ||
|
||
return ( | ||
<div className="payment-method-details"> | ||
<div className="payment-method-details__column"> | ||
<Detail | ||
isLoading={ isLoading } | ||
label={ __( 'ID', 'woocommerce-payments' ) } | ||
> | ||
{ !! id ? id : '–' } | ||
</Detail> | ||
</div> | ||
|
||
<div className="payment-method-details__column"> | ||
<Detail | ||
isLoading={ isLoading } | ||
label={ __( 'Owner', 'woocommerce-payments' ) } | ||
> | ||
{ name || '–' } | ||
</Detail> | ||
|
||
<Detail | ||
isLoading={ isLoading } | ||
label={ __( 'Owner email', 'woocommerce-payments' ) } | ||
> | ||
{ email || '–' } | ||
</Detail> | ||
|
||
<Detail | ||
isLoading={ isLoading } | ||
label={ __( 'Address', 'woocommerce-payments' ) } | ||
> | ||
<span | ||
dangerouslySetInnerHTML={ { | ||
__html: formattedAddress || '–', | ||
} } | ||
/> | ||
</Detail> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CardDetails; |
90 changes: 90 additions & 0 deletions
90
client/payment-details/payment-method/afterpay-clearpay/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/** @format **/ | ||
|
||
/** | ||
* External dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies. | ||
*/ | ||
import Detail from '../detail'; | ||
|
||
/** | ||
* Extracts and formats payment method details from a charge. | ||
* | ||
* @param {Object} charge The charge object. | ||
* @return {Object} A flat hash of all necessary values. | ||
*/ | ||
const formatPaymentMethodDetails = ( charge ) => { | ||
const { billing_details: billingDetails, payment_method: id } = charge; | ||
|
||
const { name, email, formatted_address: formattedAddress } = billingDetails; | ||
|
||
return { | ||
id, | ||
name, | ||
email, | ||
formattedAddress, | ||
}; | ||
}; | ||
|
||
/** | ||
* Placeholders to display while loading. | ||
*/ | ||
const paymentMethodPlaceholders = { | ||
id: 'id placeholder', | ||
name: 'name placeholder', | ||
email: 'email placeholder', | ||
formattedAddress: 'address placeholder', | ||
}; | ||
|
||
const CardDetails = ( { charge = {}, isLoading } ) => { | ||
const details = | ||
charge && charge.payment_method_details | ||
? formatPaymentMethodDetails( charge ) | ||
: paymentMethodPlaceholders; | ||
|
||
const { id, name, email, formattedAddress } = details; | ||
|
||
return ( | ||
<div className="payment-method-details"> | ||
<div className="payment-method-details__column"> | ||
<Detail | ||
isLoading={ isLoading } | ||
label={ __( 'ID', 'woocommerce-payments' ) } | ||
> | ||
{ !! id ? id : '–' } | ||
</Detail> | ||
</div> | ||
<div className="payment-method-details__column"> | ||
<Detail | ||
isLoading={ isLoading } | ||
label={ __( 'Owner', 'woocommerce-payments' ) } | ||
> | ||
{ name || '–' } | ||
</Detail> | ||
|
||
<Detail | ||
isLoading={ isLoading } | ||
label={ __( 'Owner email', 'woocommerce-payments' ) } | ||
> | ||
{ email || '–' } | ||
</Detail> | ||
|
||
<Detail | ||
isLoading={ isLoading } | ||
label={ __( 'Address', 'woocommerce-payments' ) } | ||
> | ||
<span | ||
dangerouslySetInnerHTML={ { | ||
__html: formattedAddress || '–', | ||
} } | ||
/> | ||
</Detail> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CardDetails; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters