diff --git a/examples/amp-subscriptions-smartbox.amp.html b/examples/amp-subscriptions-google/amp-subscriptions-smartbox.amp.html similarity index 96% rename from examples/amp-subscriptions-smartbox.amp.html rename to examples/amp-subscriptions-google/amp-subscriptions-smartbox.amp.html index 3fadcb4084fd..ecf679b9d9f7 100644 --- a/examples/amp-subscriptions-smartbox.amp.html +++ b/examples/amp-subscriptions-google/amp-subscriptions-smartbox.amp.html @@ -215,18 +215,16 @@ +

You need to append "#swg.experiments=smartbox" at the end of the URL and then refresh.

- - - -

"Smart Button (Light)"

"Smart Button (Dark)"

@@ -235,6 +233,7 @@

"Smart Button (Dark)"

subscriptions-lang="en" subscriptions-action="subscribe-smartbutton-dark" subscriptions-service="subscribe.google.com" + subscriptions-message-number="1" subscriptions-decorate>Yes I will Contribute

"Smart Button (Dark w/ custom message text color)"

@@ -244,8 +243,8 @@

"Smart Button (Dark w/ custom message text color)"

subscriptions-action="subscribe-smartbutton-dark" subscriptions-service="subscribe.google.com" subscriptions-message-text-color="rgba(0, 120, 255, 0.95)" + subscriptions-message-number="1" subscriptions-decorate>Yes I will Contribute - diff --git a/extensions/amp-subscriptions-google/0.1/amp-subscriptions-google.js b/extensions/amp-subscriptions-google/0.1/amp-subscriptions-google.js index 3d0ff75ee13a..1e5e0bd5631b 100644 --- a/extensions/amp-subscriptions-google/0.1/amp-subscriptions-google.js +++ b/extensions/amp-subscriptions-google/0.1/amp-subscriptions-google.js @@ -579,6 +579,12 @@ export class GoogleSubscriptionsPlatform { if (messageTextColor) { opts.messageTextColor = messageTextColor; } + const messageNumber = element.getAttribute( + 'subscriptions-message-number' + ); + if (messageNumber) { + opts.messageNumber = messageNumber; + } this.runtime_.attachSmartButton(element, opts, () => {}); break; default: diff --git a/extensions/amp-subscriptions-google/0.1/test/test-amp-subscriptions-google.js b/extensions/amp-subscriptions-google/0.1/test/test-amp-subscriptions-google.js index e7b463e7f504..515b9775e4ff 100644 --- a/extensions/amp-subscriptions-google/0.1/test/test-amp-subscriptions-google.js +++ b/extensions/amp-subscriptions-google/0.1/test/test-amp-subscriptions-google.js @@ -673,6 +673,20 @@ describes.realWin('amp-subscriptions-google', {amp: true}, (env) => { }); }); + it('should use message number', () => { + const elem = env.win.document.createElement('div'); + const attachStub = env.sandbox.stub(platform.runtime_, 'attachSmartButton'); + elem.textContent = 'some html'; + elem.setAttribute('subscriptions-lang', 'en'); + elem.setAttribute('subscriptions-message-number', 1); + platform.decorateUI(elem, 'subscribe-smartbutton'); + expect(attachStub).to.be.calledWith(elem, { + lang: 'en', + theme: 'light', + messageNumber: '1', // Message is 'Subscribe with just a few taps' on smartbox button. + }); + }); + it('should throw if smartButton language is missing', () => { //expectAsyncConsoleError(/must have a language attrbiute​​​/); const elem = env.win.document.createElement('div');