Skip to content

Commit

Permalink
Merge branch 'main' into feature-deposit-return-voucher
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabtron authored Jan 7, 2025
2 parents f922819 + f2b6180 commit 71362dc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ All notable changes to this project will be documented in this file.
* ui/core: Remove everything related to the old deposit return voucher feature
### Fixed

## [0.80.3]
### Added
* ui: Add listener to `SelfScanningFragment` to react to camera permission changes
* core: Receive origin type from `PaymentMethodDesricptor` in case it is not set by default

## [0.80.2]
### Fixed
* ui: Add missing focus to the product search field after opening the `ProductSearchView`
Expand Down
20 changes: 16 additions & 4 deletions core/src/main/java/io/snabble/sdk/checkout/DefaultCheckoutApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ class DefaultCheckoutApi(private val project: Project,
}
}

val originType = paymentCredentials?.type?.originType
?: getOriginTypeFromPaymentMethodDescriptor(paymentMethod = paymentMethod)

val checkoutProcessRequest = CheckoutProcessRequest(
paymentMethod = paymentMethod,
signedCheckoutInfo = signedCheckoutInfo,
Expand All @@ -215,22 +218,24 @@ class DefaultCheckoutApi(private val project: Project,
paymentInformation = when (paymentCredentials?.type) {
PaymentCredentials.Type.EXTERNAL_BILLING -> {
PaymentInformation(
originType = paymentCredentials.type?.originType,
originType = originType,
encryptedOrigin = paymentCredentials.encryptedData,
subject = paymentCredentials.additionalData["subject"]
)
}

PaymentCredentials.Type.CREDIT_CARD_PSD2 -> {
PaymentInformation(
originType = paymentCredentials.type?.originType,
originType = originType,
encryptedOrigin = paymentCredentials.encryptedData,
validUntil = SimpleDateFormat("yyyy/MM/dd").format(Date(paymentCredentials.validTo)),
cardNumber = paymentCredentials.obfuscatedId,
)
}

PaymentCredentials.Type.GIROPAY -> {
PaymentInformation(
originType = paymentCredentials.type?.originType,
originType = originType,
encryptedOrigin = paymentCredentials.encryptedData,
deviceID = paymentCredentials.additionalData["deviceID"],
deviceName = paymentCredentials.additionalData["deviceName"],
Expand All @@ -241,7 +246,7 @@ class DefaultCheckoutApi(private val project: Project,
null -> null
else -> {
PaymentInformation(
originType = paymentCredentials.type?.originType,
originType = originType,
encryptedOrigin = paymentCredentials.encryptedData
)
}
Expand Down Expand Up @@ -318,7 +323,14 @@ class DefaultCheckoutApi(private val project: Project,
})
}

private fun getOriginTypeFromPaymentMethodDescriptor(paymentMethod: PaymentMethod): String? =
project.paymentMethodDescriptors
.firstOrNull { it.paymentMethod == paymentMethod }
?.acceptedOriginTypes
?.get(0)

companion object {

private val JSON: MediaType = "application/json".toMediaType()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ open class SelfScanningFragment : BaseFragment(), MenuProvider {
createSelfScanningView()
requireView().announceForAccessibility(getString(R.string.Snabble_Scanner_Accessibility_eventBackInScanner))
explainScanner()
onCameraPermissionGrantedListener?.invoke()
} else {
canAskAgain = ActivityCompat.shouldShowRequestPermissionRationale(
requireActivity(),
Expand All @@ -67,6 +68,11 @@ open class SelfScanningFragment : BaseFragment(), MenuProvider {
}
}

/**
* Add a listener to get notified if the camera permission has been granted
*/
var onCameraPermissionGrantedListener: (() -> Unit)? = null

override fun onCreateActualView(
inflater: LayoutInflater,
container: ViewGroup?,
Expand Down

0 comments on commit 71362dc

Please sign in to comment.