Skip to content

Commit

Permalink
Add idempotency key to remaining API POST methods (#1950)
Browse files Browse the repository at this point in the history
This was already done for Token API methods.

ANDROID-454
  • Loading branch information
mshafrir-stripe authored Dec 20, 2019
1 parent b716a2f commit 096657f
Show file tree
Hide file tree
Showing 5 changed files with 212 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CreateSepaDebitActivity : AppCompatActivity() {
.setEmail(CUSTOMER_EMAIl)
.build()
),
object : ApiResultCallback<PaymentMethod> {
callback = object : ApiResultCallback<PaymentMethod> {
override fun onSuccess(result: PaymentMethod) {
progressBar.visibility = View.INVISIBLE
Toast.makeText(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,9 @@ class PayWithGoogleActivity : AppCompatActivity() {
val paymentMethodCreateParams =
PaymentMethodCreateParams.createFromGooglePay(paymentDataJson)

stripe.createPaymentMethod(paymentMethodCreateParams,
object : ApiResultCallback<PaymentMethod> {
stripe.createPaymentMethod(
paymentMethodCreateParams,
callback = object : ApiResultCallback<PaymentMethod> {
override fun onSuccess(result: PaymentMethod) {
showSnackbar("Created PaymentMethod ${result.id}")
}
Expand All @@ -160,7 +161,8 @@ class PayWithGoogleActivity : AppCompatActivity() {
Log.e("StripeExample", "Exception while creating PaymentMethod", e)
showSnackbar("Exception while creating PaymentMethod")
}
})
}
)
}

private fun showSnackbar(message: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ internal class SourceViewModel(
internal val createdSourceException: MutableLiveData<Exception> = MutableLiveData()

internal fun createSource(sourceParams: SourceParams) {
stripe.createSource(sourceParams, object : ApiResultCallback<Source> {
override fun onSuccess(result: Source) {
createdSource.value = result
}
stripe.createSource(
sourceParams = sourceParams,
callback = object : ApiResultCallback<Source> {
override fun onSuccess(result: Source) {
createdSource.value = result
}

override fun onError(e: Exception) {
createdSourceException.value = e
}
})
override fun onError(e: Exception) {
createdSourceException.value = e
}
})
}
}
Loading

0 comments on commit 096657f

Please sign in to comment.