Skip to content

Commit

Permalink
Merge branch 'master' into fixPostalCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
skyler-stripe authored Apr 15, 2022
2 parents 60ea9a4 + 6bfeeb3 commit 948c9d7
Show file tree
Hide file tree
Showing 15 changed files with 193 additions and 78 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# CHANGELOG
## x.x.x - xxxx-xx-xx

### Payments
### Payments (`com.stripe:stripe-android`)
* [ADDED] [4874](https://github.com/stripe/stripe-android/pull/4874) `us_bank_account` PaymentMethod is now available for ACH Direct Debit payments, including APIs to collect customer bank information (requires Connections SDK) and verify microdeposits.
* [FIXED] [4875](https://github.com/stripe/stripe-android/pull/4875) fix postal code callback not firing when enabled

### PaymentSheet
Expand Down
1 change: 1 addition & 0 deletions example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def getAccountId() {

dependencies {
implementation project(':payments')
implementation project(':connections')
implementation "androidx.appcompat:appcompat:$androidxAppcompatVersion"
implementation "androidx.recyclerview:recyclerview:$androidxRecyclerviewVersion"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$androidxLifecycleVersion"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ import com.stripe.example.R
import com.stripe.example.Settings
import com.stripe.example.databinding.ConnectBankAccountExampleActivityBinding

/**
* This example is currently work in progress. Do not use it as a reference.
*
* In order for this example to work, uncomment ConnectUSBankAccountActivity in LauncherActivity.kt
*/
class ConnectUSBankAccountActivity : StripeIntentActivity() {

private val viewBinding: ConnectBankAccountExampleActivityBinding by lazy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ class LauncherActivity : AppCompatActivity() {
activity.getString(R.string.compose_example),
ComposeExampleActivity::class.java
),
// Item(
// activity.getString(R.string.confirm_with_us_bank_account_entry_point),
// ConnectUSBankAccountActivity::class.java
// ),
// Item(
// activity.getString(R.string.manual_us_bank_account_example),
// ManualUSBankAccountPaymentMethodActivity::class.java
// ),
Item(
activity.getString(R.string.confirm_with_us_bank_account_entry_point),
ConnectUSBankAccountActivity::class.java
),
Item(
activity.getString(R.string.manual_us_bank_account_example),
ManualUSBankAccountPaymentMethodActivity::class.java
),
)

override fun onCreateViewHolder(viewGroup: ViewGroup, i: Int): ExamplesViewHolder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.lifecycle.lifecycleScope
import com.stripe.android.ApiResultCallback
import com.stripe.android.StripeApiBeta
import com.stripe.android.model.PaymentIntent
import com.stripe.android.model.PaymentMethod
import com.stripe.android.model.PaymentMethodCreateParams
Expand All @@ -38,15 +37,9 @@ import com.stripe.example.StripeFactory
import com.stripe.example.theme.DefaultExampleTheme
import kotlinx.coroutines.flow.MutableStateFlow

/**
* This example is currently work in progress. Do not use it as a reference.
*
* In order for this example to work uncomment ManualUSBankAccountPaymentMethodActivity
* in LauncherActivity.kt
*/
class ManualUSBankAccountPaymentMethodActivity : StripeIntentActivity() {
private val stripe by lazy {
StripeFactory(this, betas = setOf(StripeApiBeta.USBankAccount)).create()
StripeFactory(this).create()
}

private var paymentIntentSecret: String? = null
Expand Down
146 changes: 146 additions & 0 deletions payments-core/api/payments-core.api

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions payments-core/src/main/java/com/stripe/android/Stripe.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.app.Activity
import android.content.Context
import android.content.Intent
import androidx.activity.ComponentActivity
import androidx.annotation.RestrictTo
import androidx.annotation.Size
import androidx.annotation.UiThread
import androidx.annotation.WorkerThread
Expand Down Expand Up @@ -215,7 +214,6 @@ class Stripe internal constructor(
* @see <a href="https://pay.weixin.qq.com/index.php/public/wechatpay">WeChat Pay Documentation</a>
*
* WeChat Pay API is still in beta, create a [Stripe] instance with [StripeApiBeta.WeChatPayV1] to enable this API.
* US Bank Account API is still in beta, create a [Stripe] instance with [StripeApiBeta.USBankAccount] to enable this API.
*
* @param confirmPaymentIntentParams [ConfirmPaymentIntentParams] used to confirm the
* [PaymentIntent]
Expand Down Expand Up @@ -1661,7 +1659,8 @@ class Stripe internal constructor(
* sent to the bank account
* @param callback a [ApiResultCallback] to receive the result or error
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@UiThread
@JvmOverloads
fun verifyPaymentIntentWithMicrodeposits(
clientSecret: String,
firstAmount: Int,
Expand Down Expand Up @@ -1694,7 +1693,8 @@ class Stripe internal constructor(
* statement descriptor to the bank account
* @param callback a [ApiResultCallback] to receive the result or error
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@UiThread
@JvmOverloads
fun verifyPaymentIntentWithMicrodeposits(
clientSecret: String,
descriptorCode: String,
Expand Down Expand Up @@ -1727,7 +1727,8 @@ class Stripe internal constructor(
* sent to the bank account
* @param callback a [ApiResultCallback] to receive the result or error
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@UiThread
@JvmOverloads
fun verifySetupIntentWithMicrodeposits(
clientSecret: String,
firstAmount: Int,
Expand Down Expand Up @@ -1760,7 +1761,8 @@ class Stripe internal constructor(
* statement descriptor to the bank account
* @param callback a [ApiResultCallback] to receive the result or error
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@UiThread
@JvmOverloads
fun verifySetupIntentWithMicrodeposits(
clientSecret: String,
descriptorCode: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package com.stripe.android

import androidx.annotation.RestrictTo

/**
* Enums of beta headers allowed to be override when initializing [Stripe].
*/
enum class StripeApiBeta(val code: String) {
WeChatPayV1("wechat_pay_beta=v1"),
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) USBankAccount("us_bank_account_beta=v2");
WeChatPayV1("wechat_pay_beta=v1")
}
6 changes: 0 additions & 6 deletions payments-core/src/main/java/com/stripe/android/StripeKtx.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.stripe.android

import android.content.Intent
import androidx.annotation.RestrictTo
import androidx.annotation.Size
import com.stripe.android.core.exception.APIConnectionException
import com.stripe.android.core.exception.APIException
Expand Down Expand Up @@ -605,7 +604,6 @@ suspend fun Stripe.confirmSetupIntent(
* @see <a href="https://pay.weixin.qq.com/index.php/public/wechatpay">WeChat Pay Documentation</a>
*
* WeChat Pay API is still in beta, create a [Stripe] instance with [StripeApiBeta.WeChatPayV1] to enable this API.
* US Bank Account API is still in beta, create a [Stripe] instance with [StripeApiBeta.USBankAccount] to enable this API.
*
* @param confirmPaymentIntentParams [ConfirmPaymentIntentParams] used to confirm the
* [PaymentIntent]
Expand Down Expand Up @@ -817,7 +815,6 @@ internal inline fun <reified ApiObject : StripeModel> runApiRequest(
* @throws APIConnectionException failure to connect to Stripe's API
* @throws APIException any other type of problem (for instance, a temporary issue with Stripe's servers)
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@Throws(
AuthenticationException::class,
InvalidRequestException::class,
Expand Down Expand Up @@ -860,7 +857,6 @@ suspend fun Stripe.verifyPaymentIntentWithMicrodeposits(
* @throws APIConnectionException failure to connect to Stripe's API
* @throws APIException any other type of problem (for instance, a temporary issue with Stripe's servers)
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@Throws(
AuthenticationException::class,
InvalidRequestException::class,
Expand Down Expand Up @@ -903,7 +899,6 @@ suspend fun Stripe.verifyPaymentIntentWithMicrodeposits(
* @throws APIConnectionException failure to connect to Stripe's API
* @throws APIException any other type of problem (for instance, a temporary issue with Stripe's servers)
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@Throws(
AuthenticationException::class,
InvalidRequestException::class,
Expand Down Expand Up @@ -946,7 +941,6 @@ suspend fun Stripe.verifySetupIntentWithMicrodeposits(
* @throws APIConnectionException failure to connect to Stripe's API
* @throws APIException any other type of problem (for instance, a temporary issue with Stripe's servers)
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@Throws(
AuthenticationException::class,
InvalidRequestException::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,12 @@ constructor(

@JvmField val netbanking: Netbanking? = null,

internal val usBankAccount: USBankAccount? = null
/**
* If this is an `us_bank_account` PaymentMethod, this hash contains details about the bank account.
*
* [us_bank_account](https://stripe.com/docs/api/payment_methods/object#payment_method_object-us_bank_account)
*/
@JvmField val usBankAccount: USBankAccount? = null
) : StripeModel {

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) // For paymentsheet
Expand Down Expand Up @@ -362,7 +367,7 @@ constructor(
private var bacsDebit: BacsDebit? = null
private var sofort: Sofort? = null
private var netbanking: Netbanking? = null
internal var usBankAccount: USBankAccount? = null
private var usBankAccount: USBankAccount? = null
private var upi: Upi? = null

fun setId(id: String?): Builder = apply {
Expand Down Expand Up @@ -429,7 +434,7 @@ constructor(
this.netbanking = netbanking
}

internal fun setUSBankAccount(usBankAccount: USBankAccount?): Builder = apply {
fun setUSBankAccount(usBankAccount: USBankAccount?): Builder = apply {
this.usBankAccount = usBankAccount
}

Expand Down Expand Up @@ -864,7 +869,6 @@ constructor(
}

@Parcelize
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
data class USBankAccount internal constructor(
/**
* Account holder type
Expand Down Expand Up @@ -926,7 +930,6 @@ constructor(
override val type: Type get() = Type.USBankAccount

@Parcelize
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
enum class USBankAccountHolderType(val value: String) : StripeModel {
UNKNOWN("unknown"),
// Account belongs to an individual
Expand All @@ -936,7 +939,6 @@ constructor(
}

@Parcelize
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
enum class USBankAccountType(val value: String) : StripeModel {
UNKNOWN("unknown"),
// Bank account type is checking
Expand All @@ -946,7 +948,6 @@ constructor(
}

@Parcelize
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
data class USBankNetworks(
val preferred: String?,
val supported: List<String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,6 @@ data class PaymentMethodCreateParams internal constructor(
}

@Parcelize
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
data class USBankAccount(
internal var accountNumber: String,
internal var routingNumber: String,
Expand Down Expand Up @@ -612,7 +611,6 @@ data class PaymentMethodCreateParams internal constructor(

@JvmStatic
@JvmOverloads
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
fun create(
usBankAccount: USBankAccount,
billingDetails: PaymentMethod.BillingDetails? = null,
Expand Down Expand Up @@ -839,7 +837,8 @@ data class PaymentMethodCreateParams internal constructor(
)
}

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@JvmStatic
@JvmOverloads
fun createUSBankAccount(
billingDetails: PaymentMethod.BillingDetails? = null,
metadata: Map<String, String>? = null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.stripe.android.model

import android.os.Parcelable
import androidx.annotation.RestrictTo
import kotlinx.parcelize.Parcelize

sealed class PaymentMethodOptionsParams(
Expand Down Expand Up @@ -91,7 +90,6 @@ sealed class PaymentMethodOptionsParams(
}
}

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@Parcelize
data class USBankAccount(
var setupFutureUsage: ConfirmPaymentIntentParams.SetupFutureUsage? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ sealed interface StripeIntent : StripeModel {
AlipayRedirect("alipay_handle_redirect"),
BlikAuthorize("blik_authorize"),
WeChatPayRedirect("wechat_pay_redirect_to_android_app"),
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) VerifyWithMicrodeposits("verify_with_microdeposits");
VerifyWithMicrodeposits("verify_with_microdeposits");

override fun toString(): String {
return code
Expand Down Expand Up @@ -253,7 +253,6 @@ sealed interface StripeIntent : StripeModel {
@Parcelize
data class WeChatPayRedirect(val weChat: WeChat) : NextActionData()

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@Parcelize
data class VerifyWithMicrodeposits(
val arrivalDate: Long,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ internal class PaymentMethodEndToEndTest {
val paymentMethod =
Stripe(
context,
ApiKeyFixtures.US_BANK_ACCOUNT_PUBLISHABLE_KEY,
betas = setOf(StripeApiBeta.USBankAccount)
ApiKeyFixtures.US_BANK_ACCOUNT_PUBLISHABLE_KEY
).createPaymentMethodSynchronous(params)
assertThat(paymentMethod?.type).isEqualTo(PaymentMethod.Type.USBankAccount)
assertThat(paymentMethod?.usBankAccount).isEqualTo(
Expand All @@ -137,8 +136,7 @@ internal class PaymentMethodEndToEndTest {
val paymentMethod =
Stripe(
context,
ApiKeyFixtures.US_BANK_ACCOUNT_PUBLISHABLE_KEY,
betas = setOf(StripeApiBeta.USBankAccount)
ApiKeyFixtures.US_BANK_ACCOUNT_PUBLISHABLE_KEY
).createPaymentMethodSynchronous(params)
assertThat(paymentMethod?.type)
.isEqualTo(PaymentMethod.Type.USBankAccount)
Expand All @@ -154,8 +152,7 @@ internal class PaymentMethodEndToEndTest {
) {
Stripe(
context,
ApiKeyFixtures.US_BANK_ACCOUNT_PUBLISHABLE_KEY,
betas = setOf(StripeApiBeta.USBankAccount)
ApiKeyFixtures.US_BANK_ACCOUNT_PUBLISHABLE_KEY
).createPaymentMethodSynchronous(params)
}
assertThat(exception.message)
Expand Down
Loading

0 comments on commit 948c9d7

Please sign in to comment.