Skip to content

[Coroutines] - Convert SEPADirectDebitApi to suspend functions#1535

Merged
noguier merged 3 commits intomainfrom
convert-sepadirectdebitapi-coroutines
Feb 25, 2026
Merged

[Coroutines] - Convert SEPADirectDebitApi to suspend functions#1535
noguier merged 3 commits intomainfrom
convert-sepadirectdebitapi-coroutines

Conversation

@noguier
Copy link
Copy Markdown
Contributor

@noguier noguier commented Feb 23, 2026

Summary of changes

  • converted SEPADirectDebitApi.createMandate and SEPADirectDebitApi.tokenize to suspend functions
  • wrap all the updated function calls into coroutinesScope.launch
  • update affected tests

Checklist

  • Added a changelog entry
  • Relevant test coverage
  • Tested and confirmed payment flows affected by this change are functioning as expected

Authors

@noguier

@noguier noguier requested a review from a team as a code owner February 23, 2026 17:48
@github-actions
Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities found.

Scanned Files

None

Comment on lines -53 to +31
mandateType: String,
callback: SEPADirectDebitInternalTokenizeCallback
) {
try {
val jsonObject =
buildTokenizeRequest(ibanLastFour, customerId, bankReferenceToken, mandateType)
val url = "/v1/payment_methods/sepa_debit_accounts"
coroutineScope.launch {
try {
val responseBody = braintreeClient.sendPOST(
url,
jsonObject.toString()
)
try {
val nonce = parseTokenizeResponse(responseBody)
callback.onResult(nonce, null)
} catch (e: JSONException) {
callback.onResult(null, e)
}
} catch (httpError: IOException) {
callback.onResult(null, httpError)
}
}
} catch (e: JSONException) {
callback.onResult(null, e)
}
mandateType: String
): SEPADirectDebitNonce {
val jsonObject = buildTokenizeRequest(ibanLastFour, customerId, bankReferenceToken, mandateType)
val url = "/v1/payment_methods/sepa_debit_accounts"
val responseBody = braintreeClient.sendPOST(url, jsonObject.toString())
return parseTokenizeResponse(responseBody)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love to see this clean up here. A lot less code to manage 🎉

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much more readable too!

@noguier noguier merged commit f7012f4 into main Feb 25, 2026
6 of 12 checks passed
@noguier noguier deleted the convert-sepadirectdebitapi-coroutines branch February 25, 2026 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants