This repository has been archived by the owner. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
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
a.ignatov
committed
Jul 3, 2023
1 parent
c776762
commit 4609b6e
Showing
14 changed files
with
231 additions
and
28 deletions.
There are no files selected for viewing
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
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
21 changes: 21 additions & 0 deletions
21
sdk/src/main/java/ru/cloudpayments/sdk/api/models/CardCryptogramPacket.kt
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,21 @@ | ||
package ru.cloudpayments.sdk.api.models | ||
|
||
import android.os.Parcelable | ||
import com.google.gson.annotations.SerializedName | ||
import kotlinx.android.parcel.Parcelize | ||
|
||
@Parcelize | ||
data class CardCryptogramPacket( | ||
@SerializedName("Type") var type: String? = "CloudCard", | ||
@SerializedName("BrowserInfoBase64") var browserInfoBase64: String? = "", | ||
@SerializedName("CardInfo") var cardInfo: CardInfo?, | ||
@SerializedName("KeyVersion") var keyVersion: String?, | ||
@SerializedName("Format") var format: Int? = 1, | ||
@SerializedName("Value") var value: String?) : Parcelable | ||
|
||
@Parcelize | ||
data class CardInfo( | ||
@SerializedName("FirstSixDigits") var firstSixDigits: String?, | ||
@SerializedName("LastFourDigits") var lastFourDigits: String?, | ||
@SerializedName("ExpDateYear") var expDateYear: String?, | ||
@SerializedName("ExpDateMonth") var expDateMonth: String?) :Parcelable |
8 changes: 8 additions & 0 deletions
8
sdk/src/main/java/ru/cloudpayments/sdk/api/models/CloudpaymentsPublicKeyResponse.kt
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,8 @@ | ||
package ru.cloudpayments.sdk.api.models | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class CloudpaymentsPublicKeyResponse( | ||
@SerializedName("Pem") val pem: String?, | ||
@SerializedName("Version") val version: Int?) | ||
|
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
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
13 changes: 13 additions & 0 deletions
13
sdk/src/main/java/ru/cloudpayments/sdk/util/HexPacketHelper.kt
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,13 @@ | ||
package ru.cloudpayments.sdk.util | ||
|
||
class HexPacketHelper { | ||
|
||
companion object { | ||
fun numberToEvenLengthString(number: Int): String { | ||
var numberStr = number.toString() | ||
|
||
return if (numberStr.length % 2 == 0) numberStr | ||
else "0$numberStr"; | ||
} | ||
} | ||
} |
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,50 @@ | ||
package ru.cloudpayments.sdk.util | ||
|
||
import android.app.Activity | ||
import android.content.Context | ||
import android.content.SharedPreferences | ||
|
||
class PublicKey private constructor() { | ||
|
||
companion object { | ||
private val publicKey = PublicKey() | ||
private lateinit var sharedPreferences: SharedPreferences | ||
|
||
private const val PEM = "pem" | ||
private const val VERSION = "version" | ||
|
||
fun getInstance(context: Context): PublicKey { | ||
if (!::sharedPreferences.isInitialized) { | ||
synchronized(PublicKey::class.java) { | ||
if (!::sharedPreferences.isInitialized) { | ||
sharedPreferences = context.getSharedPreferences(context.packageName, Activity.MODE_PRIVATE) | ||
} | ||
} | ||
} | ||
return publicKey | ||
} | ||
} | ||
|
||
val pem: String? | ||
get() = sharedPreferences.getString(PEM, "") | ||
|
||
fun savePem(pem: String) { | ||
sharedPreferences.edit() | ||
.putString(PEM, pem) | ||
.apply() | ||
} | ||
|
||
val version: Int? | ||
get() = sharedPreferences.getInt(VERSION, 0) | ||
|
||
fun saveVersion(version: Int) { | ||
sharedPreferences.edit() | ||
.putInt(VERSION, version) | ||
.apply() | ||
} | ||
|
||
fun clearAll() { | ||
sharedPreferences.edit().clear().apply() | ||
} | ||
|
||
} |
Oops, something went wrong.