Skip to content

Commit 742a3eb

Browse files
committed
fix getting user country
1 parent a3dafa7 commit 742a3eb

5 files changed

Lines changed: 677 additions & 4 deletions

File tree

dist/public/app.bc4c5649.js

Lines changed: 666 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/public/app.bc4c5649.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/public/app.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<link rel="stylesheet" type="text/css" href="/payments.bb4d0d94.css" media="screen"><div id="root"></div><script src="/app.8cbf016f.js"></script>
1+
<link rel="stylesheet" type="text/css" href="/payments.bb4d0d94.css" media="screen"><div id="root"></div><script src="/app.bc4c5649.js"></script>

src/public/payments/customerCheckout.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import countries from './countries'
77
import products from '../../shared/products'
88

99
export async function getUserCountry () {
10-
const res = await window.fetch('https://geoip-db.com/json/')
10+
const res = await window.fetch('https://ipinfo.io/json')
1111
const data = await res.json()
12-
return data.country_code
12+
return data.country
1313
}
1414

1515
export async function validateVAT (vatNumber) {

src/public/payments/customerCheckout.jsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@ class CustomerCheckout extends React.Component {
8787

8888
componentDidMount () {
8989
getUserCountry()
90-
.then((r) => this.setState({ country: r }))
90+
.then((r) => {
91+
if (countries.find((c) => c.code === r) == null) {
92+
console.error('Could not find user country in the countries list', r)
93+
} else {
94+
this.setState({ country: r })
95+
}
96+
})
9197
.catch(console.error.bind(console))
9298
}
9399

0 commit comments

Comments
 (0)