diff --git a/.bundlemonrc.json b/.bundlemonrc.json index 7d32c78333..df38375e24 100644 --- a/.bundlemonrc.json +++ b/.bundlemonrc.json @@ -5,7 +5,7 @@ "path": "size.min.js", "compression": "gzip", "maxPercentIncrease": 3.6, - "maxSize": "77kb" + "maxSize": "79kb" } ], "reportOutput": [ diff --git a/demo/dev/button-with-message.htm b/demo/dev/button-with-message.htm new file mode 100644 index 0000000000..c7d9bf2cca --- /dev/null +++ b/demo/dev/button-with-message.htm @@ -0,0 +1,49 @@ + + + + + + + + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/globals.js b/globals.js index 30b3f726d2..068362ec38 100644 --- a/globals.js +++ b/globals.js @@ -32,6 +32,7 @@ module.exports = { __CARD_FIELD__: "/smart/card-field", __WALLET__: "/smart/wallet", __PAYMENT_FIELDS__: "/altpayfields", + __MESSAGE_MODAL__: "https://www.paypalobjects.com/upstream/bizcomponents/js/modal.js", }, }, }; diff --git a/package.json b/package.json index 6a94239981..d14c500ad3 100644 --- a/package.json +++ b/package.json @@ -114,7 +114,7 @@ "@paypal/connect-loader-component": "1.1.1", "@paypal/funding-components": "^1.0.31", "@paypal/sdk-client": "^4.0.184", - "@paypal/sdk-constants": "^1.0.141", + "@paypal/sdk-constants": "^1.0.146", "@paypal/sdk-logos": "^2.2.6" }, "lint-staged": { diff --git a/src/constants/button.js b/src/constants/button.js index 835c3717c0..9d34cd87bb 100644 --- a/src/constants/button.js +++ b/src/constants/button.js @@ -63,3 +63,24 @@ export const MENU_PLACEMENT = { ABOVE: ("above": "above"), BELOW: ("below": "below"), }; + +export const MESSAGE_OFFER = { + PAY_LATER_LONG_TERM: ("pay_later_long_term": "pay_later_long_term"), + PAY_LATER_SHORT_TERM: ("pay_later_short_term": "pay_later_short_term"), +}; + +export const MESSAGE_COLOR = { + BLACK: ("black": "black"), + WHITE: ("white": "white"), +}; + +export const MESSAGE_POSITION = { + TOP: ("top": "top"), + BOTTOM: ("bottom": "bottom"), +}; + +export const MESSAGE_ALIGN = { + CENTER: ("center": "center"), + LEFT: ("left": "left"), + RIGHT: ("right": "right"), +}; diff --git a/src/constants/class.js b/src/constants/class.js index 7c7d6b97e4..7192580eb7 100644 --- a/src/constants/class.js +++ b/src/constants/class.js @@ -42,4 +42,9 @@ export const CLASS = { HIDDEN: ("hidden": "hidden"), IMMEDIATE: ("immediate": "immediate"), + + BUTTON_MESSAGE: ("paypal-button-message": "paypal-button-message"), + + BUTTON_MESSAGE_RESERVE: + ("paypal-button-message-reserved": "paypal-button-message-reserved"), }; diff --git a/src/declarations.js b/src/declarations.js index f408237b21..6985ad993f 100644 --- a/src/declarations.js +++ b/src/declarations.js @@ -18,6 +18,7 @@ declare var __PAYPAL_CHECKOUT__: {| __VENMO__: string, __WALLET__: string, __PAYMENT_FIELDS__: string, + __MESSAGE_MODAL__: string, |}, |}; diff --git a/src/ui/buttons/buttons.jsx b/src/ui/buttons/buttons.jsx index ef2bdc5166..a13642e992 100644 --- a/src/ui/buttons/buttons.jsx +++ b/src/ui/buttons/buttons.jsx @@ -15,6 +15,7 @@ import { BUTTON_NUMBER, BUTTON_LAYOUT, BUTTON_FLOW, + MESSAGE_POSITION, } from "../../constants"; import { determineEligibleFunding, @@ -34,6 +35,8 @@ import { Button } from "./button"; import { TagLine } from "./tagline"; import { Script } from "./script"; import { PoweredByPayPal } from "./poweredBy"; +import { Message } from "./message"; +import { calculateShowPoweredBy } from "./util"; type GetWalletInstrumentOptions = {| wallet: ?Wallet, @@ -177,6 +180,8 @@ export function Buttons(props: ButtonsProps): ElementNode { supportedNativeBrowser, showPayLabel, displayOnly, + message, + messageMarkup, } = normalizeButtonProps(props); const { layout, shape, tagline } = style; @@ -237,6 +242,14 @@ export function Buttons(props: ButtonsProps): ElementNode { return i; }; + const showTagline = + tagline && + layout === BUTTON_LAYOUT.HORIZONTAL && + !fundingSource && + !message; + + const showPoweredBy = calculateShowPoweredBy(layout, fundingSources); + return (
+ {message && message.position === MESSAGE_POSITION.TOP ? ( + + ) : null} + {fundingSources.map((source, i) => (