Open YiffyToys opened 2 years ago
This would also be useful without Compose, as the currently used mechanism is deprecated and ActivityResultsContract
would allow for greater flexibility when processing the payment results.
Half a year has passed and nothing happened. This issue hasn't even been triaged yet.
I wonder if something like this may work until SumUp gets their act together:
class SumUpPaymentForResult : ActivityResultContract<SumUpPayment, ActivityResult>() {
override fun createIntent(context: Context, input: SumUpPayment): Intent {
class DummyActivity: Activity() {
var capturedIntent: Intent? = null
override fun startActivityForResult(intent: Intent?, requestCode: Int) {
capturedIntent = intent
}
override fun getPackageName(): String {
return "myapp.package"
}
}
val dummy = DummyActivity()
SumUpAPI.checkout(dummy, input, 1)
return dummy.capturedIntent!!
}
override fun parseResult(
resultCode: Int,
intent: Intent?
): ActivityResult = ActivityResult(resultCode, intent)
}
The SDK should allow to use the current ActivityResultContracts in addition of the deprecated mechanism in Activity. This is required to use the SDK in Jetpack Compose applications where rememberLauncherForActivityResult() is the prefered way to start other activities when interacting with UI elements and handle the results.