mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
🔥 Simplify code, remove console output
This commit is contained in:
parent
f2301a4674
commit
ac98600b8f
5 changed files with 8 additions and 26 deletions
|
@ -39,8 +39,7 @@ class BaseHandler {
|
|||
data.total,
|
||||
data.shipping_fee,
|
||||
data.currency_code,
|
||||
data.country_code,
|
||||
true
|
||||
data.country_code
|
||||
);
|
||||
|
||||
resolve( transaction );
|
||||
|
|
|
@ -19,8 +19,7 @@ class PayNowHandler extends BaseHandler {
|
|||
data.total,
|
||||
data.shipping_fee,
|
||||
data.currency_code,
|
||||
data.country_code,
|
||||
true
|
||||
data.country_code
|
||||
);
|
||||
|
||||
resolve( transaction );
|
||||
|
|
|
@ -47,8 +47,7 @@ class SingleProductHandler extends BaseHandler {
|
|||
data.total,
|
||||
data.shipping_fee,
|
||||
data.currency_code,
|
||||
data.country_code,
|
||||
true
|
||||
data.country_code
|
||||
);
|
||||
|
||||
resolve( transaction );
|
||||
|
|
|
@ -337,7 +337,7 @@ class GooglepayButton {
|
|||
const paymentDataRequest = Object.assign( {}, baseRequest );
|
||||
paymentDataRequest.allowedPaymentMethods =
|
||||
googlePayConfig.allowedPaymentMethods;
|
||||
paymentDataRequest.transactionInfo = this.transactionInfo.dataObject;
|
||||
paymentDataRequest.transactionInfo = this.transactionInfo.finalObject;
|
||||
paymentDataRequest.merchantInfo = googlePayConfig.merchantInfo;
|
||||
|
||||
if (
|
||||
|
@ -500,7 +500,7 @@ class GooglepayButton {
|
|||
* @return {{totalPrice: string, countryCode: string, totalPriceStatus: string, currencyCode: string}} Updated details.
|
||||
*/
|
||||
calculateNewTransactionInfo( transactionInfo ) {
|
||||
return transactionInfo.dataObject;
|
||||
return transactionInfo.finalObject;
|
||||
}
|
||||
|
||||
//------------------------
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
export default class TransactionInfo {
|
||||
#country = '';
|
||||
#currency = '';
|
||||
#isFinal = false;
|
||||
#amount = 0;
|
||||
#shippingFee = 0;
|
||||
|
||||
constructor( total, shippingFee, currency, country, isFinal ) {
|
||||
constructor( total, shippingFee, currency, country ) {
|
||||
this.#country = country;
|
||||
this.#currency = currency;
|
||||
this.#isFinal = isFinal;
|
||||
|
||||
this.shippingFee = shippingFee;
|
||||
this.amount = total - shippingFee;
|
||||
|
@ -38,21 +36,17 @@ export default class TransactionInfo {
|
|||
return this.#country;
|
||||
}
|
||||
|
||||
get totalPriceStatus() {
|
||||
return this.#isFinal ? 'FINAL' : 'DRAFT';
|
||||
}
|
||||
|
||||
get totalPrice() {
|
||||
const total = this.#amount + this.#shippingFee;
|
||||
|
||||
return total.toFixed( 2 );
|
||||
}
|
||||
|
||||
get dataObject() {
|
||||
get finalObject() {
|
||||
return {
|
||||
countryCode: this.countryCode,
|
||||
currencyCode: this.currencyCode,
|
||||
totalPriceStatus: this.totalPriceStatus,
|
||||
totalPriceStatus: 'FINAL',
|
||||
totalPrice: this.totalPrice,
|
||||
};
|
||||
}
|
||||
|
@ -74,15 +68,6 @@ export default class TransactionInfo {
|
|||
if ( totalPrice ) {
|
||||
this.shippingFee = shippingFee;
|
||||
this.amount = totalPrice - this.shippingFee;
|
||||
|
||||
console.log(
|
||||
'New Total Price:',
|
||||
totalPrice,
|
||||
'=',
|
||||
this.amount,
|
||||
'+',
|
||||
this.shippingFee
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue