mirror of
https://github.com/jlengrand/adyen-web.git
synced 2026-03-10 08:01:22 +00:00
PayPal - Adding isExpress flag (#2220)
This commit is contained in:
committed by
GitHub
parent
d6c658d770
commit
6e60d24f48
5
.changeset/strong-snakes-attack.md
Normal file
5
.changeset/strong-snakes-attack.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@adyen/adyen-web': minor
|
||||
---
|
||||
|
||||
Added isExpress configuration to PayPal component
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user