PaymentSDK
Mobile payment SDK
Example

Simple transaction

  1. 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) {
    //device is rooted
    }
  2. Create and initialize WirecardPayPalPayment object:
    WirecardPayPalPayment wirecardPayment = new WirecardPayPalPayment(timestamp, requestID, merchantID, transactionType, amount, currency, signature);
  3. 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) {
    // handle server response
    if (paymentResponse.getTransactionState().equals(TransactionState.SUCCESS)) {
    // handle successful transaction
    } else {
    // handle unsuccessful transaction
    }
    }
    @Override
    public void onError(WirecardResponseError responseError) {
    // handle error
    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;
    }
    }
    };
  4. Call WirecardClient’s method makePayment:
    wirecardClient.makePayment(wirecardPayPalPayment, wirecardResponseListener, paymentPageStyle);
  5. 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:

Recurring transaction

If you want to perform recurring transaction, just set Periodic object into wirecardPayPalPayment object instance.

Periodic periodic = new Periodic(periodicType, sequenceType);
wirecardPayPalPayment.setPeriodic(periodic);