Unzer

Manage the payment page

Manage payment pages

Overview

To be able use the Payment Page integration with the Java SDK, you must create a Paypage instance and initialize it using the Unzer object. As a result you get an ID and a redirectURL which can be used to show the Payment Page:

  • Use the Payment Page ID to render the embedded Payment Page as described in Embedded Payment Page guide.
  • Or redirect your customer to the redirectURL to use the hosted Payment Page as shown in the Hosted Payment Page guide.

Initialize a payment page

A Payment Page needs at least an amount, a currency and the returnUrl to be initialized.
Optional parameter for the API request can be added to your paypage instance using the setter function of the given property as demonstrated in the example below.

For a complete list of request parameters, see the API reference.

Unzer unzer = new Unzer('s-priv-xxxxxxxxxx');

// initialization
Paypage paypage = new Paypage();

// set optional parameters
paypage.setAmount(BigDecimal.valuOf(100.0));
paypage.setCurrency(Currency.getInstance("EUR"));
paypage.setReturnUrl("https://your.return.url");
paypage.setLogoImage("https://your.logo.image.url");
paypage.setFullPageImage("https://your.logo.image.url");
paypage.setShopName("My Test Shop");
paypage.setShopDescription("We are selling goods.");
paypage.setTagline("We are selling goods.');
paypage.setOrderId("YourShopOrderId');
paypage.setTermsAndConditionUrl("https://your.tac.url");
paypage.setPrivacyPolicyUrl("https://your.privacy.policy.url");
paypage.setImprintUrl("https://your.imprint.url");
paypage.setHelpUrl("https://your.help.url");
paypage.setContactUrl("https://your.contact.url");
paypage.setInvoiceId("YourShopInvoiceId");
paypage.setCard3ds(true);
paypage.setCss([
            'shopDescription' => 'color: purple',
            'header' => 'background-color: red',
            'helpUrl' => 'color: blue',
            'contactUrl' => 'color: green',
        ]);

// init payment page to charge transaction ...
paypage = unzer.paypage(paypage);

// get the redirectURL
String redirectUrl = paypage->getRedirectUrl();

// redirect the customer to the redirectUrl
// after finishing the payment there the customer will be redirected to the returnUrl you set via the Payment Page constructor

// Note: you have to store the paymentId (e.g. in the checkout session) to be able to fetch the payment result later.
paymentId = paypage->getPaymentId();

Exclude payment types

To exclude payment types from the Payment Page, pass a list of them before calling unzer.paypage($paypage).

Unzer unzer = new Unzer('s-priv-xxxxxxxxxx');

// set mandatory parameters
Paypage paypage = new Paypage();

// add a single payment type to exclude list
paypage.setExcludeTypes({"paypal"});

// ...or set a list of excluded types
paypage.setExcludeTypes({"paypal", "card"});

See also