diff options
| author | Joe Carstairs <jcarstairs@scottlogic.com> | 2024-01-29 11:53:41 +0000 |
|---|---|---|
| committer | Joe Carstairs <jcarstairs@scottlogic.com> | 2024-01-29 11:53:41 +0000 |
| commit | ad2a780f5bb3e48d95ad2724eb4868bf43883c32 (patch) | |
| tree | b39ea0325e7fb3cfbef6d0d24a1225dda0595a7c /src/scripts | |
| parent | 48bf60f8347db2a22f207441d463e649a9e4e08c (diff) | |
Types lib/api
Diffstat (limited to 'src/scripts')
| -rw-r--r-- | src/scripts/wc/paypal-product-buttons.ts | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/scripts/wc/paypal-product-buttons.ts b/src/scripts/wc/paypal-product-buttons.ts index b2e7e35..3c04ddf 100644 --- a/src/scripts/wc/paypal-product-buttons.ts +++ b/src/scripts/wc/paypal-product-buttons.ts @@ -68,8 +68,7 @@ class PaypalProductButtons extends HTMLElement { return constructButtons({ // This function is called to set up the transaction details without actually carrying it out async createOrder() { - - let response: Response; + let response; try { response = await api.createOrder({ productDescription, shortDescription, totalPrice }); } catch (err) { @@ -83,7 +82,7 @@ class PaypalProductButtons extends HTMLElement { `); } - const { orderId, approvalLink } = await response.json(); + const { orderId, approvalLink } = response.body; console.info(` Successfully created order with ID ${orderId}. Approval link: ${approvalLink} @@ -93,7 +92,7 @@ class PaypalProductButtons extends HTMLElement { // This function is called after payment is confirmed async onApprove(data) { - let response: Response; + let response; try { response = await api.captureOrder(data.orderID); } catch (err) { @@ -107,10 +106,10 @@ class PaypalProductButtons extends HTMLElement { `); } - const { orderId, requestStatus } = await response.json(); + const { orderId, paypalStatus } = response.body; console.info(` Successfully captured order with ID ${orderId}, - request status is ${requestStatus}. + request status is ${paypalStatus}. `); console.info(`Redirecting to confirmation page, ${successPageUrl}...`); |
