mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
♻️ Start to simplify processPayment logic
This commit is contained in:
parent
63dfb167fb
commit
d3ddc625d8
1 changed files with 6 additions and 5 deletions
|
@ -808,6 +808,8 @@ class GooglepayButton extends PaymentButton {
|
||||||
async processPayment( paymentData ) {
|
async processPayment( paymentData ) {
|
||||||
this.logGroup( 'processPayment' );
|
this.logGroup( 'processPayment' );
|
||||||
|
|
||||||
|
let result;
|
||||||
|
|
||||||
const payer = payerDataFromPaymentResponse( paymentData );
|
const payer = payerDataFromPaymentResponse( paymentData );
|
||||||
|
|
||||||
const paymentError = ( reason ) => {
|
const paymentError = ( reason ) => {
|
||||||
|
@ -891,14 +893,13 @@ class GooglepayButton extends PaymentButton {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const addBillingDataToSession = () => {
|
|
||||||
moduleStorage.setPayer( payer );
|
|
||||||
setPayerData( payer );
|
|
||||||
};
|
|
||||||
|
|
||||||
return new Promise( async ( resolve ) => {
|
return new Promise( async ( resolve ) => {
|
||||||
try {
|
try {
|
||||||
addBillingDataToSession();
|
// Add billing data to session.
|
||||||
|
moduleStorage.setPayer( payer );
|
||||||
|
setPayerData( payer );
|
||||||
|
|
||||||
await processPaymentPromise( resolve );
|
await processPaymentPromise( resolve );
|
||||||
} catch ( err ) {
|
} catch ( err ) {
|
||||||
resolve( paymentError( err.message ) );
|
resolve( paymentError( err.message ) );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue