Important information


Enable Recurring Payments

Enable recurring payments for your transactions

The SDK allows activation of recurring payment for the following payment types:

  • Card (Credit Card and Debit Card)
  • PayPal
  • Unzer Direct Debit (secured)

To activate recurring for a payment type, you need to call activateRecurring and to pass along the returnUrl to which the customer will be redirected after performing actions outside the shop (for example, authorizing a PayPal payment).

This is currently not supported.
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
Recurring recurring = unzer.recurring("s-crd-9wmri5mdlqps", "https://your.return.url");

When activating recurring, an object of type Recurring is returned which has the property redirectUrl. If this URL is not empty, you need to redirect the customer to it so that they can authenticate the payment.

// Redirect to the 3ds page or to success depending on the state of the transaction
if(recurring.getRedirectUrl() != "")
  if (recurring.getRedirectUrl() == "" && recurring.Status.equals(Recurring.Status.SUCCESS)) {
    // Redirect to success page
  } else if (recurring.getRedirectUrl() != "" && recurring.Status.equals(Recurring.Status.PENDING)) {
    // redirect to recurring.getRedirectUrl()

When the customer returns and all has been successful the method getRecurring of the payment type should return true.

Unzer unzer = new Unzer('s-priv-xxxxxxxxxx');
Card card = unzer.fetchPaymentType('s-crd-9wmri5mdlqps');

if (card.getRecurring()) {
  // handle as success
// else handle as failure
icon info
Recurring for Unzer Direct Debit
With Unzer Direct Debit recurring is activated automatically when a charge has been successful. It cannot be activated using the methods described here.

Arguments to Unzer.recurring

Parameter Type Description
typeId String Reference to the payment type to use by ID

Required: true
customerId String Reference to the customer resource to use by ID

Required: false
Default: null
metadataId String Reference to the metadata resource to use by ID

Required: false
Default: null
returnUrl URL The URL the API leads the customer to after they finished entering payment information outside of the shop (for example, PayPal).
This needs to be set to a valid URL, no matter whether a redirect is necessary or not.
Required: true
recurrenceType RecurrenceType Recurrence type used for card recurring payment.

Required: false
Default: null