PayPal - Adding isExpress flag (#2220)

This commit is contained in:
Guilherme Ribeiro
2023-06-16 10:21:09 +02:00
committed by GitHub
parent d6c658d770
commit 6e60d24f48
5 changed files with 21 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
'@adyen/adyen-web': minor
---
Added isExpress configuration to PayPal component

View File

@@ -6,6 +6,11 @@ describe('Paypal', () => {
expect(paypal.data).toEqual({ clientStateDataIndicator: true, paymentMethod: { subtype: 'sdk', type: 'paypal' } });
});
test('should return subtype express if isExpress flag is set', () => {
const paypal = new Paypal({ isExpress: true });
expect(paypal.data).toEqual({ clientStateDataIndicator: true, paymentMethod: { subtype: 'express', type: 'paypal' } });
});
test('Is always valid', () => {
const paypal = new Paypal({});
expect(paypal.isValid).toBe(true);

View File

@@ -49,10 +49,12 @@ class PaypalElement extends UIElement<PayPalElementProps> {
* Formats the component data output
*/
protected formatData() {
const { isExpress } = this.props;
return {
paymentMethod: {
type: PaypalElement.type,
subtype: PaypalElement.subtype
subtype: isExpress ? 'express' : PaypalElement.subtype
}
};
}

View File

@@ -49,6 +49,8 @@ const defaultProps: PayPalElementProps = {
blockPayPalVenmoButton: false,
isExpress: false,
configuration: {
/**
* @see {@link https://developer.paypal.com/docs/checkout/reference/customize-sdk/#merchant-id}

View File

@@ -149,6 +149,12 @@ interface PayPalCommonProps {
* @see {@link https://developer.paypal.com/docs/business/javascript-sdk/javascript-sdk-reference/#onshippingchange}
*/
onShippingChange?: (data, actions) => void;
/**
* Identifies if the payment is Express.
* @defaultValue false
*/
isExpress?: boolean;
}
export interface PayPalConfig {