Skip to content

Commit

Permalink
refactor(payment): PAYPAL-2609 moved BraintreePayPalButtonStrategy fr…
Browse files Browse the repository at this point in the history
…om core to braintree-integration package
  • Loading branch information
serhii-tkachenko committed Feb 13, 2025
1 parent 615a909 commit 7364957
Show file tree
Hide file tree
Showing 30 changed files with 645 additions and 2,468 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ describe('BraintreePaypalCreditButtonStrategy', () => {
const braintreePaypalCreditOptions: BraintreePaypalCreditButtonInitializeOptions = {
shouldProcessPayment: false,
style: { height: 45 },
// shippingAddress: {}, // TODO: <---
onAuthorizeError: jest.fn(),
onPaymentError: jest.fn(),
onError: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ export default class BraintreePaypalCreditButtonStrategy implements CheckoutButt
currencyCode = state.getCartOrThrow().currency.code;
}

// Should payment method be loaded here?
const paymentMethod = state.getPaymentMethodOrThrow<BraintreeInitializationData>(methodId);
const { clientToken, config, initializationData } = paymentMethod;

Expand Down Expand Up @@ -206,9 +205,6 @@ export default class BraintreePaypalCreditButtonStrategy implements CheckoutButt

this.buyNowCartId = buyNowCart?.id;

// Should we load checkout once again? Since it was loaded in initialization method
// await this.paymentIntegrationService.loadDefaultCheckout();
// needed only for non buy now flow
const state = this.paymentIntegrationService.getState();
const customer = state.getCustomer();
const paymentMethod: PaymentMethod<BraintreeInitializationData> =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
import { Address } from '../../../address';
import { BuyNowCartRequestBody } from '../../../cart';
import { StandardError } from '../../../common/error/errors';
import { BraintreeError } from '../../../payment/strategies/braintree';
import { PaypalStyleOptions } from '../../../payment/strategies/paypal';
import { BraintreeError, PaypalStyleOptions } from '@bigcommerce/checkout-sdk/braintree-utils';
import {
Address,
BuyNowCartRequestBody,
StandardError,
} from '@bigcommerce/checkout-sdk/payment-integration-api';

export interface BraintreePaypalButtonInitializeOptions {
export default interface BraintreePaypalButtonInitializeOptions {
/**
* @internal
* This is an internal property and therefore subject to change. DO NOT USE.
* The options that are required to initialize Buy Now functionality.
*/
shouldProcessPayment?: boolean;
buyNowInitializeOptions?: {
getBuyNowCartRequestBody?(): BuyNowCartRequestBody | void;
};

/**
* The option that used to initialize a PayPal script with provided currency code.
*/
currencyCode?: string;

/**
* The ID of a container which the messaging should be inserted.
*/
messagingContainerId?: string;

/**
* @internal
* This is an internal property and therefore subject to change. DO NOT USE.
*/
shouldProcessPayment?: boolean;

/**
* A set of styling options for the checkout button.
*/
Expand Down Expand Up @@ -57,16 +70,11 @@ export interface BraintreePaypalButtonInitializeOptions {
*
*/
onEligibilityFailure?(): void;
}

export interface WithBraintreePaypalButtonInitializeOptions {
/**
* The option that used to initialize a PayPal script with provided currency code.
*/
currencyCode?: string;

/**
* The options that are required to initialize Buy Now functionality.
* The options that are required to initialize Braintree PayPal wallet button on Product and Cart page.
*/
buyNowInitializeOptions?: {
getBuyNowCartRequestBody?(): BuyNowCartRequestBody | void;
};
braintreepaypal?: BraintreePaypalButtonInitializeOptions;
}
Loading

0 comments on commit 7364957

Please sign in to comment.