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; }
public function testGettingQuantityOfElementes() { $order = new Order(10, array(array("name" => "hello", "price" => 100), array("second", 60), array("quantized", 120, 3), array("name" => "labelled", "price" => 200, "quantity" => 4))); $this->assertEquals($order->getLine(0)["quantity"], 1); $this->assertEquals($order->getLine(1)["quantity"], 1); $this->assertEquals($order->getLine(2)["quantity"], 3); $this->assertEquals($order->getLine(2)["price"], 120); $this->assertEquals($order->getLine(3)["quantity"], 4); $this->assertEquals($order->getLine(3)["price"], 200); $order->addLine("more", 130, 3); $this->assertEquals($order->getLine(4)["quantity"], 3); $this->assertEquals($order->getLine(4)["price"], 130); }