iZettle / sdk-android

Add card payments from Zettle to your own app
https://developer.zettle.com/docs/android-sdk
24 stars 20 forks source link

CardPaymentActivity amount should be a double #22

Closed hclemson closed 2 years ago

hclemson commented 3 years ago

Expected Behavior

To be able to take payments in pounds and pence, dollar and cents, e.g. 1.99, the amount value in CardPaymentActivity should be a double.

Current Behavior

The amount value is currently a Long

Steps to Reproduce

See example Step 5

val intent = CardPaymentActivity.IntentBuilder(this)
    // MANDATORY: Transaction amount in account currency 
    .amount(20000L)
    // MANDATORY, Reference object created in previous step        
    .reference(reference)
    // MANDATORY, you can enable login prompt in the payment flow if user is not yet logged-in
    .enableLogin(enableLogin)
    // OPTIONAL, you can enable tipping (disabled by default)       
    // This option will only work for markets with tipping support
    .enableTipping(true)
    // OPTIONAL, you can enable installments (enabled by default)
    // This option will only work for markets with installments support
    .enableInstalments(enableInstallments)
    .build()
adamvoncorswant commented 3 years ago

Hey @hclemson ! All monetary amounts that we handle are always specified as an integer (long) in the minimal denominator of the currency. So, for GBP1.99 you should use the value of 199.

I hope that clarifies.

hclemson commented 3 years ago

Hi @adamvoncorswant That's perfect, that you for clarifying. Do you have any docs that detail this and the other values, as I wasn't able to locate any?

fabriciovergara commented 3 years ago

Hi @hclemson, all the documentation that we have in the README in this repository. Ass @adamvoncorswant said, we use a long for all currency values. For example, EUR has cents, then €1.99 is 199 - but SEK doesn't have cents, then 199kr is 19900

Regarding other values, do you mean when creating the intent?

.reference(reference) -> You create by providing a unique id created and store by you and with that you can use to locate a transaction.

.enableLogin(boolean) -> If user is not signed in our sdk, it will prompt before continuing a payment

.enableTipping(boolean) -> will enable tipping for a transaction, but only if the country that transaction is happening has support for tipping/gratuity.

.enableInstalments(boolean) -> will enable installments for a tranaction, but only if the country that transaction is happening has support for installments. I can say that by now only Brazil and Mexico has such support.

Please, let me know if is something else specifically.

fabriciovergara commented 3 years ago

Fixed mistake in the SEK case explanation.