@@ -41,6 +41,7 @@ define([
4141 braintreeAdapter . getApiClient ( )
4242 . then ( function ( clientInstance ) {
4343 return braintree3DSecure . create ( {
44+ version : 2 , // Will use 3DS 2 whenever possible
4445 client : clientInstance
4546 } ) ;
4647 } )
@@ -49,6 +50,7 @@ define([
4950 promise . resolve ( self . threeDSecureInstance ) ;
5051 } )
5152 . catch ( function ( err ) {
53+ fullScreenLoader . stopLoader ( ) ;
5254 promise . reject ( err ) ;
5355 } ) ;
5456
@@ -84,30 +86,55 @@ define([
8486 var self = this ,
8587 totalAmount = quote . totals ( ) [ 'base_grand_total' ] ,
8688 billingAddress = quote . billingAddress ( ) ,
89+ shippingAddress = quote . shippingAddress ( ) ,
8790 options = {
8891 amount : totalAmount ,
8992 nonce : context . paymentPayload . nonce ,
90-
91- /**
92- * Adds iframe to page
93- * @param { Object } err
94- * @param { Object } iframe
95- */
96- addFrame : function ( err , iframe ) {
97- self . createModal ( $ ( iframe ) ) ;
98- fullScreenLoader . stopLoader ( ) ;
99- self . modal . openModal ( ) ;
93+ billingAddress : {
94+ givenName : billingAddress . firstname ,
95+ surname : billingAddress . lastname ,
96+ phoneNumber : billingAddress . telephone ,
97+ streetAddress : billingAddress . street [ 0 ] ,
98+ extendedAddress : billingAddress . street [ 1 ] ,
99+ locality : billingAddress . city ,
100+ region : billingAddress . regionCode ,
101+ postalCode : billingAddress . postcode ,
102+ countryCodeAlpha2 : billingAddress . countryId
100103 } ,
101104
102105 /**
103- * Removes iframe from page
106+ * Will be called after receiving ThreeDSecure response, before completing the flow.
107+ *
108+ * @param {Object } data - ThreeDSecure data to consume before continuing
109+ * @param {Function } next - callback to continue flow
104110 */
105- removeFrame : function ( ) {
106- self . modal . closeModal ( ) ;
111+ onLookupComplete : function ( data , next ) {
112+ next ( ) ;
113+ }
114+ } ;
115+
116+ if ( context . paymentPayload . details ) {
117+ options . bin = context . paymentPayload . details . bin ;
118+ }
119+
120+ if ( shippingAddress ) {
121+ options . additionalInformation = {
122+ shippingGivenName : shippingAddress . firstname ,
123+ shippingSurname : shippingAddress . lastname ,
124+ shippingPhone : shippingAddress . telephone ,
125+ shippingAddress : {
126+ streetAddress : shippingAddress . street [ 0 ] ,
127+ extendedAddress : shippingAddress . street [ 1 ] ,
128+ locality : shippingAddress . city ,
129+ region : shippingAddress . regionCode ,
130+ postalCode : shippingAddress . postcode ,
131+ countryCodeAlpha2 : shippingAddress . countryId
107132 }
108133 } ;
134+ }
109135
110136 if ( ! this . isAmountAvailable ( totalAmount ) || ! this . isCountryAvailable ( billingAddress . countryId ) ) {
137+ self . state = $ . Deferred ( ) ;
111138 self . state . resolve ( ) ;
112139
113140 return self . state . promise ( ) ;
@@ -118,6 +145,7 @@ define([
118145 . then ( function ( ) {
119146 self . threeDSecureInstance . verifyCard ( options , function ( err , payload ) {
120147 if ( err ) {
148+ fullScreenLoader . stopLoader ( ) ;
121149 self . state . reject ( err . message ) ;
122150
123151 return ;
@@ -129,6 +157,7 @@ define([
129157 context . paymentPayload . nonce = payload . nonce ;
130158 self . state . resolve ( ) ;
131159 } else {
160+ fullScreenLoader . stopLoader ( ) ;
132161 self . state . reject ( $t ( 'Please try again with another form of payment.' ) ) ;
133162 }
134163 } ) ;
@@ -141,42 +170,6 @@ define([
141170 return self . state . promise ( ) ;
142171 } ,
143172
144- /**
145- * Creates modal window
146- *
147- * @param {Object } $context
148- * @private
149- */
150- createModal : function ( $context ) {
151- var self = this ,
152- options = {
153- clickableOverlay : false ,
154- buttons : [ ] ,
155- modalCloseBtnHandler : self . cancelFlow . bind ( self ) ,
156- keyEventHandlers : {
157- escapeKey : self . cancelFlow . bind ( self )
158- }
159- } ;
160-
161- // adjust iframe styles
162- $context . attr ( 'width' , '100%' ) ;
163- self . modal = Modal ( options , $context ) ;
164- } ,
165-
166- /**
167- * Cancels 3D Secure flow
168- *
169- * @private
170- */
171- cancelFlow : function ( ) {
172- var self = this ;
173-
174- self . threeDSecureInstance . cancelVerifyCard ( function ( ) {
175- self . modal . closeModal ( ) ;
176- self . state . reject ( ) ;
177- } ) ;
178- } ,
179-
180173 /**
181174 * Checks minimal amount for 3D Secure activation
182175 *
0 commit comments