예제 #1
0
 /**
  * @param \ActiveCollab\Payments\Gateway\GatewayInterface     $gateway
  * @param OrderInterface                                      $order
  * @param \ActiveCollab\Payments\Order\Refund\RefundInterface $refund
  */
 public function triggerOrderPartiallyRefunded(GatewayInterface $gateway, OrderInterface $order, RefundInterface $refund)
 {
     if ($order->getTotal() <= $refund->getTotal()) {
         throw new LogicException("Refunded amount needs to be less than order's total amount");
     }
     $this->trigger(self::ON_ORDER_PARTIALLY_REFUNDED, $gateway, $order, $refund);
 }
예제 #2
0
 /**
  * Test if order completed triggers an event.
  */
 public function testOrderCompletedTriggersAnEvent()
 {
     $event_triggered = false;
     $this->dispatcher->listen(DispatcherInterface::ON_ORDER_COMPLETED, function (GatewayInterface $gateway, OrderInterface $order) use(&$event_triggered) {
         $this->assertInstanceOf(ExampleOffsiteGateway::class, $gateway);
         $this->assertInstanceOf(OrderInterface::class, $order);
         $this->assertEquals($this->order->getReference(), $order->getReference());
         $event_triggered = true;
     });
     $this->gateway->triggerOrderCompleted($this->order);
     $this->assertTrue($event_triggered);
 }
 /**
  * Trigger order has been partially refunded.
  *
  * @param OrderInterface              $order
  * @param OrderItemInterface[]        $items
  * @param DateTimeValueInterface|null $timestamp
  */
 public function triggerOrderPartiallyRefunded(OrderInterface $order, array $items = null, DateTimeValueInterface $timestamp = null)
 {
     $this->orders[$order->getReference()] = $order;
     if (empty($timestamp)) {
         $timestamp = new DateTimeValue();
     }
     $refund = new Refund($order->getReference() . '-X', $order->getReference(), $timestamp, 200);
     $refund->setGateway($this);
     if (!empty($items)) {
         $refund->setItems($items);
     }
     $this->refunds[$refund->getReference()] = $refund;
     $this->getDispatcher()->triggerOrderPartiallyRefunded($this, $order, $refund);
 }