@@ -26,11 +26,11 @@ import {
2626 WEB_PAYMENT_BASIC_CARD_METHOD ,
2727 WEB_PAYMENT_APPLE_PAY_METHOD ,
2828} from 'lib/web-payment' ;
29+ import { abtest } from 'lib/abtest' ;
2930
3031export class PaymentBox extends PureComponent {
3132 constructor ( ) {
3233 super ( ) ;
33- this . handlePaymentMethodChange = this . handlePaymentMethodChange . bind ( this ) ;
3434 }
3535
3636 componentDidUpdate ( ) {
@@ -44,14 +44,14 @@ export class PaymentBox extends PureComponent {
4444 }
4545 }
4646
47- handlePaymentMethodChange ( paymentMethod ) {
47+ handlePaymentMethodChange = paymentMethod => {
4848 const onSelectPaymentMethod = this . props . onSelectPaymentMethod ;
4949 return function ( ) {
5050 analytics . ga . recordEvent ( 'Upgrades' , 'Switch Payment Method' ) ;
5151 analytics . tracks . recordEvent ( 'calypso_checkout_switch_to_' + snakeCase ( paymentMethod ) ) ;
5252 onSelectPaymentMethod ( paymentMethod ) ;
5353 } ;
54- }
54+ } ;
5555
5656 getPaymentProviderLabel ( method ) {
5757 let labelLogo = (
@@ -124,6 +124,7 @@ export class PaymentBox extends PureComponent {
124124 href = ""
125125 onClick = { this . handlePaymentMethodChange ( method ) }
126126 selected = { this . props . currentPaymentMethod === method }
127+ onKeyPress = { event => this . choosePaymentMethodWithKeyboard ( event , method ) }
127128 >
128129 { this . getPaymentProviderLabel ( method ) }
129130 </ NavItem >
@@ -139,8 +140,45 @@ export class PaymentBox extends PureComponent {
139140 } ) ;
140141 }
141142
143+ renderPaymentMethod = ( paymentMethods , isPaymentMethodTest , titleText ) => {
144+ if ( isPaymentMethodTest ) {
145+ return (
146+ < div className = "payment-box__pm-test-wrapper" >
147+ < h2 className = "payment-box__pm-title" >
148+ { this . props . translate ( 'Choose a payment method' ) }
149+ </ h2 >
150+ < ul className = "payment-box__pm-wrapper" > { paymentMethods } </ ul >
151+ </ div >
152+ ) ;
153+ }
154+
155+ if ( paymentMethods ) {
156+ return (
157+ < SectionNav selectedText = { titleText } >
158+ < NavTabs > { paymentMethods } </ NavTabs >
159+ </ SectionNav >
160+ ) ;
161+ }
162+
163+ return null ;
164+ } ;
165+
166+ choosePaymentMethodWithKeyboard = ( event , method ) => {
167+ const code = event . keyCode || event . which ;
168+ if ( code === 13 ) {
169+ //13 is the enter keycode
170+ this . props . onSelectPaymentMethod ( method ) ;
171+ }
172+ } ;
173+
142174 render ( ) {
143- const cardClass = classNames ( 'payment-box' , this . props . classSet ) ,
175+ const paymentMethods = this . getPaymentMethods ( ) ;
176+ const isPaymentMethodTest = paymentMethods && abtest ( 'checkoutPaymentTypes' ) === 'radios' ;
177+ const cardClass = classNames (
178+ 'payment-box' ,
179+ this . props . classSet ,
180+ isPaymentMethodTest && 'payment-box--payment-methods-test'
181+ ) ,
144182 contentClass = classNames ( 'payment-box__content' , this . props . contentClassSet ) ;
145183
146184 const titleText = this . props . currentPaymentMethod
@@ -151,20 +189,20 @@ export class PaymentBox extends PureComponent {
151189 } )
152190 : this . props . translate ( 'Loading…' ) ;
153191
154- const paymentMethods = this . getPaymentMethods ( ) ;
155-
156192 return (
157193 < div className = "checkout__payment-box-container" key = { this . props . currentPage } >
158194 { this . props . title ? < SectionHeader label = { this . props . title } /> : null }
159195
160- { paymentMethods && (
161- < SectionNav selectedText = { titleText } >
162- < NavTabs > { paymentMethods } </ NavTabs >
163- </ SectionNav >
164- ) }
196+ { this . renderPaymentMethod ( paymentMethods , isPaymentMethodTest , titleText ) }
165197
166198 < Card className = { cardClass } >
167199 < div className = "checkout__box-padding" >
200+ { isPaymentMethodTest && (
201+ < h2 className = "checkout__payment-information-title" >
202+ { this . props . translate ( 'Enter your payment information' ) }
203+ </ h2 >
204+ ) }
205+
168206 < div className = { contentClass } > { this . props . children } </ div >
169207 </ div >
170208 </ Card >
0 commit comments