[Deprecated] 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 Installment.
To confirm a shipment, you can call the ship
method of the unzer
or payment
object.
For a full list of the ship
request parameter, please refer to API reference.
$unzer = new UnzerSDK\Unzer('s-priv-xxxxxxxxxx');
$payment = $unzer->fetchPayment('s-pay-1');
$shipment = $unzer->ship($payment);
$unzer = new UnzerSDK\Unzer('s-priv-xxxxxxxxxx');
$payment = $unzer->fetchPayment('s-pay-1');
$shipment = $payment->ship();
Arguments to Unzer::ship
Parameter | Type | Description |
---|---|---|
payment | string or UnzerSDK\Resources\Payment | The ID of the payment resource or the Payment object itself. 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 Unzer API using the method $unzer->fetchPaymentByOrderId($YourOrderId) Required: false Default: null |
Arguments to Payment::ship
Parameter | Type | Description |
---|---|---|
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 Unzer API using the method$unzer->fetchPaymentByOrderId($YourOrderId) Required: false |
Transaction Results
The transaction response will be stored in the transaction object. It contains a paymentId
(e.g 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 parameters isSuccess
, isPending
, isError
indicate the result of the transaction. Only one of these three can be true.
If a transaction fails, the Unzer API will return an error resource instead of a transaction. In the SDK this is handled as an UnzerApiException
. Make sure to catch that case properly.
For an example transaction, see Confirm shipment.
try {
$unzer = new UnzerSDK\Unzer('s-priv-xxxxxxxxxx');
$payment = $unzer->fetchPayment($paymentId);
$shipment = $payment->ship();
if ($shipment ->isSuccess) {
$this->redirectToSuccess();
}
// Transaction has to be pending at this point.
$this->redirectToPending();
} catch (UnzerApiException $e) {
// Transaction failed. API returned error resource.
$this->log($e->getClientMessage());
$this->log($e->getMerchantMessage());
$this->redirectToFailure(); // redirect to the failure page of your shop
} catch (RuntimeException $e) {
$merchantMessage = $e->getMessage();
}
Cancel after shipment
If the customer requests a refund or cancels the order, you can execute a cancel
and this amount is deducted from the transaction amount. You must always specify the reason code for a cancel.
Possible reason codes are:
reasonCode | Description |
---|---|
CANCEL | You can use CANCEL if you like to cancel a remaining amount, for instance if you are not going to ship certain goods. |
RETURN | RETURN is used, if you like to refund a certain amount for goods the customer returned to you. |
CREDIT | CREDIT can be used if you like to reduce the order amount after goods are shipped for example, to grant a discount for defect goods. |
See also
- Cancel a charge (refund) for cancel call examples.