Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
frosso committed Mar 21, 2024
1 parent e8af24a commit a2995c8
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 390 deletions.
40 changes: 27 additions & 13 deletions client/checkout/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,15 +465,21 @@ export default class WCPayAPI {
* @param {Object} shippingAddress Shipping details.
* @return {Promise} Promise for the request to the server.
*/
paymentRequestCalculateShippingOptions( shippingAddress ) {
return this.request(
getPaymentRequestAjaxURL( 'get_shipping_options' ),
{
security: getPaymentRequestData( 'nonce' )?.shipping,
is_product_page: getPaymentRequestData( 'is_product_page' ),
...shippingAddress,
}
);
async paymentRequestCalculateShippingOptions( shippingAddress ) {
if ( ! this.paymentRequestCartInfo ) {
return Promise.reject();
}

// TODO ~FR: send updated info to cart with cart token, and update accordingly.
return window.wp.apiFetch( {
method: 'POST',
path: '/wc/store/v1/cart/update-customer',
headers: {
Nonce: this.paymentRequestCartInfo.nonce,
'Cart-Token': this.paymentRequestCartInfo.cartToken,
},
data: { shipping_address: shippingAddress },
} );
}

/**
Expand Down Expand Up @@ -561,10 +567,18 @@ export default class WCPayAPI {
* @param {Object} paymentData Order data.
* @return {Promise} Promise for the request to the server.
*/
paymentRequestCreateOrder( paymentData ) {
return this.request( getPaymentRequestAjaxURL( 'create_order' ), {
_wpnonce: getPaymentRequestData( 'nonce' )?.checkout,
...paymentData,
async paymentRequestCreateOrder( paymentData ) {

Check failure on line 570 in client/checkout/api/index.js

View workflow job for this annotation

GitHub Actions / JS linting

'paymentData' is defined but never used
if ( ! this.paymentRequestCartInfo ) return Promise.reject();

// TODO ~FR: this is the juicy stuff
return window.wp.apiFetch( {
method: 'POST',
path: '/wc/store/v1/cart/add-item',
headers: {
Nonce: this.paymentRequestCartInfo.nonce,
'Cart-Token': this.paymentRequestCartInfo.cartToken,
},
data: productData,

Check failure on line 581 in client/checkout/api/index.js

View workflow job for this annotation

GitHub Actions / JS linting

'productData' is not defined
} );
}

Expand Down
4 changes: 2 additions & 2 deletions client/checkout/blocks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import WCPayAPI from '../api';
import { SavedTokenHandler } from './saved-token-handler';
import request from '../utils/request';
import enqueueFraudScripts from 'fraud-scripts';
import paymentRequestPaymentMethod from '../../payment-request/blocks';
// import paymentRequestPaymentMethod from '../../payment-request/blocks';
import {
PAYMENT_METHOD_NAME_CARD,
PAYMENT_METHOD_NAME_BANCONTACT,
Expand Down Expand Up @@ -155,7 +155,7 @@ if ( getUPEConfig( 'isWooPayEnabled' ) ) {
}
}

registerExpressPaymentMethod( paymentRequestPaymentMethod( api ) );
// registerExpressPaymentMethod( paymentRequestPaymentMethod( api ) );
window.addEventListener( 'load', () => {
enqueueFraudScripts( getUPEConfig( 'fraudServices' ) );
addCheckoutTracking();
Expand Down
3 changes: 0 additions & 3 deletions client/payment-request/blocks/apple-pay-preview.js

This file was deleted.

49 changes: 0 additions & 49 deletions client/payment-request/blocks/index.js

This file was deleted.

146 changes: 0 additions & 146 deletions client/payment-request/blocks/payment-request-express.js

This file was deleted.

Loading

0 comments on commit a2995c8

Please sign in to comment.