-
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.
Merge branch 'develop' into dev/5101-add-e2e-test-non-admin-users-can…
…-login-to-wp-admin
- Loading branch information
Showing
13 changed files
with
218 additions
and
6 deletions.
There are no files selected for viewing
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
File renamed without changes
File renamed without changes
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: minor | ||
Type: add | ||
|
||
Add WeChat Pay support to checkout. |
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
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
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
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
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
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
98 changes: 98 additions & 0 deletions
98
client/payment-details/payment-method/wechat-pay/index.tsx
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,98 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import React from 'react'; | ||
|
||
/** | ||
* Internal dependencies. | ||
*/ | ||
import Detail from '../detail'; | ||
import { PaymentMethodDetails } from 'wcpay/payment-details/types'; | ||
import { Charge } from 'wcpay/types/charges'; | ||
|
||
/** | ||
* Extracts and formats payment method details from a charge. | ||
* | ||
* @param {Charge} charge The charge object. | ||
* @return {PaymentMethodDetails} A flat hash of all necessary values. | ||
*/ | ||
const formatPaymentMethodDetails = ( charge: Charge ): PaymentMethodDetails => { | ||
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: PaymentMethodDetails = { | ||
id: 'id placeholder', | ||
name: 'name placeholder', | ||
email: 'email placeholder', | ||
formattedAddress: 'address placeholder', | ||
}; | ||
|
||
interface WeChatPayDetailsProps { | ||
charge?: Charge; | ||
isLoading: boolean; | ||
} | ||
|
||
const WeChatPayDetails: React.FC< WeChatPayDetailsProps > = ( { | ||
charge, | ||
isLoading, | ||
} ) => { | ||
const { id, name, email, formattedAddress } = | ||
charge && charge.payment_method_details | ||
? formatPaymentMethodDetails( charge ) | ||
: paymentMethodPlaceholders; | ||
|
||
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 | ||
// eslint-disable-next-line react/no-danger | ||
dangerouslySetInnerHTML={ { | ||
__html: formattedAddress || '–', | ||
} } | ||
/> | ||
</Detail> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default WeChatPayDetails; |
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
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