melhorando pay
This commit is contained in:
parent
0b259035f9
commit
7c41fd4340
1
.idea/.name
generated
Normal file
1
.idea/.name
generated
Normal file
@ -0,0 +1 @@
|
||||
POS
|
||||
@ -100,10 +100,11 @@ class AditumSdkService(private val paymentApplication: PaymentApplication) {
|
||||
}
|
||||
|
||||
fun pay(
|
||||
amount: Int,
|
||||
installments: Int,
|
||||
merchantChargeId: String?,
|
||||
resolve: (Any) -> Unit = {},
|
||||
amount: Long,
|
||||
installments: Int = 0,
|
||||
paymentType: PaymentType,
|
||||
allowContactless: Boolean = true,
|
||||
resolve: (PaymentResponse) -> Unit = {},
|
||||
reject: (String, String?) -> Unit = { _, _ -> }
|
||||
) {
|
||||
coroutineScope.launch {
|
||||
@ -114,14 +115,13 @@ class AditumSdkService(private val paymentApplication: PaymentApplication) {
|
||||
}
|
||||
|
||||
val paymentRequest = PaymentRequest().apply {
|
||||
operationType = PayOperationType.Authorization
|
||||
paymentType = PaymentType.Credit
|
||||
this.amount = amount.toLong()
|
||||
this.merchantChargeId = merchantChargeId ?: UUID.randomUUID().toString()
|
||||
currency = 986
|
||||
allowContactless = true
|
||||
operationType = PayOperationType.Authorization
|
||||
this.paymentType = paymentType
|
||||
this.amount = amount
|
||||
this.allowContactless = allowContactless
|
||||
manualEntry = false
|
||||
installmentType = InstallmentType.Merchant
|
||||
installmentType = if (paymentType == PaymentType.Debit) InstallmentType.None else InstallmentType.Merchant
|
||||
installmentNumber = installments
|
||||
}
|
||||
|
||||
@ -129,7 +129,8 @@ class AditumSdkService(private val paymentApplication: PaymentApplication) {
|
||||
override fun onResponse(paymentResponse: PaymentResponse?) {
|
||||
if (paymentResponse != null) {
|
||||
val json = gson.toJson(paymentResponse)
|
||||
resolve(json)
|
||||
Log.e(TAG, "onResponse - $json")
|
||||
resolve(paymentResponse)
|
||||
} else {
|
||||
Log.e(TAG, "onResponse - paymentResponse is null")
|
||||
reject(AditumError.PAYMENT_RESPONSE_NULL, AditumError.PAYMENT_RESPONSE_NULL_MESSAGE)
|
||||
@ -206,6 +207,18 @@ class AditumSdkService(private val paymentApplication: PaymentApplication) {
|
||||
}
|
||||
}
|
||||
|
||||
fun aboutOperation(resolve: (Boolean) -> Unit = {}, reject: (String, String?) -> Unit = { _, _ -> }) {
|
||||
coroutineScope.launch {
|
||||
if (!paymentApplication.ensureServiceConnected()) {
|
||||
reject(AditumError.SERVICE_NOT_AVAILABLE, AditumError.SERVICE_NOT_AVAILABLE_MESSAGE)
|
||||
return@launch
|
||||
}
|
||||
|
||||
paymentApplication.communicationService?.abortOperation()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fun deactivate(resolve: (Boolean) -> Unit = {}, reject: (String, String?) -> Unit = { _, _ -> }) {
|
||||
coroutineScope.launch {
|
||||
try {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user