Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
liberty
tunnel
liberty-tunnel-client-library-apple
Commits
9125476a
Commit
9125476a
authored
Aug 14, 2019
by
Jose Blaya
Browse files
Remove sandbox transactions in production
parent
ca66c72a
Changes
9
Hide whitespace changes
Inline
Side-by-side
PIALibrary/Resources/UI/iOS/en.lproj/Signup.strings
View file @
9125476a
...
...
@@ -21,8 +21,6 @@
"failure.vc_title" = "Sign-up failed";
"failure.title" = "Account creation failed";
"failure.message" = "We're unable to create an account at this time. Please try again later. Reopening the app will re-attempt to create an account.";
"failure.environment.title" = "Invalid environment";
"failure.environment.message" = "Your have a sandbox receipt. Purchases with sandbox receipts are not available in Beta or Production builds.";
"failure.redeem.invalid.title" = "Invalid card PIN";
"failure.redeem.invalid.message" = "Looks like you entered an invalid card PIN. Please try again.";
"failure.redeem.claimed.title" = "Card claimed already";
...
...
PIALibrary/Sources/Library/Account/DefaultAccountProvider.swift
View file @
9125476a
...
...
@@ -347,11 +347,6 @@ class DefaultAccountProvider: AccountProvider, ConfigurationAccess, DatabaseAcce
// callback?(uncredited, nil)
// return
// }
if
!
Client
.
configuration
.
arePurchasesAvailable
()
{
callback
?(
nil
,
ClientError
.
invalidEnvironment
)
return
}
self
.
accessedStore
.
purchaseProduct
(
product
)
{
(
transaction
,
error
)
in
guard
let
transaction
=
transaction
else
{
callback
?(
nil
,
error
)
...
...
@@ -363,12 +358,6 @@ class DefaultAccountProvider: AccountProvider, ConfigurationAccess, DatabaseAcce
}
func
restorePurchases
(
_
callback
:
SuccessLibraryCallback
?)
{
if
!
Client
.
configuration
.
arePurchasesAvailable
()
{
callback
?(
ClientError
.
invalidEnvironment
)
return
}
accessedStore
.
refreshPaymentReceipt
(
callback
)
}
...
...
@@ -389,12 +378,19 @@ class DefaultAccountProvider: AccountProvider, ConfigurationAccess, DatabaseAcce
return
}
guard
let
credentials
=
credentials
else
{
// If bad Receipt and purchases are not available, remove and clean the transaction from the queue
if
error
as?
ClientError
==
.
badReceipt
,
let
transaction
=
request
.
transaction
,
!
Client
.
configuration
.
arePurchasesAvailable
()
{
self
.
accessedStore
.
finishTransaction
(
transaction
,
success
:
false
)
}
callback
?(
nil
,
error
)
return
}
if
let
transaction
=
request
.
transaction
{
self
.
accessedStore
.
finishTransaction
(
transaction
,
success
:
true
)
}
self
.
accessedDatabase
.
plain
.
lastSignupEmail
=
nil
self
.
accessedDatabase
.
secure
.
setPublicUsername
(
credentials
.
username
)
self
.
accessedDatabase
.
secure
.
setPassword
(
credentials
.
password
,
for
:
credentials
.
username
)
...
...
@@ -525,17 +521,19 @@ class DefaultAccountProvider: AccountProvider, ConfigurationAccess, DatabaseAcce
callback
?(
nil
,
ClientError
.
noReceipt
)
return
}
if
!
Client
.
configuration
.
arePurchasesAvailable
()
{
callback
?(
nil
,
ClientError
.
invalidEnvironment
)
return
}
webServices
.
processPayment
(
credentials
:
user
.
credentials
,
request
:
payment
)
{
(
error
)
in
if
let
_
=
error
{
if
let
error
=
error
{
// If bad Receipt and purchases are not available, remove and clean the transaction from the queue
if
error
as?
ClientError
==
.
badReceipt
,
let
transaction
=
request
.
transaction
,
!
Client
.
configuration
.
arePurchasesAvailable
()
{
self
.
accessedStore
.
finishTransaction
(
transaction
,
success
:
false
)
}
callback
?(
nil
,
error
)
return
}
if
let
transaction
=
request
.
transaction
{
self
.
accessedStore
.
finishTransaction
(
transaction
,
success
:
true
)
}
...
...
PIALibrary/Sources/Library/Client+Configuration.swift
View file @
9125476a
...
...
@@ -297,7 +297,7 @@ extension Client {
public
func
arePurchasesAvailable
()
->
Bool
{
if
let
url
=
Bundle
.
main
.
appStoreReceiptURL
,
url
.
lastPathComponent
==
"sandboxReceipt"
,
!
isDevelopment
{
Client
.
environment
==
.
production
{
return
false
}
return
true
...
...
PIALibrary/Sources/Library/ClientError.swift
View file @
9125476a
...
...
@@ -60,7 +60,5 @@ public enum ClientError: String, Error {
/// Invalid parameter
case
invalidParameter
/// Invalid environment
case
invalidEnvironment
#endif
}
PIALibrary/Sources/Library/WebServices/PIAWebServices.swift
View file @
9125476a
...
...
@@ -93,11 +93,6 @@ class PIAWebServices: WebServices, ConfigurationAccess {
400
:
.
badReceipt
]
if
!
Client
.
configuration
.
arePurchasesAvailable
()
{
callback
?(
nil
,
ClientError
.
invalidEnvironment
)
return
}
req
(
nil
,
.
post
,
endpoint
,
parameters
,
status
,
JSONRequestExecutor
()
{
(
json
,
status
,
error
)
in
if
let
knownError
=
self
.
knownError
(
endpoint
,
status
,
errors
)
{
callback
?(
nil
,
knownError
)
...
...
@@ -165,11 +160,6 @@ class PIAWebServices: WebServices, ConfigurationAccess {
400
:
.
badReceipt
]
if
!
Client
.
configuration
.
arePurchasesAvailable
()
{
callback
?(
ClientError
.
invalidEnvironment
)
return
}
req
(
credentials
,
.
post
,
endpoint
,
parameters
,
status
,
JSONRequestExecutor
()
{
(
json
,
status
,
error
)
in
if
let
knownError
=
self
.
knownError
(
endpoint
,
status
,
errors
)
{
callback
?(
knownError
)
...
...
PIALibrary/Sources/UI/iOS/SwiftGen+Strings.swift
View file @
9125476a
...
...
@@ -21,12 +21,6 @@ internal enum L10n {
internal
static
let
title
=
L10n
.
tr
(
"Signup"
,
"failure.title"
)
/// Sign-up failed
internal
static
let
vcTitle
=
L10n
.
tr
(
"Signup"
,
"failure.vc_title"
)
internal
enum
Environment
{
/// Your have a sandbox receipt. Purchases with sandbox receipts are not available in Beta or Production builds.
internal
static
let
message
=
L10n
.
tr
(
"Signup"
,
"failure.environment.message"
)
/// Invalid environment
internal
static
let
title
=
L10n
.
tr
(
"Signup"
,
"failure.environment.title"
)
}
internal
enum
Redeem
{
internal
enum
Claimed
{
/// Looks like this card has already been claimed by another account. You can try entering a different PIN.
...
...
PIALibrary/Sources/UI/iOS/ViewControllers/ConfirmVPNPlanViewController.swift
View file @
9125476a
...
...
@@ -161,9 +161,6 @@ public class ConfirmVPNPlanViewController: AutolayoutViewController, BrandableNa
if
let
error
=
error
{
var
message
=
error
.
localizedDescription
log
.
error
(
"Purchase failed (error:
\(
error
)
)"
)
if
error
as?
ClientError
==
ClientError
.
invalidEnvironment
{
message
=
L10n
.
Signup
.
Failure
.
Environment
.
message
}
Macros
.
displayImageNote
(
withImage
:
Asset
.
iconWarning
.
image
,
message
:
message
)
}
else
{
...
...
PIALibrary/Sources/UI/iOS/ViewControllers/RestoreSignupViewController.swift
View file @
9125476a
...
...
@@ -136,9 +136,6 @@ public class RestoreSignupViewController: AutolayoutViewController, BrandableNav
private
func
reportRestoreFailure
(
_
optionalError
:
Error
?)
{
var
message
=
optionalError
?
.
localizedDescription
??
L10n
.
Welcome
.
Iap
.
Error
.
title
if
let
error
=
optionalError
{
if
error
as?
ClientError
==
ClientError
.
invalidEnvironment
{
message
=
L10n
.
Signup
.
Failure
.
Environment
.
message
}
log
.
error
(
"Failed to restore payment receipt (error:
\(
error
)
)"
)
}
else
{
log
.
error
(
"Failed to restore payment receipt"
)
...
...
PIALibrary/Sources/UI/iOS/ViewControllers/SignupFailureViewController.swift
View file @
9125476a
...
...
@@ -35,10 +35,6 @@ public class SignupFailureViewController: AutolayoutViewController, BrandableNav
labelTitle
.
text
=
L10n
.
Signup
.
Failure
.
Redeem
.
Invalid
.
title
labelMessage
.
text
=
L10n
.
Signup
.
Failure
.
Redeem
.
Invalid
.
message
break
case
.
invalidEnvironment
:
labelTitle
.
text
=
L10n
.
Signup
.
Failure
.
Environment
.
title
labelMessage
.
text
=
L10n
.
Signup
.
Failure
.
Environment
.
message
break
case
.
redeemClaimed
:
title
=
L10n
.
Welcome
.
Redeem
.
title
imvPicture
.
image
=
Asset
.
imageRedeemClaimed
.
image
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment