@paypal/checkout-components
Advanced tools
Comparing version 5.0.335 to 5.0.336
{ | ||
"name": "@paypal/checkout-components", | ||
"version": "5.0.335", | ||
"version": "5.0.336", | ||
"description": "PayPal Checkout components, for integrating checkout products.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -355,3 +355,3 @@ /* @flow */ | ||
if (response.status !== 200) { | ||
actions.reject(errors?.ADDRESS_ERROR); | ||
return actions.reject(errors?.ADDRESS_ERROR); | ||
} | ||
@@ -388,3 +388,3 @@ }; | ||
if (response.status !== 200) { | ||
actions.reject(errors?.METHOD_UNAVAILABLE); | ||
return actions.reject(errors?.METHOD_UNAVAILABLE); | ||
} | ||
@@ -391,0 +391,0 @@ }; |
@@ -639,6 +639,16 @@ /* @flow */ | ||
); | ||
// $FlowIssue | ||
await onShippingAddressChange(data, actions); | ||
expect(actions.reject).toHaveBeenCalledWith(errors.ADDRESS_ERROR); | ||
expect.assertions(1); | ||
const localActions = { | ||
// eslint-disable-next-line compat/compat | ||
reject: vi.fn((message) => Promise.reject(message)), | ||
}; | ||
// $FlowIssueeslint-disable-next-line compat/compat | ||
await expect(onShippingAddressChange(data, localActions)).rejects.toThrow( | ||
errors.ADDRESS_ERROR | ||
); | ||
expect(localActions.reject).toHaveBeenCalledWith(errors.ADDRESS_ERROR); | ||
expect.assertions(2); | ||
}); | ||
@@ -645,0 +655,0 @@ |
@@ -443,3 +443,3 @@ /* eslint-disable eslint-comments/disable-enable-pair */ | ||
export type ButtonMessageInputs = {| | ||
amount?: number | void, | ||
amount?: number | string | void, | ||
offer?: $ReadOnlyArray<$Values<typeof MESSAGE_OFFER>> | void, | ||
@@ -783,3 +783,2 @@ color?: $Values<typeof MESSAGE_COLOR> | void, | ||
const { | ||
amount, | ||
color = MESSAGE_COLOR.BLACK, | ||
@@ -790,4 +789,9 @@ position, | ||
let offer = message.offer; | ||
let amount = message.amount; | ||
if (typeof amount !== "undefined") { | ||
if (typeof amount !== "number") { | ||
if (typeof amount === "string") { | ||
amount = Number(amount); | ||
} | ||
if (typeof amount !== "number" || isNaN(amount)) { | ||
throw new TypeError( | ||
@@ -794,0 +798,0 @@ `Expected message.amount to be a number, got: ${amount}` |
@@ -21,2 +21,6 @@ /* @flow */ | ||
import { getSessionID } from "../../lib"; | ||
import type { | ||
OnShippingOptionsChange, | ||
OnShippingAddressChange, | ||
} from "../../ui/buttons/props"; | ||
@@ -43,2 +47,5 @@ type CardProps = {| | ||
token: string, | ||
onShippingAddressChange?: OnShippingAddressChange, | ||
onShippingOptionsChange?: OnShippingOptionsChange, | ||
hasShippingCallback?: boolean, | ||
|}; | ||
@@ -88,2 +95,23 @@ | ||
onShippingAddressChange: { | ||
type: "function", | ||
required: false, | ||
}, | ||
onShippingOptionsChange: { | ||
type: "function", | ||
required: false, | ||
}, | ||
hasShippingCallback: { | ||
type: "boolean", | ||
required: false, | ||
queryParam: true, | ||
value: ({ props }) => { | ||
return Boolean( | ||
props.onShippingAddressChange || props.onShippingOptionsChange | ||
); | ||
}, | ||
}, | ||
buttonSessionID: { | ||
@@ -90,0 +118,0 @@ type: "string", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1215293
16858