Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement payments via Express Checkout Element on the Cart and Checkout pages #8914

Merged
merged 71 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from 67 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
40a6a52
Add handlers for button events
rafaelzaleski May 21, 2024
318d6e5
Rename utils
rafaelzaleski May 21, 2024
e99f846
Rename ECE components
rafaelzaleski May 22, 2024
4324d65
Only load PRB or ECE in blocks
rafaelzaleski May 24, 2024
0d45344
Add handle for click event
rafaelzaleski May 24, 2024
635cbcf
Add Ajax Handler class
rafaelzaleski May 25, 2024
fdf7314
Add shipping options ajax handler
rafaelzaleski May 25, 2024
302a50c
Add shipping options management
rafaelzaleski May 26, 2024
e7e478d
Fix request to create_order endpoint
rafaelzaleski May 26, 2024
827b186
create payment method from elements
rafaelzaleski May 28, 2024
6a60a9d
Merge branch 'develop' into add/8773-ece-support-blocks-checkout-page
rafaelzaleski May 28, 2024
6ccd97f
Add payment_request_type to request to ensure compatibility
rafaelzaleski May 29, 2024
4006c97
Fix import of getErrorMessageFromNotice
rafaelzaleski May 29, 2024
01b552d
Add ECE to new payment process
rafaelzaleski May 29, 2024
4da2eea
Fix event handlers
rafaelzaleski May 29, 2024
fc41a5d
Merge branch 'develop' into add/8773-ece-support-blocks-checkout-page
rafaelzaleski May 29, 2024
95cdf90
Add changelog
rafaelzaleski May 29, 2024
8bfc361
Fix php lint errors
rafaelzaleski May 29, 2024
cca6be0
Fix JS lint errors
rafaelzaleski May 29, 2024
604dfd0
Replace function names
rafaelzaleski May 29, 2024
e853fa9
Fix php tests
rafaelzaleski May 29, 2024
3410710
Fix JS lint
rafaelzaleski May 29, 2024
1285553
Fix method references in ajax_add_to_cart
rafaelzaleski May 29, 2024
c45ce9b
Ignore psalm UndefinedClass for WC_Subscriptions_Cart
rafaelzaleski May 29, 2024
590aa09
Expose method get_quantity in button helper
rafaelzaleski May 29, 2024
c536f4d
Merge branch 'develop' into add/8773-ece-support-blocks-checkout-page
rafaelzaleski May 29, 2024
30a6814
Fix ECE button not showing when WooPay is disabled
rafaelzaleski May 31, 2024
924ddbe
Render ECE element on shortcode cart and checkout pages
reykjalin May 31, 2024
5133c64
Merge branch 'develop' into add/8870-ece-for-shortcode-cart-and-checkout
reykjalin Jun 4, 2024
ed24af2
revert ECE changes in non ECE file
reykjalin Jun 4, 2024
f3f19a9
Add correct amounts and interactions for ECE buttons
reykjalin Jun 4, 2024
63dabfd
Don't attempt to render ECE button when no shipping rate is available
reykjalin Jun 4, 2024
fae6e1a
add support for processing a payment
reykjalin Jun 5, 2024
fa260ef
add changelog entry
reykjalin Jun 5, 2024
4038fe9
Merge branch 'develop' into add/8870-ece-for-shortcode-cart-and-checkout
reykjalin Jun 5, 2024
67f5b38
fix check for shipping rates
reykjalin Jun 6, 2024
935b340
Merge branch 'develop' into add/8870-ece-for-shortcode-cart-and-checkout
reykjalin Jun 7, 2024
1aa3567
reject address and shipping rate promise immediately if not successful
reykjalin Jun 7, 2024
cd202c3
call the right Stripe event function when payment fails
reykjalin Jun 7, 2024
3c30f18
block UI while payment sheet is open
reykjalin Jun 7, 2024
1a7d257
Implement payments via Express Checkout Element on the product page.
asumaran Jun 7, 2024
0973d1f
generalize and use the shippingAddressChangeHandler
reykjalin Jun 7, 2024
c50c857
use the onConfirmHandler for completing payments
reykjalin Jun 7, 2024
1101189
Merge branch 'develop' into as-8868-ece-product-page
reykjalin Jun 7, 2024
6b013b9
use the display items normalization function
reykjalin Jun 7, 2024
0728307
add and use a shippingratechange handler
reykjalin Jun 7, 2024
eb5199b
Merge branch 'add/8870-ece-for-shortcode-cart-and-checkout' into as-8…
reykjalin Jun 7, 2024
c006636
take into account what should happen on the product page
reykjalin Jun 7, 2024
81625b7
add a changelog entry for the product page
reykjalin Jun 7, 2024
1564ba9
fix missing event parameter in abortPayment call
reykjalin Jun 7, 2024
bc29b0c
Merge branch 'develop' into as-8868-ece-product-page
cesarcosta99 Jun 7, 2024
5d52d09
Merge branch 'develop' into as-8868-ece-product-page
asumaran Jun 7, 2024
dfbc699
Use `getExpressCheckoutData` to get product options
asumaran Jun 7, 2024
4780915
stop filtering 0 amount items from line items
reykjalin Jun 10, 2024
c79db1e
add missing return statement
reykjalin Jun 14, 2024
ab882b5
add missing translation
reykjalin Jun 14, 2024
7937656
add missing async markers for event handlers
reykjalin Jun 14, 2024
54eb67b
use correct error message extraction util function
reykjalin Jun 14, 2024
eb3ecd3
disable required function return types
reykjalin Jun 14, 2024
3b81108
Merge branch 'develop' into as-8868-ece-product-page
reykjalin Jun 14, 2024
000f8ad
remove unnecessary empty array initialization
reykjalin Jun 14, 2024
0c0bf2a
fix wrong assumption about shape of cart line items provided to norma…
reykjalin Jun 19, 2024
b2e0eed
Merge branch 'develop' into as-8868-ece-product-page
reykjalin Jun 20, 2024
42eff21
add tests for express checkout utils
reykjalin Jun 20, 2024
7877718
add tests for normalization functions
reykjalin Jun 20, 2024
d558ccd
add unit tests for event handlers
reykjalin Jun 20, 2024
8592e31
add changelog entry
reykjalin Jun 20, 2024
ad37396
Merge branch 'develop' into as-8868-ece-product-page
reykjalin Jun 20, 2024
8d5d8b4
fix incorrect normalization of line items
reykjalin Jun 20, 2024
d363a55
fix failing unit test
reykjalin Jun 20, 2024
f135c9b
fix payment failure in blocks
reykjalin Jun 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog/kreykjalin-8868-ece-cart-and-checkout-page
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: add

