/**
  * Sets the "used" timestamp on vouchers that have been used entirely for
  * a payment.
  *
  * The timestamp is set to the "created at" timestamp for the payment.
  *
  * @param Payment\Event\TransactionalEvent $event
  */
 public function setUsedTimestamp(Payment\Event\TransactionalEvent $event)
 {
     $payment = $event->getPayment();
     $voucherLoader = $this->get('voucher.loader');
     $voucherEdit = $this->get('voucher.edit');
     // Set voucher edit decorator to use the transaction from the event
     $voucherEdit->setTransaction($event->getTransaction());
     // Skip if the payment isn't a voucher payment
     if ('voucher' !== $payment->method->getName()) {
         return false;
     }
     $voucher = $voucherLoader->getByID($payment->reference);
     // Skip if the voucher could not be found
     if (!$voucher instanceof Voucher) {
         return false;
     }
     // Skip if the voucher wasn't fully used
     if ($payment->amount != $voucher->getBalance()) {
         return false;
     }
     $voucherEdit->setUsed($voucher, $payment->authorship->createdAt());
 }