Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,18 @@ class SamsungPayFragment : Fragment() {
SamsungPayManager.initiate(
requireActivity(),
paymentRequest,
onCanceled = {
MoyasarAppContainer.viewModel.notifyPaymentResult(PaymentResult.Canceled)
},
authorizePayment = { token, orderNumber ->
if (token != null && orderNumber != null) {
progressBar.show()
SamsungPayManager.authorizePayment(token, orderNumber)
} else {
MoyasarAppContainer.viewModel.notifyPaymentResult(
PaymentResult.Failed(Throwable("Something went wrong."))
)
}
else MoyasarAppContainer.viewModel.notifyPaymentResult(PaymentResult.Failed(
Throwable("Something went wrong.")))
}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ object SamsungPayManager {
fun initiate(
context: Context,
paymentRequest: PaymentRequest,
onCanceled: () -> Unit = {},
authorizePayment: (String?, String?) -> Unit
) {
val samsungPayConfig = paymentRequest.samsungPay
Expand All @@ -76,6 +77,7 @@ object SamsungPayManager {
paymentRequest,
context,
samsungPay,
onCanceled,
authorizePayment
)
}
Expand Down Expand Up @@ -173,6 +175,7 @@ object SamsungPayManager {
paymentRequest: PaymentRequest,
context: Context,
samsungPay: SamsungPay,
onCanceled: () -> Unit,
authorizePayment: (String?, String?) -> Unit
) {
val customSheetPaymentInfo = makeCustomSheetPaymentInfo(paymentRequest)
Expand Down Expand Up @@ -224,6 +227,11 @@ object SamsungPayManager {
}

override fun onFailure(errorCode: Int, errorData: Bundle?) {
if (errorCode == ERROR_USER_CANCELED) {
MoyasarLogger.log("MoyasarSDK", "Samsung Pay canceled by user")
onCanceled()
return
}
handleOnFail(errorData ?: Bundle(), samsungPay, context, errorCode)
authorizePayment(null, null)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.moyasar.android.sdk.core.extensions.default
import com.moyasar.android.sdk.core.data.response.PaymentResponse
import com.moyasar.android.sdk.creditcard.data.models.CreditCardNetwork
import com.moyasar.android.sdk.creditcard.data.models.request.PaymentRequest
import com.moyasar.android.sdk.creditcard.data.models.request.PaymentSplit
import com.moyasar.android.sdk.stcpay.presentation.view.fragments.EnterMobileNumberFragment
import com.moyasar.android.sdk.creditcard.presentation.view.fragments.PaymentFragment
import com.moyasar.android.sdk.samsungpay.data.SamsungPayConfig
Expand Down