@@ -41,6 +41,7 @@ define([
41
41
braintreeAdapter . getApiClient ( )
42
42
. then ( function ( clientInstance ) {
43
43
return braintree3DSecure . create ( {
44
+ version : 2 , // Will use 3DS 2 whenever possible
44
45
client : clientInstance
45
46
} ) ;
46
47
} )
@@ -49,6 +50,7 @@ define([
49
50
promise . resolve ( self . threeDSecureInstance ) ;
50
51
} )
51
52
. catch ( function ( err ) {
53
+ fullScreenLoader . stopLoader ( ) ;
52
54
promise . reject ( err ) ;
53
55
} ) ;
54
56
@@ -84,30 +86,55 @@ define([
84
86
var self = this ,
85
87
totalAmount = quote . totals ( ) [ 'base_grand_total' ] ,
86
88
billingAddress = quote . billingAddress ( ) ,
89
+ shippingAddress = quote . shippingAddress ( ) ,
87
90
options = {
88
91
amount : totalAmount ,
89
92
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
100
103
} ,
101
104
102
105
/**
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
104
110
*/
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
107
132
}
108
133
} ;
134
+ }
109
135
110
136
if ( ! this . isAmountAvailable ( totalAmount ) || ! this . isCountryAvailable ( billingAddress . countryId ) ) {
137
+ self . state = $ . Deferred ( ) ;
111
138
self . state . resolve ( ) ;
112
139
113
140
return self . state . promise ( ) ;
@@ -118,6 +145,7 @@ define([
118
145
. then ( function ( ) {
119
146
self . threeDSecureInstance . verifyCard ( options , function ( err , payload ) {
120
147
if ( err ) {
148
+ fullScreenLoader . stopLoader ( ) ;
121
149
self . state . reject ( err . message ) ;
122
150
123
151
return ;
@@ -129,6 +157,7 @@ define([
129
157
context . paymentPayload . nonce = payload . nonce ;
130
158
self . state . resolve ( ) ;
131
159
} else {
160
+ fullScreenLoader . stopLoader ( ) ;
132
161
self . state . reject ( $t ( 'Please try again with another form of payment.' ) ) ;
133
162
}
134
163
} ) ;
@@ -141,42 +170,6 @@ define([
141
170
return self . state . promise ( ) ;
142
171
} ,
143
172
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
-
180
173
/**
181
174
* Checks minimal amount for 3D Secure activation
182
175
*
0 commit comments