Skip to content

Commit

Permalink
Convert ThreeDSecureV2ButtonCustomization, ThreeDSecureV2ButtonType, …
Browse files Browse the repository at this point in the history
…ThreeDSecureV2LabelCustomization, ThreeDSecureV2TextBoxCustomization, ThreeDSecureV2ToolbarCustomization, and ThreeDSecureV2UiCustomization to Kotlin (#1132)
  • Loading branch information
tdchow authored Aug 27, 2024
1 parent 8b158f4 commit c075b9d
Show file tree
Hide file tree
Showing 16 changed files with 237 additions and 851 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
* Update `ThreeDSecureRequest.isDataOnlyRequested()` to `ThreeDSecureRequest.getDataOnlyRequested()`
* Update `ThreeDSecureRequest.isExemptionRequested()` to `ThreeDSecureRequest.getDataOnlyRequested()`
* Update `ThreeDSecureRequest.isCardAddChallengeRequested()` to `ThreeDSecureRequest.getCardAddChallengeRequested()`
* ThreeDSecure
* Split `ThreeDSecureV2UiCustomization.setButtonCustomization()` to `setButtonCustomization()` and `setButtonType()`
* Change `ThreeDSecureV2ButtonType` to an enum

## 5.0.0-beta1 (2024-07-23)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.braintreepayments.api.threedsecure.ThreeDSecureResult;
import com.braintreepayments.api.threedsecure.ThreeDSecureUiType;
import com.braintreepayments.api.threedsecure.ThreeDSecureV2ButtonCustomization;
import com.braintreepayments.api.threedsecure.ThreeDSecureV2ButtonType;
import com.braintreepayments.api.threedsecure.ThreeDSecureV2LabelCustomization;
import com.braintreepayments.api.threedsecure.ThreeDSecureV2TextBoxCustomization;
import com.braintreepayments.api.threedsecure.ThreeDSecureV2ToolbarCustomization;
Expand Down Expand Up @@ -200,7 +201,7 @@ public void onPurchase(View v) {
card.setExpirationYear(cardForm.getExpirationYear());
card.setCvv(cardForm.getCvv());
// TODO: GQL currently only returns the bin if validate = false
card.setShouldValidate(false);
card.setShouldValidate(false);
card.setPostalCode(cardForm.getPostalCode());

cardClient.tokenize(card, (cardResult) -> {
Expand Down Expand Up @@ -325,8 +326,8 @@ private ThreeDSecureRequest threeDSecureRequest(PaymentMethodNonce paymentMethod
v2UiCustomization.setLabelCustomization(labelCustomization);
v2UiCustomization.setTextBoxCustomization(textBoxCustomization);
v2UiCustomization.setToolbarCustomization(toolbarCustomization);
v2UiCustomization.setButtonCustomization(submitButtonCustomization,
ThreeDSecureV2UiCustomization.BUTTON_TYPE_VERIFY);
v2UiCustomization.setButtonCustomization(submitButtonCustomization);
v2UiCustomization.setButtonType(ThreeDSecureV2ButtonType.BUTTON_TYPE_VERIFY);

ThreeDSecureRequest threeDSecureRequest = new ThreeDSecureRequest();
threeDSecureRequest.setAmount("10");
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.braintreepayments.api.threedsecure

import android.os.Parcelable
import com.cardinalcommerce.shared.userinterfaces.ButtonCustomization
import kotlinx.parcelize.Parcelize

/**
* Button customization options for 3D Secure 2 flows.
*
* @property textFontName Font type for the UI element.
* @property textColor Color code in Hex format. For example, the color code can be “#999999”.
* @property textFontSize Font size for the UI element.
* @property backgroundColor @param backgroundColor Color code in Hex format. For example, the color
* code can be “#999999”.
* @property cornerRadius Radius (integer value) for the button corners.
*/
@Parcelize
data class ThreeDSecureV2ButtonCustomization(
var textFontName: String? = null,
var textColor: String? = null,
var textFontSize: Int = 0,
var backgroundColor: String? = null,
var cornerRadius: Int = 0
) : Parcelable {

val cardinalButtonCustomization: ButtonCustomization
get() {
return ButtonCustomization().also {
textFontName?.let { textFontName -> it.textFontName = textFontName }
textColor?.let { textColor -> it.textColor = textColor }
if (textFontSize != 0) it.textFontSize = textFontSize
backgroundColor?.let { backgroundColor -> it.backgroundColor = backgroundColor }
if (cornerRadius != 0) it.cornerRadius = cornerRadius
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.braintreepayments.api.threedsecure

/**
* Button types that can be customized in 3D Secure 2 flows.
*/
enum class ThreeDSecureV2ButtonType {
BUTTON_TYPE_VERIFY,
BUTTON_TYPE_CONTINUE,
BUTTON_TYPE_NEXT,
BUTTON_TYPE_CANCEL,
BUTTON_TYPE_RESEND
}
Loading

0 comments on commit c075b9d

Please sign in to comment.