Пример #1
0
 public function testCreatingWithShipping()
 {
     $order = new Order(10, array(array("name" => "hello", "price" => 123.2), array("second", 112), array("type" => "shipping", "altName" => "Transport cost", "price" => 12)));
     $this->assertEquals($order->getLineCount(), 2);
     $this->assertEquals($order->getLine(0)["name"], "hello");
     $this->assertEquals($order->getLine(0)["price"], 123.2);
     $this->assertEquals($order->getLine(1)["name"], "second");
     $this->assertEquals($order->getLine(1)["price"], 112);
     $this->assertEquals($order->hasShipping(), true);
     $this->assertEquals($order->getShippingPrice(), 12);
     $this->assertEquals($order->getShippingAltName(), "Transport cost");
 }
Пример #2
0
 private function getOptionsWithLineItems(Order $order)
 {
     $options = $this->options;
     $total = 0;
     $lineItemCount = $order->getLineCount();
     for ($i = 0; $i < $lineItemCount; $i++) {
         $item = $order->getLine($i);
         $options["L_PAYMENTREQUEST_0_NAME" . $i] = urlencode($item["name"]);
         //TODO: Maybe L_PAYMENTREQUEST_0_{NUMBER,DESC}.$i (an item number) is required?
         $options["L_PAYMENTREQUEST_0_AMT" . $i] = urlencode(number_format($item["priceBeforeTax"], 2));
         //TODO: Support quantities
         $options["L_PAYMENTREQUEST_0_QTY" . $i] = urlencode(1);
     }
     return $options;
 }