new-subscription.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750
  1. import _ from 'lodash'
  2. /* eslint-disable
  3. camelcase,
  4. max-len,
  5. no-return-assign
  6. */
  7. /* global recurly */
  8. import App from '../base'
  9. import getMeta from '../utils/meta'
  10. export default App.controller(
  11. 'NewSubscriptionController',
  12. function ($scope, MultiCurrencyPricing, $http, $location, eventTracking) {
  13. window.couponCode = $location.search().cc || ''
  14. window.plan_code = $location.search().planCode || ''
  15. window.ITMCampaign = $location.search().itm_campaign || ''
  16. window.ITMContent = $location.search().itm_content || ''
  17. if (typeof recurly === 'undefined' || !recurly) {
  18. $scope.recurlyLoadError = true
  19. return
  20. }
  21. $scope.ui = {
  22. showCurrencyDropdown: false,
  23. showAddressSecondLine: false,
  24. addCompanyDetails: false,
  25. }
  26. $scope.recurlyLoadError = false
  27. $scope.currencyCode = MultiCurrencyPricing.currencyCode
  28. $scope.initiallySelectedCurrencyCode = MultiCurrencyPricing.currencyCode // track for payment-page-refreshed
  29. $scope.allCurrencies = MultiCurrencyPricing.plans
  30. $scope.availableCurrencies = {}
  31. $scope.planCode = window.plan_code
  32. $scope.switchToStudent = function () {
  33. const currentPlanCode = window.plan_code
  34. const planCode = currentPlanCode.replace('collaborator', 'student')
  35. eventTracking.sendMB('payment-page-switch-to-student', {
  36. plan_code: window.plan_code,
  37. })
  38. eventTracking.send(
  39. 'subscription-funnel',
  40. 'subscription-form-switch-to-student',
  41. window.plan_code
  42. )
  43. window.location = `/user/subscription/new?planCode=${planCode}&currency=${$scope.currencyCode}&cc=${$scope.data.coupon}&itm_campaign=${window.ITMCampaign}&itm_content=${window.ITMContent}`
  44. }
  45. eventTracking.sendMB('payment-page-view', { plan: window.plan_code })
  46. eventTracking.send(
  47. 'subscription-funnel',
  48. 'subscription-form-viewed',
  49. window.plan_code
  50. )
  51. $scope.paymentMethod = { value: 'credit_card' }
  52. $scope.data = {
  53. first_name: '',
  54. last_name: '',
  55. postal_code: '',
  56. address1: '',
  57. address2: '',
  58. state: '',
  59. city: '',
  60. company: '',
  61. vat_number: '',
  62. country: getMeta('ol-countryCode'),
  63. coupon: window.couponCode,
  64. }
  65. $scope.validation = {}
  66. $scope.processing = false
  67. $scope.threeDSecureFlow = false
  68. $scope.threeDSecureContainer = document.querySelector(
  69. '.three-d-secure-container'
  70. )
  71. $scope.threeDSecureRecurlyContainer = document.querySelector(
  72. '.three-d-secure-recurly-container'
  73. )
  74. recurly.configure({
  75. publicKey: getMeta('ol-recurlyApiKey'),
  76. style: {
  77. all: {
  78. fontFamily: '"Open Sans", sans-serif',
  79. fontSize: '16px',
  80. fontColor: '#7a7a7a',
  81. },
  82. month: {
  83. placeholder: 'MM',
  84. },
  85. year: {
  86. placeholder: 'YY',
  87. },
  88. cvv: {
  89. placeholder: 'CVV',
  90. },
  91. },
  92. })
  93. const pricing = recurly.Pricing()
  94. window.pricing = pricing
  95. function setupPricing() {
  96. pricing
  97. .plan(window.plan_code, { quantity: 1 })
  98. .address({
  99. country: $scope.data.country,
  100. })
  101. .tax({ tax_code: 'digital', vat_number: '' })
  102. .currency($scope.currencyCode)
  103. .coupon($scope.data.coupon)
  104. .catch(function (err) {
  105. if (
  106. $scope.currencyCode !== 'USD' &&
  107. err.name === 'invalid-currency'
  108. ) {
  109. $scope.currencyCode = 'USD'
  110. setupPricing()
  111. } else if (err.name === 'api-error' && err.code === 'not-found') {
  112. // not-found here should refer to the coupon code, plan_code should be valid
  113. $scope.$applyAsync(() => {
  114. $scope.couponError = 'Coupon code is not valid for selected plan'
  115. })
  116. } else {
  117. // Bail out on other errors, form state will not be correct
  118. $scope.$applyAsync(() => {
  119. $scope.recurlyLoadError = true
  120. })
  121. throw err
  122. }
  123. })
  124. .done()
  125. }
  126. setupPricing()
  127. pricing.on('change', () => {
  128. $scope.planName = pricing.items.plan.name
  129. if (pricing.items.plan.trial) {
  130. $scope.trialLength = pricing.items.plan.trial.length
  131. }
  132. $scope.recurlyPrice = $scope.trialLength
  133. ? pricing.price.next
  134. : pricing.price.now
  135. $scope.taxes = pricing.price.taxes
  136. $scope.monthlyBilling = pricing.items.plan.period.length === 1
  137. $scope.availableCurrencies = {}
  138. for (const currencyCode in pricing.items.plan.price) {
  139. if (MultiCurrencyPricing.plans[currencyCode]) {
  140. $scope.availableCurrencies[currencyCode] =
  141. MultiCurrencyPricing.plans[currencyCode]
  142. }
  143. }
  144. // abridged list for payment-page-refreshed split test
  145. $scope.limitedCurrencies = {}
  146. const limitedCurrencyCodes = ['USD', 'EUR', 'GBP']
  147. if (
  148. limitedCurrencyCodes.indexOf($scope.initiallySelectedCurrencyCode) ===
  149. -1
  150. ) {
  151. limitedCurrencyCodes.unshift($scope.initiallySelectedCurrencyCode)
  152. }
  153. limitedCurrencyCodes.forEach(currencyCode => {
  154. $scope.limitedCurrencies[currencyCode] =
  155. MultiCurrencyPricing.plans[currencyCode]
  156. })
  157. if (
  158. pricing.items &&
  159. pricing.items.coupon &&
  160. pricing.items.coupon.discount &&
  161. pricing.items.coupon.discount.type === 'percent'
  162. ) {
  163. const basePrice = parseInt(pricing.price.base.plan.unit, 10)
  164. $scope.coupon = {
  165. singleUse: pricing.items.coupon.single_use,
  166. normalPrice: basePrice,
  167. name: pricing.items.coupon.name,
  168. normalPriceWithoutTax: basePrice,
  169. }
  170. if (
  171. pricing.items.coupon.applies_for_months > 0 &&
  172. pricing.items.coupon.discount.rate &&
  173. pricing.items.coupon.applies_for_months
  174. ) {
  175. $scope.coupon.discountMonths = pricing.items.coupon.applies_for_months
  176. $scope.coupon.discountRate = pricing.items.coupon.discount.rate * 100
  177. }
  178. if (pricing.price.taxes[0] && pricing.price.taxes[0].rate) {
  179. $scope.coupon.normalPrice += basePrice * pricing.price.taxes[0].rate
  180. }
  181. } else {
  182. $scope.coupon = null
  183. }
  184. $scope.$apply()
  185. })
  186. $scope.applyCoupon = () => {
  187. $scope.couponError = ''
  188. pricing
  189. .coupon($scope.data.coupon)
  190. .catch(err => {
  191. if (err.name === 'api-error' && err.code === 'not-found') {
  192. $scope.$applyAsync(() => {
  193. $scope.couponError = 'Coupon code is not valid for selected plan'
  194. })
  195. } else {
  196. $scope.$applyAsync(() => {
  197. $scope.couponError =
  198. 'An error occured when verifying the coupon code'
  199. })
  200. throw err
  201. }
  202. })
  203. .done()
  204. }
  205. $scope.showAddressSecondLine = function (e) {
  206. e.preventDefault()
  207. $scope.ui.showAddressSecondLine = true
  208. }
  209. $scope.showCurrencyDropdown = function (e) {
  210. e.preventDefault()
  211. $scope.ui.showCurrencyDropdown = true
  212. }
  213. // This check is just so we don't load this on the default checkout variant
  214. const newCardInputElement = document.querySelector('#recurly-card-input')
  215. const elements = recurly.Elements()
  216. if (newCardInputElement) {
  217. const card = elements.CardElement({
  218. displayIcon: true,
  219. style: {
  220. inputType: 'mobileSelect',
  221. fontColor: '#5d6879',
  222. placeholder: {},
  223. invalid: {
  224. fontColor: '#a93529',
  225. },
  226. },
  227. })
  228. card.attach('#recurly-card-input')
  229. card.on('change', state => {
  230. $scope.$applyAsync(() => {
  231. $scope.showCardElementInvalid =
  232. !state.focus && !state.empty && !state.valid
  233. $scope.cardIsValid = state.valid
  234. })
  235. })
  236. }
  237. $scope.applyVatNumber = () =>
  238. pricing
  239. .tax({ tax_code: 'digital', vat_number: $scope.data.vat_number })
  240. .done()
  241. $scope.changeCurrency = function (newCurrency) {
  242. $scope.currencyCode = newCurrency
  243. return pricing
  244. .currency(newCurrency)
  245. .catch(function (err) {
  246. if (
  247. $scope.currencyCode !== 'USD' &&
  248. err.name === 'invalid-currency'
  249. ) {
  250. $scope.changeCurrency('USD')
  251. } else {
  252. throw err
  253. }
  254. })
  255. .done()
  256. }
  257. $scope.inputHasError = function (formItem) {
  258. if (formItem == null) {
  259. return false
  260. }
  261. return formItem.$touched && formItem.$invalid
  262. }
  263. $scope.isFormValid = function (form) {
  264. if ($scope.paymentMethod.value === 'paypal') {
  265. return $scope.data.country !== ''
  266. } else {
  267. if (newCardInputElement) {
  268. return form.$valid && $scope.cardIsValid
  269. } else {
  270. return form.$valid
  271. }
  272. }
  273. }
  274. $scope.updateCountry = () =>
  275. pricing.address({ country: $scope.data.country }).done()
  276. $scope.setPaymentMethod = function (method) {
  277. $scope.paymentMethod.value = method
  278. $scope.validation.errorFields = {}
  279. $scope.genericError = ''
  280. }
  281. let cachedRecurlyBillingToken
  282. const completeSubscription = function (
  283. err,
  284. recurlyBillingToken,
  285. recurly3DSecureResultToken
  286. ) {
  287. if (recurlyBillingToken) {
  288. // temporary store the billing token as it might be needed when
  289. // re-sending the request after SCA authentication
  290. cachedRecurlyBillingToken = recurlyBillingToken
  291. }
  292. $scope.validation.errorFields = {}
  293. if (err != null) {
  294. eventTracking.sendMB('payment-page-form-error', err)
  295. eventTracking.send('subscription-funnel', 'subscription-error')
  296. // We may or may not be in a digest loop here depending on
  297. // whether recurly could do validation locally, so do it async
  298. $scope.$evalAsync(function () {
  299. $scope.processing = false
  300. $scope.genericError = err.message
  301. _.each(
  302. err.fields,
  303. field => ($scope.validation.errorFields[field] = true)
  304. )
  305. })
  306. } else {
  307. const postData = {
  308. _csrf: window.csrfToken,
  309. recurly_token_id: cachedRecurlyBillingToken.id,
  310. recurly_three_d_secure_action_result_token_id:
  311. recurly3DSecureResultToken && recurly3DSecureResultToken.id,
  312. subscriptionDetails: {
  313. currencyCode: pricing.items.currency,
  314. plan_code: pricing.items.plan.code,
  315. coupon_code: pricing.items.coupon ? pricing.items.coupon.code : '',
  316. first_name: $scope.data.first_name,
  317. last_name: $scope.data.last_name,
  318. isPaypal: $scope.paymentMethod.value === 'paypal',
  319. address: {
  320. address1: $scope.data.address1,
  321. address2: $scope.data.address2,
  322. country: $scope.data.country,
  323. state: $scope.data.state,
  324. zip: $scope.data.postal_code,
  325. },
  326. ITMCampaign: window.ITMCampaign,
  327. ITMContent: window.ITMContent,
  328. },
  329. }
  330. if (
  331. postData.subscriptionDetails.isPaypal &&
  332. $scope.ui.addCompanyDetails
  333. ) {
  334. postData.subscriptionDetails.billing_info = {}
  335. if ($scope.data.company && $scope.data.company !== '') {
  336. postData.subscriptionDetails.billing_info.company =
  337. $scope.data.company
  338. }
  339. if ($scope.data.vat_number && $scope.data.vat_number !== '') {
  340. postData.subscriptionDetails.billing_info.vat_number =
  341. $scope.data.vat_number
  342. }
  343. }
  344. eventTracking.sendMB('payment-page-form-submit', {
  345. currencyCode: postData.subscriptionDetails.currencyCode,
  346. plan_code: postData.subscriptionDetails.plan_code,
  347. coupon_code: postData.subscriptionDetails.coupon_code,
  348. isPaypal: postData.subscriptionDetails.isPaypal,
  349. })
  350. eventTracking.send(
  351. 'subscription-funnel',
  352. 'subscription-form-submitted',
  353. postData.subscriptionDetails.plan_code
  354. )
  355. return $http
  356. .post('/user/subscription/create', postData)
  357. .then(function () {
  358. eventTracking.sendMB('payment-page-form-success')
  359. eventTracking.send(
  360. 'subscription-funnel',
  361. 'subscription-submission-success',
  362. postData.subscriptionDetails.plan_code
  363. )
  364. window.location.href = '/user/subscription/thank-you'
  365. })
  366. .catch(response => {
  367. $scope.processing = false
  368. const { data } = response
  369. $scope.genericError =
  370. (data && data.message) ||
  371. 'Something went wrong processing the request'
  372. if (data.threeDSecureActionTokenId) {
  373. initThreeDSecure(data.threeDSecureActionTokenId)
  374. }
  375. })
  376. }
  377. }
  378. $scope.submit = function () {
  379. $scope.processing = true
  380. if ($scope.paymentMethod.value === 'paypal') {
  381. const opts = { description: $scope.planName }
  382. recurly.paypal(opts, completeSubscription)
  383. } else {
  384. const tokenData = _.cloneDeep($scope.data)
  385. if (!$scope.ui.addCompanyDetails) {
  386. delete tokenData.company
  387. delete tokenData.vat_number
  388. }
  389. if (newCardInputElement) {
  390. recurly.token(elements, tokenData, completeSubscription)
  391. } else {
  392. recurly.token(tokenData, completeSubscription)
  393. }
  394. }
  395. }
  396. const initThreeDSecure = function (threeDSecureActionTokenId) {
  397. // instanciate and configure Recurly 3DSecure flow
  398. const risk = recurly.Risk()
  399. const threeDSecure = risk.ThreeDSecure({
  400. actionTokenId: threeDSecureActionTokenId,
  401. })
  402. // on SCA verification error: show payment UI with the error message
  403. threeDSecure.on('error', error => {
  404. $scope.genericError = `Error: ${error.message}`
  405. $scope.threeDSecureFlow = false
  406. $scope.$apply()
  407. })
  408. // on SCA verification success: show payment UI in processing mode and
  409. // resubmit the payment with the new token final success or error will be
  410. // handled by `completeSubscription`
  411. threeDSecure.on('token', recurly3DSecureResultToken => {
  412. completeSubscription(null, null, recurly3DSecureResultToken)
  413. $scope.genericError = null
  414. $scope.threeDSecureFlow = false
  415. $scope.processing = true
  416. $scope.$apply()
  417. })
  418. // make sure the threeDSecureRecurlyContainer is empty (in case of
  419. // retries) and show 3DSecure UI
  420. $scope.threeDSecureRecurlyContainer.innerHTML = ''
  421. $scope.threeDSecureFlow = true
  422. threeDSecure.attach($scope.threeDSecureRecurlyContainer)
  423. // scroll the UI into view (timeout needed to make sure the element is
  424. // visible)
  425. window.setTimeout(() => {
  426. $scope.threeDSecureContainer.scrollIntoView()
  427. }, 0)
  428. }
  429. // list taken from Recurly (see https://docs.recurly.com/docs/countries-provinces-and-states). Country code must exist on Recurly, so update with care
  430. $scope.countries = [
  431. { code: 'AF', name: 'Afghanistan' },
  432. { code: 'AX', name: 'Åland Islands' },
  433. { code: 'AL', name: 'Albania' },
  434. { code: 'DZ', name: 'Algeria' },
  435. { code: 'AS', name: 'American Samoa' },
  436. { code: 'AD', name: 'Andorra' },
  437. { code: 'AO', name: 'Angola' },
  438. { code: 'AI', name: 'Anguilla' },
  439. { code: 'AQ', name: 'Antarctica' },
  440. { code: 'AG', name: 'Antigua and Barbuda' },
  441. { code: 'AR', name: 'Argentina' },
  442. { code: 'AM', name: 'Armenia' },
  443. { code: 'AW', name: 'Aruba' },
  444. { code: 'AC', name: 'Ascension Island' },
  445. { code: 'AU', name: 'Australia' },
  446. { code: 'AT', name: 'Austria' },
  447. { code: 'AZ', name: 'Azerbaijan' },
  448. { code: 'BS', name: 'Bahamas' },
  449. { code: 'BH', name: 'Bahrain' },
  450. { code: 'BD', name: 'Bangladesh' },
  451. { code: 'BB', name: 'Barbados' },
  452. { code: 'BY', name: 'Belarus' },
  453. { code: 'BE', name: 'Belgium' },
  454. { code: 'BZ', name: 'Belize' },
  455. { code: 'BJ', name: 'Benin' },
  456. { code: 'BM', name: 'Bermuda' },
  457. { code: 'BT', name: 'Bhutan' },
  458. { code: 'BO', name: 'Bolivia' },
  459. { code: 'BA', name: 'Bosnia and Herzegovina' },
  460. { code: 'BW', name: 'Botswana' },
  461. { code: 'BV', name: 'Bouvet Island' },
  462. { code: 'BR', name: 'Brazil' },
  463. { code: 'BQ', name: 'British Antarctic Territory' },
  464. { code: 'IO', name: 'British Indian Ocean Territory' },
  465. { code: 'VG', name: 'British Virgin Islands' },
  466. { code: 'BN', name: 'Brunei' },
  467. { code: 'BG', name: 'Bulgaria' },
  468. { code: 'BF', name: 'Burkina Faso' },
  469. { code: 'BI', name: 'Burundi' },
  470. { code: 'CV', name: 'Cabo Verde' },
  471. { code: 'KH', name: 'Cambodia' },
  472. { code: 'CM', name: 'Cameroon' },
  473. { code: 'CA', name: 'Canada' },
  474. { code: 'IC', name: 'Canary Islands' },
  475. { code: 'CT', name: 'Canton and Enderbury Islands' },
  476. { code: 'KY', name: 'Cayman Islands' },
  477. { code: 'CF', name: 'Central African Republic' },
  478. { code: 'EA', name: 'Ceuta and Melilla' },
  479. { code: 'TD', name: 'Chad' },
  480. { code: 'CL', name: 'Chile' },
  481. { code: 'CN', name: 'China' },
  482. { code: 'CX', name: 'Christmas Island' },
  483. { code: 'CP', name: 'Clipperton Island' },
  484. { code: 'CC', name: 'Cocos [Keeling] Islands' },
  485. { code: 'CO', name: 'Colombia' },
  486. { code: 'KM', name: 'Comoros' },
  487. { code: 'CG', name: 'Congo - Brazzaville' },
  488. { code: 'CD', name: 'Congo - Kinshasa' },
  489. { code: 'CD', name: 'Congo [DRC]' },
  490. { code: 'CG', name: 'Congo [Republic]' },
  491. { code: 'CK', name: 'Cook Islands' },
  492. { code: 'CR', name: 'Costa Rica' },
  493. { code: 'CI', name: 'Côte d’Ivoire' },
  494. { code: 'HR', name: 'Croatia' },
  495. { code: 'CU', name: 'Cuba' },
  496. { code: 'CY', name: 'Cyprus' },
  497. { code: 'CZ', name: 'Czech Republic' },
  498. { code: 'DK', name: 'Denmark' },
  499. { code: 'DG', name: 'Diego Garcia' },
  500. { code: 'DJ', name: 'Djibouti' },
  501. { code: 'DM', name: 'Dominica' },
  502. { code: 'DO', name: 'Dominican Republic' },
  503. { code: 'NQ', name: 'Dronning Maud Land' },
  504. { code: 'TL', name: 'East Timor' },
  505. { code: 'EC', name: 'Ecuador' },
  506. { code: 'EG', name: 'Egypt' },
  507. { code: 'SV', name: 'El Salvador' },
  508. { code: 'GQ', name: 'Equatorial Guinea' },
  509. { code: 'ER', name: 'Eritrea' },
  510. { code: 'EE', name: 'Estonia' },
  511. { code: 'ET', name: 'Ethiopia' },
  512. { code: 'FK', name: 'Falkland Islands [Islas Malvinas]' },
  513. { code: 'FK', name: 'Falkland Islands' },
  514. { code: 'FO', name: 'Faroe Islands' },
  515. { code: 'FJ', name: 'Fiji' },
  516. { code: 'FI', name: 'Finland' },
  517. { code: 'FR', name: 'France' },
  518. { code: 'GF', name: 'French Guiana' },
  519. { code: 'PF', name: 'French Polynesia' },
  520. { code: 'FQ', name: 'French Southern and Antarctic Territories' },
  521. { code: 'TF', name: 'French Southern Territories' },
  522. { code: 'GA', name: 'Gabon' },
  523. { code: 'GM', name: 'Gambia' },
  524. { code: 'GE', name: 'Georgia' },
  525. { code: 'DE', name: 'Germany' },
  526. { code: 'GH', name: 'Ghana' },
  527. { code: 'GI', name: 'Gibraltar' },
  528. { code: 'GR', name: 'Greece' },
  529. { code: 'GL', name: 'Greenland' },
  530. { code: 'GD', name: 'Grenada' },
  531. { code: 'GP', name: 'Guadeloupe' },
  532. { code: 'GU', name: 'Guam' },
  533. { code: 'GT', name: 'Guatemala' },
  534. { code: 'GG', name: 'Guernsey' },
  535. { code: 'GW', name: 'Guinea-Bissau' },
  536. { code: 'GN', name: 'Guinea' },
  537. { code: 'GY', name: 'Guyana' },
  538. { code: 'HT', name: 'Haiti' },
  539. { code: 'HM', name: 'Heard Island and McDonald Islands' },
  540. { code: 'HN', name: 'Honduras' },
  541. { code: 'HK', name: 'Hong Kong' },
  542. { code: 'HU', name: 'Hungary' },
  543. { code: 'IS', name: 'Iceland' },
  544. { code: 'IN', name: 'India' },
  545. { code: 'ID', name: 'Indonesia' },
  546. { code: 'IR', name: 'Iran' },
  547. { code: 'IQ', name: 'Iraq' },
  548. { code: 'IE', name: 'Ireland' },
  549. { code: 'IM', name: 'Isle of Man' },
  550. { code: 'IL', name: 'Israel' },
  551. { code: 'IT', name: 'Italy' },
  552. { code: 'CI', name: 'Ivory Coast' },
  553. { code: 'JM', name: 'Jamaica' },
  554. { code: 'JP', name: 'Japan' },
  555. { code: 'JE', name: 'Jersey' },
  556. { code: 'JT', name: 'Johnston Island' },
  557. { code: 'JO', name: 'Jordan' },
  558. { code: 'KZ', name: 'Kazakhstan' },
  559. { code: 'KE', name: 'Kenya' },
  560. { code: 'KI', name: 'Kiribati' },
  561. { code: 'KW', name: 'Kuwait' },
  562. { code: 'KG', name: 'Kyrgyzstan' },
  563. { code: 'LA', name: 'Laos' },
  564. { code: 'LV', name: 'Latvia' },
  565. { code: 'LB', name: 'Lebanon' },
  566. { code: 'LS', name: 'Lesotho' },
  567. { code: 'LR', name: 'Liberia' },
  568. { code: 'LY', name: 'Libya' },
  569. { code: 'LI', name: 'Liechtenstein' },
  570. { code: 'LT', name: 'Lithuania' },
  571. { code: 'LU', name: 'Luxembourg' },
  572. { code: 'MO', name: 'Macau SAR China' },
  573. { code: 'MO', name: 'Macau' },
  574. { code: 'MK', name: 'Macedonia [FYROM]' },
  575. { code: 'MK', name: 'Macedonia' },
  576. { code: 'MG', name: 'Madagascar' },
  577. { code: 'MW', name: 'Malawi' },
  578. { code: 'MY', name: 'Malaysia' },
  579. { code: 'MV', name: 'Maldives' },
  580. { code: 'ML', name: 'Mali' },
  581. { code: 'MT', name: 'Malta' },
  582. { code: 'MH', name: 'Marshall Islands' },
  583. { code: 'MQ', name: 'Martinique' },
  584. { code: 'MR', name: 'Mauritania' },
  585. { code: 'MU', name: 'Mauritius' },
  586. { code: 'YT', name: 'Mayotte' },
  587. { code: 'FX', name: 'Metropolitan France' },
  588. { code: 'MX', name: 'Mexico' },
  589. { code: 'FM', name: 'Micronesia' },
  590. { code: 'MI', name: 'Midway Islands' },
  591. { code: 'MD', name: 'Moldova' },
  592. { code: 'MC', name: 'Monaco' },
  593. { code: 'MN', name: 'Mongolia' },
  594. { code: 'ME', name: 'Montenegro' },
  595. { code: 'MS', name: 'Montserrat' },
  596. { code: 'MA', name: 'Morocco' },
  597. { code: 'MZ', name: 'Mozambique' },
  598. { code: 'MM', name: 'Myanmar [Burma]' },
  599. { code: 'NA', name: 'Namibia' },
  600. { code: 'NR', name: 'Nauru' },
  601. { code: 'NP', name: 'Nepal' },
  602. { code: 'AN', name: 'Netherlands Antilles' },
  603. { code: 'NL', name: 'Netherlands' },
  604. { code: 'NC', name: 'New Caledonia' },
  605. { code: 'NZ', name: 'New Zealand' },
  606. { code: 'NI', name: 'Nicaragua' },
  607. { code: 'NE', name: 'Niger' },
  608. { code: 'NG', name: 'Nigeria' },
  609. { code: 'NU', name: 'Niue' },
  610. { code: 'NF', name: 'Norfolk Island' },
  611. { code: 'KP', name: 'North Korea' },
  612. { code: 'VD', name: 'North Vietnam' },
  613. { code: 'MP', name: 'Northern Mariana Islands' },
  614. { code: 'NO', name: 'Norway' },
  615. { code: 'OM', name: 'Oman' },
  616. { code: 'QO', name: 'Outlying Oceania' },
  617. { code: 'PC', name: 'Pacific Islands Trust Territory' },
  618. { code: 'PK', name: 'Pakistan' },
  619. { code: 'PW', name: 'Palau' },
  620. { code: 'PS', name: 'Palestinian Territories' },
  621. { code: 'PZ', name: 'Panama Canal Zone' },
  622. { code: 'PA', name: 'Panama' },
  623. { code: 'PG', name: 'Papua New Guinea' },
  624. { code: 'PY', name: 'Paraguay' },
  625. { code: 'YD', name: "People's Democratic Republic of Yemen" },
  626. { code: 'PE', name: 'Peru' },
  627. { code: 'PH', name: 'Philippines' },
  628. { code: 'PN', name: 'Pitcairn Islands' },
  629. { code: 'PL', name: 'Poland' },
  630. { code: 'PT', name: 'Portugal' },
  631. { code: 'PR', name: 'Puerto Rico' },
  632. { code: 'QA', name: 'Qatar' },
  633. { code: 'RE', name: 'Réunion' },
  634. { code: 'RO', name: 'Romania' },
  635. { code: 'RU', name: 'Russia' },
  636. { code: 'RW', name: 'Rwanda' },
  637. { code: 'BL', name: 'Saint Barthélemy' },
  638. { code: 'SH', name: 'Saint Helena' },
  639. { code: 'KN', name: 'Saint Kitts and Nevis' },
  640. { code: 'LC', name: 'Saint Lucia' },
  641. { code: 'MF', name: 'Saint Martin' },
  642. { code: 'PM', name: 'Saint Pierre and Miquelon' },
  643. { code: 'VC', name: 'Saint Vincent and the Grenadines' },
  644. { code: 'WS', name: 'Samoa' },
  645. { code: 'SM', name: 'San Marino' },
  646. { code: 'ST', name: 'São Tomé and Príncipe' },
  647. { code: 'SA', name: 'Saudi Arabia' },
  648. { code: 'SN', name: 'Senegal' },
  649. { code: 'CS', name: 'Serbia and Montenegro' },
  650. { code: 'RS', name: 'Serbia' },
  651. { code: 'SC', name: 'Seychelles' },
  652. { code: 'SL', name: 'Sierra Leone' },
  653. { code: 'SG', name: 'Singapore' },
  654. { code: 'SK', name: 'Slovakia' },
  655. { code: 'SI', name: 'Slovenia' },
  656. { code: 'SB', name: 'Solomon Islands' },
  657. { code: 'SO', name: 'Somalia' },
  658. { code: 'ZA', name: 'South Africa' },
  659. { code: 'GS', name: 'South Georgia and the South Sandwich Islands' },
  660. { code: 'KR', name: 'South Korea' },
  661. { code: 'ES', name: 'Spain' },
  662. { code: 'LK', name: 'Sri Lanka' },
  663. { code: 'SD', name: 'Sudan' },
  664. { code: 'SR', name: 'Suriname' },
  665. { code: 'SJ', name: 'Svalbard and Jan Mayen' },
  666. { code: 'SZ', name: 'Swaziland' },
  667. { code: 'SE', name: 'Sweden' },
  668. { code: 'CH', name: 'Switzerland' },
  669. { code: 'SY', name: 'Syria' },
  670. { code: 'TW', name: 'Taiwan' },
  671. { code: 'TJ', name: 'Tajikistan' },
  672. { code: 'TZ', name: 'Tanzania' },
  673. { code: 'TH', name: 'Thailand' },
  674. { code: 'TL', name: 'Timor-Leste' },
  675. { code: 'TG', name: 'Togo' },
  676. { code: 'TK', name: 'Tokelau' },
  677. { code: 'TO', name: 'Tonga' },
  678. { code: 'TT', name: 'Trinidad and Tobago' },
  679. { code: 'TA', name: 'Tristan da Cunha' },
  680. { code: 'TN', name: 'Tunisia' },
  681. { code: 'TR', name: 'Turkey' },
  682. { code: 'TM', name: 'Turkmenistan' },
  683. { code: 'TC', name: 'Turks and Caicos Islands' },
  684. { code: 'TV', name: 'Tuvalu' },
  685. { code: 'UM', name: 'U.S. Minor Outlying Islands' },
  686. { code: 'PU', name: 'U.S. Miscellaneous Pacific Islands' },
  687. { code: 'VI', name: 'U.S. Virgin Islands' },
  688. { code: 'UG', name: 'Uganda' },
  689. { code: 'UA', name: 'Ukraine' },
  690. { code: 'AE', name: 'United Arab Emirates' },
  691. { code: 'GB', name: 'United Kingdom' },
  692. { code: 'US', name: 'United States' },
  693. { code: 'UY', name: 'Uruguay' },
  694. { code: 'UZ', name: 'Uzbekistan' },
  695. { code: 'VU', name: 'Vanuatu' },
  696. { code: 'VA', name: 'Vatican City' },
  697. { code: 'VE', name: 'Venezuela' },
  698. { code: 'VN', name: 'Vietnam' },
  699. { code: 'WK', name: 'Wake Island' },
  700. { code: 'WF', name: 'Wallis and Futuna' },
  701. { code: 'EH', name: 'Western Sahara' },
  702. { code: 'YE', name: 'Yemen' },
  703. { code: 'ZM', name: 'Zambia' },
  704. { code: 'ZW', name: 'Zimbabwe' },
  705. ]
  706. }
  707. )