Skip to content

Commit

Permalink
Merge pull request #539 from gini/fix(merchant-sdk)-release-candidate…
Browse files Browse the repository at this point in the history
…-fixes

fix(merchant-sdk): Added amount verification to SDK using `String.toB…
  • Loading branch information
danicretu authored Aug 21, 2024
2 parents 6ec97f7 + d421b72 commit 0966a10
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import net.gini.android.merchant.sdk.integratedFlow.PaymentFlowConfiguration
import net.gini.android.merchant.sdk.integratedFlow.PaymentFragment
import net.gini.android.merchant.sdk.paymentcomponent.PaymentComponent
import net.gini.android.merchant.sdk.util.DisplayedScreen
import net.gini.android.merchant.sdk.util.toBackendFormat
import org.slf4j.LoggerFactory

/**
Expand Down Expand Up @@ -108,7 +109,15 @@ class GiniMerchant(
* @param flowConfiguration - optional parameter with the [PaymentFlowConfiguration]
*/
fun createFragment(iban: String, recipient: String, amount: String, purpose: String, flowConfiguration: PaymentFlowConfiguration? = null): PaymentFragment {
if (iban.isEmpty() || recipient.isEmpty() || amount.isEmpty() || purpose.isEmpty()) throw IllegalStateException("Payment details are incomplete.")
if (iban.isEmpty() || recipient.isEmpty() || amount.isEmpty() || purpose.isEmpty()) {
error("Payment details are incomplete.")
}

try {
amount.toBackendFormat()
} catch (e: NumberFormatException) {
error("Amount format is incorrect.")
}

val paymentDetails = PaymentDetails(
recipient = recipient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/gms_large"
android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
Expand Down

0 comments on commit 0966a10

Please sign in to comment.