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(
|
fun pay(
|
||||||
amount: Int,
|
amount: Long,
|
||||||
installments: Int,
|
installments: Int = 0,
|
||||||
merchantChargeId: String?,
|
paymentType: PaymentType,
|
||||||
resolve: (Any) -> Unit = {},
|
allowContactless: Boolean = true,
|
||||||
|
resolve: (PaymentResponse) -> Unit = {},
|
||||||
reject: (String, String?) -> Unit = { _, _ -> }
|
reject: (String, String?) -> Unit = { _, _ -> }
|
||||||
) {
|
) {
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
@ -114,14 +115,13 @@ class AditumSdkService(private val paymentApplication: PaymentApplication) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val paymentRequest = PaymentRequest().apply {
|
val paymentRequest = PaymentRequest().apply {
|
||||||
operationType = PayOperationType.Authorization
|
|
||||||
paymentType = PaymentType.Credit
|
|
||||||
this.amount = amount.toLong()
|
|
||||||
this.merchantChargeId = merchantChargeId ?: UUID.randomUUID().toString()
|
|
||||||
currency = 986
|
currency = 986
|
||||||
allowContactless = true
|
operationType = PayOperationType.Authorization
|
||||||
|
this.paymentType = paymentType
|
||||||
|
this.amount = amount
|
||||||
|
this.allowContactless = allowContactless
|
||||||
manualEntry = false
|
manualEntry = false
|
||||||
installmentType = InstallmentType.Merchant
|
installmentType = if (paymentType == PaymentType.Debit) InstallmentType.None else InstallmentType.Merchant
|
||||||
installmentNumber = installments
|
installmentNumber = installments
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,7 +129,8 @@ class AditumSdkService(private val paymentApplication: PaymentApplication) {
|
|||||||
override fun onResponse(paymentResponse: PaymentResponse?) {
|
override fun onResponse(paymentResponse: PaymentResponse?) {
|
||||||
if (paymentResponse != null) {
|
if (paymentResponse != null) {
|
||||||
val json = gson.toJson(paymentResponse)
|
val json = gson.toJson(paymentResponse)
|
||||||
resolve(json)
|
Log.e(TAG, "onResponse - $json")
|
||||||
|
resolve(paymentResponse)
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "onResponse - paymentResponse is null")
|
Log.e(TAG, "onResponse - paymentResponse is null")
|
||||||
reject(AditumError.PAYMENT_RESPONSE_NULL, AditumError.PAYMENT_RESPONSE_NULL_MESSAGE)
|
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 = { _, _ -> }) {
|
fun deactivate(resolve: (Boolean) -> Unit = {}, reject: (String, String?) -> Unit = { _, _ -> }) {
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user