Add support for ECE elements on the Shortcode Cart and Checkout pages
52 changes: 30 additions & 22 deletions client/express-checkout/event-handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,42 @@ import {
import { getErrorMessageFromNotice } from './utils/index';

export const shippingAddressChangeHandler = async ( api, event, elements ) => {
const response = await api.expressCheckoutECECalculateShippingOptions(
normalizeShippingAddress( event.address )
);
try {
const response = await api.expressCheckoutECECalculateShippingOptions(
normalizeShippingAddress( event.address )
);

if ( response.result === 'success' ) {
elements.update( {
amount: response.total.amount,
} );
event.resolve( {
shippingRates: response.shipping_options,
lineItems: normalizeLineItems( response.displayItems ),
} );
} else {
if ( response.result === 'success' ) {
elements.update( {
amount: response.total.amount,
} );
event.resolve( {
shippingRates: response.shipping_options,
lineItems: normalizeLineItems( response.displayItems ),
} );
} else {
event.reject();
}
} catch ( e ) {
event.reject();
}
};

export const shippingRateChangeHandler = async ( api, event, elements ) => {
const response = await api.paymentRequestUpdateShippingDetails(
event.shippingRate
);
try {
const response = await api.paymentRequestUpdateShippingDetails(
event.shippingRate
);

if ( response.result === 'success' ) {
elements.update( { amount: response.total.amount } );
event.resolve( {
lineItems: normalizeLineItems( response.displayItems ),
} );
} else {
if ( response.result === 'success' ) {
elements.update( { amount: response.total.amount } );
event.resolve( {
lineItems: normalizeLineItems( response.displayItems ),
} );
} else {
event.reject();
}
} catch ( e ) {
event.reject();
}
};
Expand Down Expand Up @@ -88,6 +96,6 @@ export const onConfirmHandler = async (
completePayment( redirectUrl );
}
} catch ( e ) {
return abortPayment( event, error.message );
return abortPayment( event, e.message );
}
};
Loading
Loading