Unzer

Confirm shipment

Confirm shipping your goods to the customer and activate the insurance.

Shipment is the process of sending the goods to the customer. Once you have sent the goods, you must confirm the shipment to activate the insurance requested in the previous /charge request. The customer now has 40 days after this date to make the payment. You receive the money regardless of whether the customer pays or not.

Shipment is available for Unzer Invoice Secured and Unzer Instalment.

To confirm a shipment, you can call the ship method of the unzer or payment object.

Unzer unzer = new Unzer('s-priv-xxxxxxxxxx');
Shipment shipment = unzer.shipment('s-pay-1');

Arguments to Unzer.ship

Parameter Type Description
paymentId string The ID of the payment resource.
Required: true
invoiceId string The ID of the invoice in your shop. Only applicable in case of invoice payment types.
Required: In case of invoice payment types and if it has not been set before.
Default: null
orderId string The ID of the order in your store.
This ID can be used to fetch the payment resource from the PAPI using the method $unzer->fetchPaymentByOrderId($YourOrderId)
Required: false
Default: null

Transaction Results

The transaction response is stored in the transaction object. It contains a paymentId (for example, s-pay-1) the transactionId and other properties of the response. The transaction object provides getter functions to access those properties. For example, shipment.getPaymentId()

The status-parameter indicate the result of the transaction. The Enum can only be SUCCESS, PENDING or ERRROR

If a transaction fails, the payment API returns an error resource instead of a transaction. In the SDK this is handled as an UnzerPaymentException. Make sure to catch that case properly.

You can find an example transaction response on the Confirm shipment page.

try {
    Unzer unzer  = new Unzer("s-priv-xxxxxxxxxx");
    Shipment shipment = unzer.shipment(paymentId);

    if (shipment.Status.equals(Shipment.Status.SUCCESS)) {
        this.redirectToSuccess();
    }
    // Transaction has to be pending at this point.
    this.redirectToPending();
} catch (HttpCommunicationException | PaymentException e) {
    // Transaction failed. API returned error resource.
    List<PaymentError> paymentErrorList = e.getPaymentErrorList();
    //Handle API Errors
    
    this.redirectToFailure(); // redirect to the failure page of your shop
} catch (Exception e) {
    merchantMessage = e.getMessage();
}