mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-31 06:52:50 +08:00
🔥 Minor clean-up
This commit is contained in:
parent
3b92eaac81
commit
179c1d6831
1 changed files with 2 additions and 23 deletions
|
@ -386,7 +386,6 @@ class GooglepayButton {
|
|||
|
||||
updatedData.country_code = transactionInfo.countryCode;
|
||||
updatedData.currency_code = transactionInfo.currencyCode;
|
||||
updatedData.total_str = transactionInfo.totalPrice;
|
||||
|
||||
// Handle unserviceable address.
|
||||
if ( ! updatedData.shipping_options?.shippingOptions?.length ) {
|
||||
|
@ -425,7 +424,8 @@ class GooglepayButton {
|
|||
* TODO - Move this to the PaymentButton base class
|
||||
*
|
||||
* @param {string} shippingId - The shipping method ID.
|
||||
* @param {Object} shippingData - The PaymentDataRequest object that contains shipping options.
|
||||
* @param {Object} shippingData - The PaymentDataRequest object that
|
||||
* contains shipping options.
|
||||
* @param {Array} shippingData.shippingOptions
|
||||
* @param {string} shippingData.defaultSelectedOptionId
|
||||
*
|
||||
|
@ -460,27 +460,6 @@ class GooglepayButton {
|
|||
return currentOption?.cost ? this.toAmount( currentOption.cost ) : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the provided value to a number with configurable precision.
|
||||
*
|
||||
* TODO - Move this to the PaymentButton base class
|
||||
*
|
||||
* @param {any} value - The value to convert.
|
||||
* @param {number} [precision=2] - The number of decimal places.
|
||||
* @return {number} Always a numeric value with the specified precision.
|
||||
*/
|
||||
toAmount( value, precision = 2 ) {
|
||||
const number = Number( value );
|
||||
|
||||
if ( isNaN( number ) ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const multiplier = Math.pow( 10, precision );
|
||||
|
||||
return Math.round( number * multiplier ) / multiplier;
|
||||
}
|
||||
|
||||
unserviceableShippingAddressError() {
|
||||
return {
|
||||
reason: 'SHIPPING_ADDRESS_UNSERVICEABLE',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue