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
5 changes: 3 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ androidx-constraintlayout-main = '2.2.1'
androidx-core-main = '1.17.0'
androidx-core-splashscreen = '1.2.0'
androidx-credentials = '1.5.0'
androidx-datastore = '1.1.7'
androidx-datastore = '1.2.0'
androidx-exifinterface = "1.4.1"
androidx-fragment = '1.8.9'
androidx-hilt = '1.3.0'
Expand Down Expand Up @@ -96,7 +96,7 @@ sentry = '5.12.2'
squareup-javapoet = "1.13.0"
squareup-leakcanary = '2.14'
squareup-okhttp3 = "5.2.3"
stripe-terminal = '4.7.5'
stripe-terminal = '5.0.0'
swiperefreshlayout = "1.1.0"
tinder-statemachine = '0.2.0'
volley = "1.2.1"
Expand Down Expand Up @@ -261,6 +261,7 @@ squareup-okhttp3-tls = { module = "com.squareup.okhttp3:okhttp-tls", version.ref
squareup-okhttp3-urlconnection = { module = "com.squareup.okhttp3:okhttp-urlconnection", version.ref = "squareup-okhttp3" }
stripe-terminal-taptopay = { group = "com.stripe", name = "stripeterminal-taptopay", version.ref = "stripe-terminal" }
stripe-terminal-core = { group = "com.stripe", name = "stripeterminal-core", version.ref = "stripe-terminal" }
stripe-terminal-ktx = { group = "com.stripe", name = "stripeterminal-ktx", version.ref = "stripe-terminal" }
tinder-statemachine = { group = "com.tinder.statemachine", name = "statemachine", version.ref = "tinder-statemachine" }
volley = { module = "com.android.volley:volley", version.ref = "volley" }
wellsql = { module = "org.wordpress:wellsql", version.ref = "wellsql" }
Expand Down
1 change: 1 addition & 0 deletions libs/cardreader/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ android {
dependencies {
runtimeOnly(libs.stripe.terminal.taptopay)
implementation(libs.stripe.terminal.core)
implementation(libs.stripe.terminal.ktx)

// Coroutines
implementation(libs.kotlinx.coroutines.core)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.woocommerce.android.cardreader.internal.payments.actions

import com.stripe.stripeterminal.external.callable.Callback
import com.stripe.stripeterminal.external.models.RefundConfiguration
import com.stripe.stripeterminal.external.models.CollectRefundConfiguration
import com.stripe.stripeterminal.external.models.RefundParameters
import com.stripe.stripeterminal.external.models.TerminalException
import com.woocommerce.android.cardreader.internal.wrappers.TerminalWrapper
Expand All @@ -17,7 +17,7 @@ internal class CollectInteracRefundAction(private val terminal: TerminalWrapper)

fun collectRefund(
refundParameters: RefundParameters,
refundConfiguration: RefundConfiguration
refundConfiguration: CollectRefundConfiguration
): Flow<CollectInteracRefundStatus> {
return callbackFlow {
val cancelable = terminal.refundPayment(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import com.stripe.stripeterminal.external.callable.PaymentIntentCallback
import com.stripe.stripeterminal.external.callable.ReaderCallback
import com.stripe.stripeterminal.external.callable.RefundCallback
import com.stripe.stripeterminal.external.callable.TerminalListener
import com.stripe.stripeterminal.external.models.CollectRefundConfiguration
import com.stripe.stripeterminal.external.models.ConnectionConfiguration
import com.stripe.stripeterminal.external.models.DiscoveryConfiguration
import com.stripe.stripeterminal.external.models.PaymentIntent
import com.stripe.stripeterminal.external.models.PaymentIntentParameters
import com.stripe.stripeterminal.external.models.Reader
import com.stripe.stripeterminal.external.models.RefundConfiguration
import com.stripe.stripeterminal.external.models.RefundParameters
import com.stripe.stripeterminal.external.models.SimulateReaderUpdate
import com.stripe.stripeterminal.external.models.SimulatedCard
Expand All @@ -40,7 +40,7 @@ internal class TerminalWrapper {
logLevel: LogLevel,
tokenProvider: ConnectionTokenProvider,
listener: TerminalListener
) = Terminal.initTerminal(application, logLevel, tokenProvider, listener)
) = Terminal.init(application, logLevel, tokenProvider, listener, null)

@RequiresPermission(
anyOf = [
Expand Down Expand Up @@ -69,7 +69,9 @@ internal class TerminalWrapper {
fun disconnectReader(callback: Callback) =
Terminal.getInstance().disconnectReader(callback)

fun clearCachedCredentials() = Terminal.getInstance().clearCachedCredentials()
fun clearCachedCredentials() {
Terminal.getInstance().clearCachedCredentials()
}

fun createPaymentIntent(params: PaymentIntentParameters, callback: PaymentIntentCallback) =
Terminal.getInstance().createPaymentIntent(params, callback)
Expand All @@ -85,12 +87,14 @@ internal class TerminalWrapper {
fun cancelPayment(paymentIntent: PaymentIntent, callback: PaymentIntentCallback) =
Terminal.getInstance().cancelPaymentIntent(paymentIntent, callback)

@Suppress("DEPRECATION")
fun refundPayment(
refundParameters: RefundParameters,
refundConfiguration: RefundConfiguration,
refundConfiguration: CollectRefundConfiguration,
callback: Callback
) = Terminal.getInstance().collectRefundPaymentMethod(refundParameters, refundConfiguration, callback)

@Suppress("DEPRECATION")
fun processRefund(callback: RefundCallback) =
Terminal.getInstance().confirmRefund(callback)

Expand Down Expand Up @@ -121,12 +125,7 @@ internal class TerminalWrapper {

fun setupTapToPayUx(config: CardReaderManager.TapToPayUxConfig) {
val uxConfig = TapToPayUxConfiguration.Builder()
.tapZone(
TapToPayUxConfiguration.TapZone.Manual.Builder()
.indicator(TapToPayUxConfiguration.TapZoneIndicator.DEFAULT)
.position(TapToPayUxConfiguration.TapZonePosition.Default)
.build()
)
.tapZone(TapToPayUxConfiguration.TapZone.Default)
.colors(
TapToPayUxConfiguration.ColorScheme.Builder()
.primary(Color.Resource(config.primaryColor))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package com.woocommerce.android.cardreader.payments

import com.stripe.stripeterminal.external.models.RefundConfiguration
import com.stripe.stripeterminal.external.models.CollectRefundConfiguration
import com.stripe.stripeterminal.external.models.CustomerCancellation

data class RefundConfig(
val enableCustomerCancellation: Boolean
)

internal fun RefundConfig.toStripeRefundConfiguration(): RefundConfiguration {
return RefundConfiguration.Builder()
.setEnableCustomerCancellation(this.enableCustomerCancellation)
internal fun RefundConfig.toStripeRefundConfiguration(): CollectRefundConfiguration {
return CollectRefundConfiguration.Builder()
.setCustomerCancellation(
if (enableCustomerCancellation) {
CustomerCancellation.ENABLE_IF_AVAILABLE
} else {
CustomerCancellation.DISABLE_IF_AVAILABLE
}
)
.build()
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.woocommerce.android.cardreader.payments

import com.stripe.stripeterminal.external.models.RefundParameters
import com.stripe.stripeterminal.external.models.RefundParameters.Id
import com.woocommerce.android.cardreader.internal.payments.PaymentUtils
import java.math.BigDecimal

Expand All @@ -12,8 +11,8 @@ data class RefundParams(
)

internal fun RefundParams.toStripeRefundParameters(paymentUtils: PaymentUtils): RefundParameters {
return RefundParameters.Builder(
Id.Charge(id = this.chargeId),
return RefundParameters.ByChargeId(
id = this.chargeId,
amount = paymentUtils.convertToSmallestCurrencyUnit(this.amount, this.currency),
currency = this.currency
).build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import org.mockito.kotlin.verify
import org.mockito.kotlin.whenever
import java.math.BigDecimal

@Suppress("DoNotMockDataClass")
@ExperimentalCoroutinesApi
class CardReaderManagerImplTest : CardReaderBaseUnitTest() {
private lateinit var cardReaderManager: CardReaderManagerImpl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ private const val USD_CURRENCY = "USD"
private const val DUMMY_CHARGE_ID = "ch_abcdefgh"
private const val TIMEOUT = 1000L

@Suppress("DoNotMockDataClass")
@ExperimentalCoroutinesApi
@RunWith(MockitoJUnitRunner::class)
class InteracRefundManagerTest : CardReaderBaseUnitTest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ private const val DUMMY_CUSTOMER_NAME = "Tester"
private const val DUMMY_SITE_URL = "www.test.test/test"
private const val DUMMY_STORE_NAME = "Test store"

@Suppress("DoNotMockDataClass")
@ExperimentalCoroutinesApi
class PaymentManagerTest : CardReaderBaseUnitTest() {
private lateinit var manager: PaymentManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import java.math.BigDecimal
private const val NONE_USD_CURRENCY = "CZK"
private const val USD_CURRENCY = "USD"

@Suppress("DoNotMockDataClass", "DoNotMockSealedClass")
@ExperimentalCoroutinesApi
class PaymentUtilsTest : CardReaderBaseUnitTest() {
private lateinit var paymentUtils: PaymentUtils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import org.mockito.kotlin.mock
import org.mockito.kotlin.whenever
import java.math.BigDecimal

@Suppress("DoNotMockDataClass")
@RunWith(MockitoJUnitRunner::class)
class RefundErrorMapperTest {
private lateinit var mapper: RefundErrorMapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import org.mockito.kotlin.mock
import org.mockito.kotlin.verify
import org.mockito.kotlin.whenever

@Suppress("DoNotMockDataClass")
@ExperimentalCoroutinesApi
@RunWith(MockitoJUnitRunner::class)
class CollectInteracRefundActionTest : CardReaderBaseUnitTest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import org.mockito.kotlin.mock
import org.mockito.kotlin.verify
import org.mockito.kotlin.whenever

@Suppress("DoNotMockDataClass")
@ExperimentalCoroutinesApi
internal class CollectPaymentActionTest : CardReaderBaseUnitTest() {
private lateinit var action: CollectPaymentAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import org.mockito.kotlin.verify
import org.mockito.kotlin.whenever
import java.math.BigDecimal

@Suppress("DoNotMockDataClass")
@ExperimentalCoroutinesApi
internal class CreatePaymentActionTest : CardReaderBaseUnitTest() {
private lateinit var action: CreatePaymentAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import org.mockito.kotlin.any
import org.mockito.kotlin.mock
import org.mockito.kotlin.whenever

@Suppress("DoNotMockDataClass")
@ExperimentalCoroutinesApi
@RunWith(MockitoJUnitRunner::class)
class ProcessInteracRefundActionTest : CardReaderBaseUnitTest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import org.mockito.kotlin.any
import org.mockito.kotlin.mock
import org.mockito.kotlin.whenever

@Suppress("DoNotMockDataClass")
@ExperimentalCoroutinesApi
internal class ProcessPaymentActionTest : CardReaderBaseUnitTest() {
private lateinit var action: ProcessPaymentAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ protected void setupBottomButton(Button button) {
@NonNull
private Spanned formatTosText(int stringResId) {
final int primaryColorResId = ContextExtensionsKt.getColorResIdFromAttribute(getContext(),
com.google.android.material.R.attr.colorPrimary);
androidx.appcompat.R.attr.colorPrimary);
final String primaryColorHtml = HtmlUtils.colorResToHtmlColor(getContext(), primaryColorResId);
return Html.fromHtml(getString(stringResId, "<font color='" + primaryColorHtml + "'>", "</font>"));
}
Expand Down