-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed38f54
commit fc3f6dd
Showing
16 changed files
with
271 additions
and
113 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package ua.liqpay | ||
|
||
/** | ||
* Liqpay checkout end point. | ||
*/ | ||
internal const val LIQPAY_URL_CHECKOUT = "https://www.liqpay.ua/api/3/checkout" | ||
|
||
/** | ||
* Privat24 application package name. | ||
*/ | ||
internal const val PRIVAT24_APP_PACKAGE = "ua.privatbank.ap24" | ||
|
||
/** | ||
* Privat24 application deeplink path. | ||
*/ | ||
internal const val PRIVAT24_APP_URI_SCHEME = "privat24:" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
package ua.liqpay.request | ||
|
||
enum class ErrorCode { | ||
IO, | ||
FAIL_INTERNET_CONNECTION, | ||
NEED_NON_UI_THREAD, | ||
CHECKOUT_CANCELED | ||
CHECKOUT_CANCELED, | ||
OTHER | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package ua.liqpay.utils | ||
|
||
import android.content.ActivityNotFoundException | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.content.pm.PackageManager | ||
import android.net.Uri | ||
|
||
|
||
|
||
fun isInstallApp(context: Context, uri: String): Boolean { | ||
val pm = context.packageManager | ||
try { | ||
pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES) | ||
return true | ||
} catch (e: PackageManager.NameNotFoundException) { | ||
} | ||
return false | ||
} | ||
|
||
|
||
fun handleAppLink(context: Context, url: String, app: String) { | ||
if (isInstallApp(context, app)) { | ||
context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url))) | ||
return | ||
} | ||
try { | ||
context.startActivity( | ||
Intent( | ||
Intent.ACTION_VIEW, | ||
Uri.parse("market://details?id=$app") | ||
) | ||
) | ||
} catch (unused: ActivityNotFoundException) { | ||
context.startActivity( | ||
Intent( | ||
Intent.ACTION_VIEW, | ||
Uri.parse("https://play.google.com/store/apps/details?id=$app") | ||
) | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package ua.liqpay.utils | ||
|
||
import org.json.JSONException | ||
import org.json.JSONObject | ||
|
||
/** | ||
* Merge json objects. | ||
* | ||
* @param object1 [JSONObject] | ||
* | ||
* @param object2 [JSONObject] | ||
*/ | ||
fun merge(object1: JSONObject, object2: JSONObject): JSONObject { | ||
val iter = object2.keys() as Iterator<String> | ||
while (iter.hasNext()) { | ||
val key = iter.next() | ||
try { | ||
object1.put(key, object2[key]) | ||
} catch (e: JSONException) { | ||
e.printStackTrace() | ||
} | ||
} | ||
return object1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.