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 28, 2023
1 parent
4609b6e
commit c77d973
Showing
36 changed files
with
697 additions
and
54 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
17 changes: 17 additions & 0 deletions
17
...src/main/java/ru/cloudpayments/sdk/api/models/CloudpaymentsGetTinkoffPayQrLinkResponse.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,17 @@ | ||
package ru.cloudpayments.sdk.api.models | ||
|
||
import com.google.gson.annotations.SerializedName | ||
import io.reactivex.Observable | ||
|
||
data class CloudpaymentsGetTinkoffPayQrLinkResponse( | ||
@SerializedName("Success") val success: Boolean?, | ||
@SerializedName("Message") val message: String?, | ||
@SerializedName("Model") val transaction: CloudpaymentsTinkoffPayQrLinkTransaction?) { | ||
fun handleError(): Observable<CloudpaymentsGetTinkoffPayQrLinkResponse> { | ||
return if (success == true ) { | ||
Observable.just(this) | ||
} else { | ||
Observable.error(CloudpaymentsTransactionError(message ?: "")) | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...c/main/java/ru/cloudpayments/sdk/api/models/CloudpaymentsMerchantConfigurationResponse.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,23 @@ | ||
package ru.cloudpayments.sdk.api.models | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class CloudpaymentsMerchantConfigurationResponse( | ||
@SerializedName("Success") val success: Boolean?, | ||
@SerializedName("Message") val message: String?, | ||
@SerializedName("Model") val model: MerchantConfiguration? | ||
) | ||
|
||
data class MerchantConfiguration( | ||
@SerializedName("ExternalPaymentMethods") val externalPaymentMethods: ArrayList<ExternalPaymentMethods>?, | ||
@SerializedName("Features") val features: Features? | ||
) | ||
|
||
data class ExternalPaymentMethods( | ||
@SerializedName("Type") val type: Int?, | ||
@SerializedName("Enabled") val enabled: Boolean? | ||
) | ||
|
||
data class Features( | ||
@SerializedName("IsSaveCard") val isSaveCard: Int? | ||
) |
8 changes: 8 additions & 0 deletions
8
...src/main/java/ru/cloudpayments/sdk/api/models/CloudpaymentsTinkoffPayQrLinkTransaction.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 CloudpaymentsTinkoffPayQrLinkTransaction( | ||
@SerializedName("TransactionId") val transactionId: Int?, | ||
@SerializedName("ProviderQrId") val providerQrId: String?, | ||
@SerializedName("QrUrl") val qrUrl: String?) |
10 changes: 10 additions & 0 deletions
10
sdk/src/main/java/ru/cloudpayments/sdk/api/models/QrLinkStatusWait.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,10 @@ | ||
package ru.cloudpayments.sdk.api.models | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class QrLinkStatusWait( | ||
@SerializedName("TransactionId") val transactionId: Int?, | ||
@SerializedName("Status") val status: String?, | ||
@SerializedName("StatusCode") val statusCode: String?) | ||
|
||
|
6 changes: 6 additions & 0 deletions
6
sdk/src/main/java/ru/cloudpayments/sdk/api/models/QrLinkStatusWaitBody.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,6 @@ | ||
package ru.cloudpayments.sdk.api.models | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class QrLinkStatusWaitBody( | ||
@SerializedName("TransactionId") val transactionId: Int) |
17 changes: 17 additions & 0 deletions
17
sdk/src/main/java/ru/cloudpayments/sdk/api/models/QrLinkStatusWaitResponse.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,17 @@ | ||
package ru.cloudpayments.sdk.api.models | ||
|
||
import com.google.gson.annotations.SerializedName | ||
import io.reactivex.Observable | ||
|
||
data class QrLinkStatusWaitResponse( | ||
@SerializedName("Success") val success: Boolean?, | ||
@SerializedName("Message") val message: String?, | ||
@SerializedName("Model") val transaction: QrLinkStatusWait?) { | ||
fun handleError(): Observable<QrLinkStatusWaitResponse> { | ||
return if (success == true ){ | ||
Observable.just(this) | ||
} else { | ||
Observable.error(CloudpaymentsTransactionError(message ?: "")) | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
sdk/src/main/java/ru/cloudpayments/sdk/api/models/TinkoffPayQrLinkBody.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,19 @@ | ||
package ru.cloudpayments.sdk.api.models | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class TinkoffPayQrLinkBody( | ||
@SerializedName("Webview") val webView: Boolean = true, // Мобильное устройство | ||
@SerializedName("Device") val device: String = "MobileApp", // Вызов из мобильных приложений | ||
@SerializedName("Amount") val amount: String, // Сумма | ||
@SerializedName("Currency") val currency: String, // Валюта | ||
@SerializedName("Description") val description: String? = null, // Описание платежа | ||
@SerializedName("AccountId") val accountId: String? = null, // Identity плательщика в системе мерчанта | ||
@SerializedName("Email") val email: String? = null, // E-mail плательщика | ||
@SerializedName("JsonData") val jsonData: String? = null, // Произвольные данные мерчанта в формате JSON | ||
@SerializedName("InvoiceId") val invoiceId: String? = null, // id заказа в системе мерчанта | ||
@SerializedName("Scheme") val scheme: String, // charge - одностадийная оплата, auth - двухстадийная оплата (Scheme":"0") | ||
@SerializedName("TtlMinutes") val ttlMinutes: Int = 30, // Время жизни Qr | ||
@SerializedName("SuccessRedirectUrl") val successRedirectUrl: String = "https://cp.ru", // Url успешной оплаты (мерчанта) | ||
@SerializedName("FailRedirectUrl") val failRedirectUrl: String = "https://cp.ru", // Url неуспешной оплаты (мерчанта) | ||
@SerializedName("SaveCard") var saveCard: Boolean? = null) |
58 changes: 50 additions & 8 deletions
58
sdk/src/main/java/ru/cloudpayments/sdk/configuration/PaymentData.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 |
---|---|---|
@@ -1,15 +1,57 @@ | ||
package ru.cloudpayments.sdk.configuration | ||
|
||
import android.os.Parcelable | ||
import android.util.Log | ||
import com.google.gson.GsonBuilder | ||
import com.google.gson.JsonSyntaxException | ||
import com.google.gson.annotations.SerializedName | ||
import kotlinx.android.parcel.Parcelize | ||
import ru.cloudpayments.sdk.Constants | ||
import ru.cloudpayments.sdk.api.models.PaymentDataPayer | ||
import ru.cloudpayments.sdk.util.TAG | ||
|
||
@Parcelize | ||
class PaymentData(val amount: String, | ||
var currency: String = "RUB", | ||
val invoiceId: String? = null, | ||
val description: String? = null, | ||
val accountId: String? = null, | ||
var email: String? = null, | ||
val payer: PaymentDataPayer? = null, | ||
val jsonData: String? = null): Parcelable | ||
class PaymentData( | ||
val amount: String, | ||
var currency: String = "RUB", | ||
val invoiceId: String? = null, | ||
val description: String? = null, | ||
val accountId: String? = null, | ||
var email: String? = null, | ||
val payer: PaymentDataPayer? = null, | ||
val jsonData: String? = null | ||
) : Parcelable { | ||
|
||
fun jsonDataHasRecurrent(): Boolean { | ||
|
||
if (!jsonData.isNullOrEmpty()) { | ||
val gson = GsonBuilder() | ||
.setLenient() | ||
.create() | ||
|
||
try { | ||
val cpJsonData = gson.fromJson(jsonData, CpJsonData::class.java) | ||
cpJsonData.cloudPayments?.recurrent?.interval?.let { | ||
return true | ||
} | ||
} catch (e: JsonSyntaxException) { | ||
Log.e(TAG, "JsonData syntax error") | ||
} | ||
} | ||
return false | ||
} | ||
} | ||
|
||
data class CpJsonData( | ||
@SerializedName("cloudPayments") val cloudPayments: CloudPaymentsJsonData? | ||
) | ||
|
||
data class CloudPaymentsJsonData( | ||
@SerializedName("recurrent") val recurrent: CloudPaymentsRecurrentJsonData? | ||
) | ||
|
||
data class CloudPaymentsRecurrentJsonData( | ||
@SerializedName("interval") val interval: String?, | ||
@SerializedName("period") val period: String?, | ||
@SerializedName("amount") val amount: String? | ||
) |
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,5 @@ | ||
package ru.cloudpayments.sdk.models | ||
|
||
data class PayParams( | ||
var saveCard: Boolean? = null | ||
) |
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.