Simple Transaction
- Create WirecardClient instance. Note that our SDK works only with non-rooted devices, if SDK detects that device is rooted, exception is thrown during initialization of WirecardClient object. This is how you should handle this:
WirecardClient wirecardClient;
String environment = WirecardEnvironment.TEST.name();
try {
wirecardClient = WirecardClientBuilder.newInstance(context, environment)
.build();
} catch (WirecardException exception) {
}
- Create and initialize WirecardCardPayment object.
WirecardCardPayment wirecardCardPayment = new WirecardCardPayment(timestamp, requestID, merchantID, transactionType, amount, currency, signature);
- Create and initialize WirecardResponseListener object which provides callback methods which will provide transaction result or error information if occure.
WirecardResponseListener wirecardResponseListener = new WirecardResponseListener() {
@Override
public void onResponse(WirecardPaymentResponse paymentResponse) {
if (paymentResponse.getTransactionState().equals(TransactionState.SUCCESS)) {
} else {
}
}
@Override
public void onError(WirecardResponseError responseError) {
switch (responseError.getErrorCode()) {
case WirecardErrorCode.ERROR_CODE_GENERAL:
String detailedMessage = responseError.getErrorMessage();
break;
case WirecardErrorCode.ERROR_CODE_INVALID_PAYMENT_DATA:
break;
case WirecardErrorCode.ERROR_CODE_NETWORK_ISSUE:
break;
case WirecardErrorCode.ERROR_CODE_USER_CANCELED:
break;
}
}
};
- Call WirecardClient’s method makePayment
wirecardClient.makePayment(wirecardCardPayment, wirecardResponseListener, paymentPageStyle);
- Process response. When transaction was processed on server side and no error during transaction occurred, WirecardResponseListener’s method onResponse will be called. If any error occurs, method onError will be called.
Referenced transaction
If you want to perform referenced transaction (using token or parentTransactionID), just set them into wirecardCardPayment
instance.
wirecardPayment.setParentTransactionID(parentTransactionID);
or
CardToken cardToken = new CardToken(tokenID, maskedAccountNumber);
wirecardPayment.setCardToken(cardToken);
Custom form UI
It is possible to customize:
- input fields style
- background color / resource
- buttons background color / resource
- labels,hints
- labels,hints colors
- supported card brands
You need to initialize PaymentPageStyle object.
PaymentPageStyle style = new PaymentPageStyle();
Provide customized resources:
PaymentPageStyle style = new PaymentPageStyle();
style.backgroundResourceId = R.color.yellow;
style.inputTextColor = context.getResources().getColor(R.color.red);
style.inputFieldColor = context.getResources().getColor(R.color.red);
style.inputHintTextColor = context.getResources().getColor(R.color.red_transparent);
style.payButtonBackgroundResourceId = R.color.blue;
style.toolbarResourceId = R.color.red;
style.inputLabelTextColor = context.getResources().getColor(R.color.blue);
style.scanButtonTextColor = context.getResources().getColor(R.color.red);
style.toolbarTextColor = context.getResources().getColor(R.color.yellow);
style.payButtonTextColor = context.getResources().getColor(R.color.yellow);
Set<CardBrand> supportedCardBrands = new HashSet<>();
supportedCardBrands.add(CardBrand.MASTERCARD);
supportedCardBrands.add(CardBrand.AMEX);
style.supportedCardBrands = supportedCardBrands;
...
Call WirecardClient’s method makePayment:
wirecardClient.makePayment(wirecardCardPayment, wirecardResponseListener, paymentPageStyle);
Card payment form guide
1 - backgroundResourceId
2 - inputTextColor
3 - inputFieldColor
4 - payButtonBackgroundResourceId
5 - toolbarResourceId
6 - inputLabelTextColor
7 - toolbarTextColor
8 - payButtonTextColor
9 - scanButtonTextColor