mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-31 06:52:50 +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 ) {
|
||||
this.logGroup( 'processPayment' );
|
||||
|
||||
let result;
|
||||
|
||||
const payer = payerDataFromPaymentResponse( paymentData );
|
||||
|
||||
const paymentError = ( reason ) => {
|
||||
|
@ -891,14 +893,13 @@ class GooglepayButton extends PaymentButton {
|
|||
}
|
||||
};
|
||||
|
||||
const addBillingDataToSession = () => {
|
||||
moduleStorage.setPayer( payer );
|
||||
setPayerData( payer );
|
||||
};
|
||||
|
||||
return new Promise( async ( resolve ) => {
|
||||
try {
|
||||
addBillingDataToSession();
|
||||
// Add billing data to session.
|
||||
moduleStorage.setPayer( payer );
|
||||
setPayerData( payer );
|
||||
|
||||
await processPaymentPromise( resolve );
|
||||
} catch ( err ) {
|
||||
resolve( paymentError( err.message ) );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue