Skip to content

Commit

Permalink
feat: Bumped sdks version to 3.2.0
Browse files Browse the repository at this point in the history
feat: Added to PaymentIntent charges, paymentMethod, amountDetails properties
  • Loading branch information
BreX900 committed Nov 19, 2023
1 parent 876c351 commit ca2bc20
Show file tree
Hide file tree
Showing 40 changed files with 845 additions and 81 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/stripe_terminal_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true



jobs:
integration:
runs-on: ubuntu-latest
Expand All @@ -23,7 +21,7 @@ jobs:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.13.x'
flutter-version: '3.16.x'

- name: Resolve dependencies
run: flutter pub get
Expand All @@ -47,9 +45,13 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: setup-cocoapods
uses: maxim-lobanov/setup-cocoapods@v1
with:
podfile-path: stripe_terminal/example/ios/Podfile.lock
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.13.x'
flutter-version: '3.16.x'

- name: Resolve dependencies
run: flutter pub get --enforce-lockfile
Expand Down
6 changes: 6 additions & 0 deletions stripe_terminal/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
- chore(android): Replaced `compileSdkVersion` with `compileSdk` and bumped version to `34`
- chore(android): Bumped tools gradle version to `8.1.3`
- feat: Bumped [Android](https://github.com/stripe/stripe-terminal-android/blob/master/CHANGELOG.md#320---2023-11-15)
and [IOS](https://github.com/stripe/stripe-terminal-ios/blob/master/CHANGELOG.md#320-2023-11-17) sdks versions to `3.2.0`
- feat: Added to `PaymentIntent` class `charges`, `paymentMethod`, `amountDetails` properties

## 3.1.2
- fix: Fixed incorrect Terminal instance access when unmounting the plugin from the engine

Expand Down
8 changes: 4 additions & 4 deletions stripe_terminal/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:8.0.2'
classpath 'com.android.tools.build:gradle:8.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'

android {
namespace "mek.stripeterminal"
compileSdkVersion 33
compileSdk 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down Expand Up @@ -66,6 +66,6 @@ android {

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
api "com.stripe:stripeterminal-localmobile:3.1.0"
api "com.stripe:stripeterminal-core:3.1.0"
api "com.stripe:stripeterminal-localmobile:3.2.0"
api "com.stripe:stripeterminal-core:3.2.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,16 @@ data class AddressApi(
}
}

data class AmountDetailsApi(
val tip: TipApi?,
) {
fun serialize(): List<Any?> {
return listOf(
tip?.serialize(),
)
}
}

enum class BatteryStatusApi {
CRITICAL, LOW, NOMINAL;
}
Expand All @@ -565,6 +575,26 @@ enum class CardBrandApi {
AMEX, DINERS_CLUB, DISCOVER, JCB, MASTER_CARD, UNION_PAY, VISA, INTERAC, EFTPOS_AU;
}

data class CardDetailsApi(
val brand: CardBrandApi?,
val country: String?,
val expMonth: Long,
val expYear: Long,
val funding: CardFundingTypeApi?,
val last4: String?,
) {
fun serialize(): List<Any?> {
return listOf(
brand?.ordinal,
country,
expMonth,
expYear,
funding?.ordinal,
last4,
)
}
}

enum class CardFundingTypeApi {
CREDIT, DEBIT, PREPAID;
}
Expand Down Expand Up @@ -679,6 +709,38 @@ data class CartLineItemApi(
}
}

data class ChargeApi(
val amount: Long,
val currency: String,
val status: ChargeStatusApi,
val paymentMethodDetails: PaymentMethodDetailsApi?,
val description: String,
val id: String,
val metadata: HashMap<String, String>,
val statementDescriptorSuffix: String?,
val calculatedStatementDescriptor: String?,
val authorizationCode: String?,
) {
fun serialize(): List<Any?> {
return listOf(
amount,
currency,
status.ordinal,
paymentMethodDetails?.serialize(),
description,
id,
hashMapOf(*metadata.map { (k, v) -> k to v }.toTypedArray()),
statementDescriptorSuffix,
calculatedStatementDescriptor,
authorizationCode,
)
}
}

enum class ChargeStatusApi {
SUCCEEDED, PENDING, FAILED;
}

enum class ConfirmationMethodApi {
AUTOMATIC, MANUAL;
}
Expand Down Expand Up @@ -830,7 +892,10 @@ data class PaymentIntentApi(
val captureMethod: CaptureMethodApi,
val currency: String,
val metadata: HashMap<String, String>,
val charges: List<ChargeApi>,
val paymentMethod: PaymentMethodApi?,
val paymentMethodId: String?,
val amountDetails: AmountDetailsApi?,
val amountTip: Double?,
val statementDescriptor: String?,
val statementDescriptorSuffix: String?,
Expand Down Expand Up @@ -860,7 +925,10 @@ data class PaymentIntentApi(
captureMethod.ordinal,
currency,
hashMapOf(*metadata.map { (k, v) -> k to v }.toTypedArray()),
charges.map { it.serialize()} ,
paymentMethod?.serialize(),
paymentMethodId,
amountDetails?.serialize(),
amountTip,
statementDescriptor,
statementDescriptorSuffix,
Expand Down Expand Up @@ -936,6 +1004,26 @@ enum class PaymentIntentUsageApi {
ON_SESSION, OFF_SESSION;
}

data class PaymentMethodApi(
val id: String,
val card: CardDetailsApi?,
val cardPresent: CardPresentDetailsApi?,
val interacPresent: CardPresentDetailsApi?,
val customerId: String?,
val metadata: HashMap<String, String>,
) {
fun serialize(): List<Any?> {
return listOf(
id,
card?.serialize(),
cardPresent?.serialize(),
interacPresent?.serialize(),
customerId,
hashMapOf(*metadata.map { (k, v) -> k to v }.toTypedArray()),
)
}
}

data class PaymentMethodDetailsApi(
val cardPresent: CardPresentDetailsApi?,
val interacPresent: CardPresentDetailsApi?,
Expand Down Expand Up @@ -1192,6 +1280,16 @@ enum class TerminalExceptionCodeApi {
UNKNOWN, READER_NOT_RECOVERED, PAYMENT_INTENT_NOT_RECOVERED, SETUP_INTENT_NOT_RECOVERED, CANCEL_FAILED, NOT_CONNECTED_TO_READER, ALREADY_CONNECTED_TO_READER, BLUETOOTH_DISABLED, BLUETOOTH_PERMISSION_DENIED, CONFIRM_INVALID_PAYMENT_INTENT, INVALID_CLIENT_SECRET, INVALID_READER_FOR_UPDATE, UNSUPPORTED_OPERATION, UNEXPECTED_OPERATION, UNSUPPORTED_SDK, FEATURE_NOT_AVAILABLE_WITH_CONNECTED_READER, USB_PERMISSION_DENIED, USB_DISCOVERY_TIMED_OUT, INVALID_PARAMETER, INVALID_REQUIRED_PARAMETER, INVALID_TIP_PARAMETER, LOCAL_MOBILE_UNSUPPORTED_DEVICE, LOCAL_MOBILE_UNSUPPORTED_OPERATING_SYSTEM_VERSION, LOCAL_MOBILE_DEVICE_TAMPERED, LOCAL_MOBILE_DEBUG_NOT_SUPPORTED, OFFLINE_MODE_UNSUPPORTED_OPERATING_SYSTEM_VERSION, CANCELED, LOCATION_SERVICES_DISABLED, BLUETOOTH_SCAN_TIMED_OUT, BLUETOOTH_LOW_ENERGY_UNSUPPORTED, READER_SOFTWARE_UPDATE_FAILED_BATTERY_LOW, READER_SOFTWARE_UPDATE_FAILED_INTERRUPTED, READER_SOFTWARE_UPDATE_FAILED_EXPIRED_UPDATE, BLUETOOTH_CONNECTION_FAILED_BATTERY_CRITICALLY_LOW, CARD_INSERT_NOT_READ, CARD_SWIPE_NOT_READ, CARD_READ_TIMED_OUT, CARD_REMOVED, CUSTOMER_CONSENT_REQUIRED, CARD_LEFT_IN_READER, FEATURE_NOT_ENABLED_ON_ACCOUNT, PASSCODE_NOT_ENABLED, COMMAND_NOT_ALLOWED_DURING_CALL, INVALID_AMOUNT, INVALID_CURRENCY, APPLE_BUILT_IN_READER_T_O_S_ACCEPTANCE_REQUIRESI_CLOUD_SIGN_IN, APPLE_BUILT_IN_READER_T_O_S_ACCEPTANCE_CANCELED, APPLE_BUILT_IN_READER_FAILED_TO_PREPARE, APPLE_BUILT_IN_READER_DEVICE_BANNED, APPLE_BUILT_IN_READER_T_O_S_NOT_YET_ACCEPTED, APPLE_BUILT_IN_READER_T_O_S_ACCEPTANCE_FAILED, APPLE_BUILT_IN_READER_MERCHANT_BLOCKED, APPLE_BUILT_IN_READER_INVALID_MERCHANT, READER_BUSY, INCOMPATIBLE_READER, READER_COMMUNICATION_ERROR, UNKNOWN_READER_IP_ADDRESS, INTERNET_CONNECT_TIME_OUT, CONNECT_FAILED_READER_IS_IN_USE, READER_NOT_ACCESSIBLE_IN_BACKGROUND, BLUETOOTH_ERROR, BLUETOOTH_CONNECT_TIMED_OUT, BLUETOOTH_DISCONNECTED, BLUETOOTH_PEER_REMOVED_PAIRING_INFORMATION, BLUETOOTH_ALREADY_PAIRED_WITH_ANOTHER_DEVICE, BLUETOOTH_RECONNECT_STARTED, USB_DISCONNECTED, USB_RECONNECT_STARTED, READER_CONNECTED_TO_ANOTHER_DEVICE, READER_SOFTWARE_UPDATE_FAILED, READER_SOFTWARE_UPDATE_FAILED_READER_ERROR, READER_SOFTWARE_UPDATE_FAILED_SERVER_ERROR, NFC_DISABLED, UNSUPPORTED_READER_VERSION, UNEXPECTED_SDK_ERROR, UNEXPECTED_READER_ERROR, ENCRYPTION_KEY_FAILURE, ENCRYPTION_KEY_STILL_INITIALIZING, DECLINED_BY_STRIPE_API, DECLINED_BY_READER, NOT_CONNECTED_TO_INTERNET, REQUEST_TIMED_OUT, STRIPE_API_CONNECTION_ERROR, STRIPE_API_ERROR, STRIPE_API_RESPONSE_DECODING_ERROR, INTERNAL_NETWORK_ERROR, CONNECTION_TOKEN_PROVIDER_ERROR, SESSION_EXPIRED, UNSUPPORTED_MOBILE_DEVICE_CONFIGURATION, COMMAND_NOT_ALLOWED, AMOUNT_EXCEEDS_MAX_OFFLINE_AMOUNT, OFFLINE_PAYMENTS_DATABASE_TOO_LARGE, READER_CONNECTION_NOT_AVAILABLE_OFFLINE, READER_CONNECTION_OFFLINE_LOCATION_MISMATCH, READER_CONNECTION_OFFLINE_NEEDS_UPDATE, LOCATION_CONNECTION_NOT_AVAILABLE_OFFLINE, NO_LAST_SEEN_ACCOUNT, INVALID_OFFLINE_CURRENCY, REFUND_FAILED, CARD_SWIPE_NOT_AVAILABLE, INTERAC_NOT_SUPPORTED_OFFLINE, ONLINE_PIN_NOT_SUPPORTED_OFFLINE, OFFLINE_AND_CARD_EXPIRED, OFFLINE_TRANSACTION_DECLINED, OFFLINE_COLLECT_AND_CONFIRM_MISMATCH, FORWARDING_TEST_MODE_PAYMENT_IN_LIVE_MODE, FORWARDING_LIVE_MODE_PAYMENT_IN_TEST_MODE, OFFLINE_PAYMENT_INTENT_NOT_FOUND, UPDATE_PAYMENT_INTENT_UNAVAILABLE_WHILE_OFFLINE, UPDATE_PAYMENT_INTENT_UNAVAILABLE_WHILE_OFFLINE_MODE_ENABLED, MISSING_EMV_DATA, CONNECTION_TOKEN_PROVIDER_ERROR_WHILE_FORWARDING, CONNECTION_TOKEN_PROVIDER_TIMED_OUT, ACCOUNT_ID_MISMATCH_WHILE_FORWARDING, OFFLINE_BEHAVIOR_FORCE_OFFLINE_WITH_FEATURE_DISABLED, NOT_CONNECTED_TO_INTERNET_AND_OFFLINE_BEHAVIOR_REQUIRE_ONLINE, TEST_CARD_IN_LIVE_MODE, COLLECT_INPUTS_APPLICATION_ERROR, COLLECT_INPUTS_TIMED_OUT, COLLECT_INPUTS_UNSUPPORTED;
}

data class TipApi(
val amount: Long?,
) {
fun serialize(): List<Any?> {
return listOf(
amount,
)
}
}

data class TippingConfigurationApi(
val eligibleAmount: Long,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import mek.stripeterminal.toHashMap
import com.stripe.stripeterminal.external.models.*
import com.stripe.stripeterminal.external.models.TerminalException.TerminalErrorCode
import mek.stripeterminal.createApiError
import mek.stripeterminal.mappings.toApi

fun TerminalException.toPlatformError(): PlatformError {
return toApi().toPlatformError()
Expand Down Expand Up @@ -317,6 +318,9 @@ fun PaymentIntent.toApi(): PaymentIntentApi {
},
currency = currency!!,
metadata = metadata?.toHashMap() ?: hashMapOf(),
charges = getCharges().map { it.toApi() },
paymentMethod = paymentMethod?.toApi(),
amountDetails = amountDetails?.toApi(),
paymentMethodId = paymentMethodId,
amountTip = amountTip?.toDouble(),
statementDescriptor = statementDescriptor,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package mek.stripeterminal.mappings

import com.stripe.stripeterminal.external.models.CardDetails
import mek.stripeterminal.api.CardDetailsApi
import mek.stripeterminal.api.cardBrandToApi
import mek.stripeterminal.api.fundingToApi

fun CardDetails.toApi(): CardDetailsApi {
return CardDetailsApi(
brand = cardBrandToApi(brand),
country = country,
expMonth = expMonth.toLong(),
expYear = expYear.toLong(),
funding = fundingToApi(funding),
last4 = last4,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package mek.stripeterminal.mappings

import com.stripe.stripeterminal.external.models.Charge
import mek.stripeterminal.api.ChargeApi
import mek.stripeterminal.api.ChargeStatusApi
import mek.stripeterminal.api.toApi
import mek.stripeterminal.toHashMap

fun Charge.toApi(): ChargeApi {
return ChargeApi(
amount = amount,
currency = currency!!,
status = when (status) {
"pending" -> ChargeStatusApi.PENDING
"failed" -> ChargeStatusApi.FAILED
"succeeded" -> ChargeStatusApi.SUCCEEDED
else -> throw Error("Unsupported $status")
},
paymentMethodDetails = paymentMethodDetails?.toApi(),
description = description!!,
id = id,
metadata = metadata?.toHashMap() ?: hashMapOf(),
statementDescriptorSuffix = statementDescriptorSuffix,
calculatedStatementDescriptor = calculatedStatementDescriptor,
authorizationCode = authorizationCode,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package mek.stripeterminal.mappings

import com.stripe.stripeterminal.external.models.AmountDetails
import mek.stripeterminal.api.AmountDetailsApi

fun AmountDetails.toApi(): AmountDetailsApi {
return AmountDetailsApi(
tip = tip?.toApi(),
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package mek.stripeterminal.mappings

import com.stripe.stripeterminal.external.models.PaymentMethod
import mek.stripeterminal.api.PaymentMethodApi
import mek.stripeterminal.api.toApi
import mek.stripeterminal.toHashMap

fun PaymentMethod.toApi(): PaymentMethodApi {
return PaymentMethodApi(
id = id,
card = cardDetails?.toApi(),
cardPresent = cardPresentDetails?.toApi(),
interacPresent = interacPresentDetails?.toApi(),
customerId = customer,
metadata = metadata?.toHashMap() ?: hashMapOf(),
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package mek.stripeterminal.mappings

import com.stripe.stripeterminal.external.models.Tip
import mek.stripeterminal.api.TipApi

fun Tip.toApi(): TipApi {
return TipApi(
amount = amount,
)
}
2 changes: 1 addition & 1 deletion stripe_terminal/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
namespace "mek.stripeterminal.example"
compileSdkVersion flutter.compileSdkVersion
compileSdk 34 // flutter.compileSdkVersion
ndkVersion flutter.ndkVersion

compileOptions {
Expand Down
2 changes: 1 addition & 1 deletion stripe_terminal/example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:8.0.2'
classpath 'com.android.tools.build:gradle:8.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
10 changes: 5 additions & 5 deletions stripe_terminal/example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
PODS:
- Flutter (1.0.0)
- mek_stripe_terminal (3.1.2):
- mek_stripe_terminal (3.2.0):
- Flutter
- StripeTerminal (~> 3.1.0)
- StripeTerminal (~> 3.2.0)
- permission_handler_apple (9.1.1):
- Flutter
- StripeTerminal (3.1.0)
- StripeTerminal (3.2.0)

DEPENDENCIES:
- Flutter (from `Flutter`)
Expand All @@ -26,9 +26,9 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
mek_stripe_terminal: 0bed67f1e3d67bb50ab3d3457de82693cbfbdb20
mek_stripe_terminal: 8055972d50bf0f261f0f82de4cbe64db3dd53edb
permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6
StripeTerminal: fa064cf68a7a3df7c2ee1b2e6d33c8866d1e6aef
StripeTerminal: cc78f3deca49d72ffa1285609ca2a125535ac7d1

PODFILE CHECKSUM: cf4dc61115723a2c178f9ac6bcd06534dfb5b047

Expand Down
Loading

0 comments on commit ca2bc20

Please sign in to comment.