-
Notifications
You must be signed in to change notification settings - Fork 0
SDK Custom UI Usage Tutorial
If you do not want to make use of the pre-created UI screens for payment method registration, you can also register payment methods manually. This might be less stable across different PSPs since some PSPs require some data and others require other data points. The pre-created UI would take care of collecting all necessary data points for you. There is more information on the data needed from each PSP in their respective wiki pages.
To use your own UI, you need to take the following steps:
- Add the SDK and necessary dependencies to your project
- Configure the SDK
(These steps are identical to the first two steps of using the preconfigured UI. See the tutorial on that topic for instructions on how to perform these steps.)
- Register the payment methods
For BSPayone, the below is enough to register a credit card:
val billingData = BillingData(
firstName = "Max",
lastName = "Mustermann",
city = "Cologne",
country = "DE"
)
val creditCardData = CreditCardData(
number = "4111111111111111",
expiryMonth = 10,
expiryYear = 2021,
cvv = "123",
billingData = billingData
)
val requestUUID = UUID.randomUUID()
val registrationManager = Stash.getRegistrationManager()
registrationManager.registerCreditCard(creditCardData, requestUUID)
.subscribeBy(
onSuccess = { paymentAlias ->
//Send alias to your backend server for later usage
sendAliasToBackend(paymentAlias.alias)
aliasInfo = paymentAlias.extraAliasInfo as CreditCardExtraInfo
// Handle showing credit card payment method in UI, i.e.:
showCreditCardMask(aliasInfo.creditCardMask)
},
onError = {
//Handle exceptions
handleException(it)
}
)
BillingData billingData = new BillingData.Builder()
.setFirstName("Max")
.setLastName("Mustermann")
.setCountry("DE")
.build();
CreditCardData creditCardData = new CreditCardData.Builder()
.setNumber("123123123123")
.setCvv("123")
.setBillingData(billingData)
.setExpiryMonth(11)
.setExpiryYear(2020)
.build();
UUID requestUUID = UUID.randomUUID()
registrationManager.registerCreditCard(creditCardData, requestUUID)
.subscribe(
paymentMethodAlias -> {
//Handle showing credit card payment method in UI, i.e.:
ExtraAliasInfo.CreditCardExtraInfo creditCardAliasInfo = paymentMethodAlias.getJavaExtraInfo().getCreditCardExtraInfo();
showCreditCardMask(creditCardAliasInfo.getCreditCardMask());
}
},
exception -> {
//Handle error
handleException(exception);
}
);
Note that the country field takes an ISO country code. e.g. 'DE' for Germany and is mandatory for some PSPs (e.g. BSPayone). If you were using i.e. Adyen integration, you would not need to provide country parameter.
Also, note that the UUID idempotency key is an optional parameter.
Registering a SEPA method from code is quite similar. Here, you need to use the registerCreditCard
of RegistrationManager
:
val billingData = BillingData(
city = "Cologne",
country = "DE"
)
val sepaData = SepaData(
iban = "DE63123456791212121212",
billingData = billingData
)
val requestUUID = UUID.randomUUID()
val registrationManager = Stash.getRegistrationManager()
registrationManager.registerSepa(sepaData, requestUUID)
.subscribeBy(
onSuccess = { paymentAlias ->
// Handle showing credit card payment method in UI, i.e.:
val aliasInfo = paymentAlias.extraAliasInfo as SepaExtraInfo
showSepaMask(aliasInfo.creditCardMask)
},
onError = {
// Handle error
}
)
BillingData billingData = new BillingData.Builder()
.setCity("Cologne")
.setCountry("DE")
.build()
SepaData sepaData = new SepaData.Builder()
.setIban("DE63123456791212121212");
.setBillingData(billingData);
.build()
RegistrationManager registrationManager = Stash.getRegistrationManager();
UUID requestUUID = UUID.randomUUID()
registrationManager.registerSepa(sepaData, requestUUID)
.subscribe(
paymentAlias -> {
ExtraAliasInfo.SepaExtraInfo sepaAliasInfo = paymentMethodAlias.getJavaExtraInfo().getSepaExtraInfo();;
//Handle showing SEPA payment method in UI i.e.:
showSepaMask(sepaAliasInfo.getMaskedIban());
},
error -> {
// Handle error
}
);