コード例 #1
0
 function test_UpdateOrderRows_updatePaymentPlanOrderRows_multiple_row_success()
 {
     $country = "SE";
     // create order
     $order = TestUtil::createOrderWithoutOrderRows(TestUtil::createIndividualCustomer($country));
     $order->addOrderRow(WebPayItem::orderRow()->setArticleNumber("1")->setQuantity(1)->setAmountExVat(1000.0)->setVatPercent(25)->setDescription("A Specification")->setName('A Name')->setUnit("st")->setDiscountPercent(0));
     $order->addOrderRow(WebPayItem::orderRow()->setArticleNumber("2")->setQuantity(1)->setAmountExVat(2000.0)->setVatPercent(25)->setDescription("B Specification")->setName('B Name')->setUnit("st")->setDiscountPercent(0));
     $order->addOrderRow(WebPayItem::orderRow()->setArticleNumber("3")->setQuantity(1)->setAmountExVat(3000.0)->setVatPercent(25)->setDescription("C Specification")->setName('C Name')->setUnit("st")->setDiscountPercent(0));
     $orderResponse = $order->usePaymentPlanPayment(TestUtil::getGetPaymentPlanParamsForTesting())->doRequest();
     $this->assertEquals(1, $orderResponse->accepted);
     // update all attributes for a numbered orderRow
     $updateOrderRowsResponse = WebPayAdmin::updateOrderRows(Svea\SveaConfig::getDefaultConfig())->setOrderId($orderResponse->sveaOrderId)->setCountryCode($country)->updateOrderRow(WebPayItem::numberedOrderRow()->setArticleNumber("10")->setQuantity(1)->setAmountExVat(10.0)->setVatPercent(25)->setDescription("K Specification")->setName('K Name')->setUnit("st")->setDiscountPercent(1)->setRowNumber(1)->setStatus(Svea\NumberedOrderRow::ORDERROWSTATUS_NOTDELIVERED))->updateOrderRows(array(WebPayItem::numberedOrderRow()->setArticleNumber("20")->setQuantity(2)->setAmountExVat(20.0)->setVatPercent(25)->setDescription("K2 Specification")->setName('K2 Name')->setUnit("st")->setDiscountPercent(1)->setRowNumber(2)->setStatus(Svea\NumberedOrderRow::ORDERROWSTATUS_NOTDELIVERED), WebPayItem::numberedOrderRow()->setArticleNumber("30")->setQuantity(3)->setAmountExVat(30.0)->setVatPercent(25)->setDescription("K3 Specification")->setName('K3 Name')->setUnit("st")->setDiscountPercent(1)->setRowNumber(3)->setStatus(Svea\NumberedOrderRow::ORDERROWSTATUS_NOTDELIVERED)))->updatePaymentPlanOrderRows()->doRequest();
     ////print_r( $updateOrderRowsResponse );
     ////print_r("test_UpdateOrderRows_updateInvoiceOrderRows_single_row_success: "); //print_r( $orderResponse->sveaOrderId );
     $this->assertEquals(1, $updateOrderRowsResponse->accepted);
     // todo query result & check amounts, description automatically
 }
コード例 #2
0
 function test_manual_setup_CreditInvoiceOrderRows_testdata()
 {
     // Stop here and mark this test as incomplete.
     $this->markTestIncomplete('test_manual_setup_CreditOrderRows_testdata -- run this first to setup order for CreditOrderRows tests to work with. 
         1. Run once, then make sure to log as ug 79021 and approve the invoice in the admin interface. 
         2. Set $this->invoiceIdToTest to the approved invoice id in setUp() above.
         3. Then uncomment and run CreditOrderRows tests below.');
     // create order
     $order = TestUtil::createOrderWithoutOrderRows(TestUtil::createIndividualCustomer($this->country));
     $order->addOrderRow(WebPayItem::orderRow()->setArticleNumber("1")->setQuantity(1)->setAmountExVat(100.0)->setVatPercent(25)->setDescription("A Specification")->setName('A Name')->setUnit("st")->setDiscountPercent(0));
     $order->addOrderRow(WebPayItem::orderRow()->setArticleNumber("2")->setQuantity(1)->setAmountExVat(100.0)->setVatPercent(12)->setDescription("B Specification")->setName('B Name')->setUnit("st")->setDiscountPercent(0));
     $order->addOrderRow(WebPayItem::orderRow()->setArticleNumber("3")->setQuantity(1)->setAmountExVat(1.0)->setVatPercent(25)->setDescription("C Specification")->setName('C Name')->setUnit("st")->setDiscountPercent(0));
     $order->addOrderRow(WebPayItem::orderRow()->setArticleNumber("4")->setQuantity(1)->setAmountExVat(100.0)->setVatPercent(0)->setDescription("D Specification")->setName('D Name')->setUnit("st")->setDiscountPercent(0));
     $order->addOrderRow(WebPayItem::orderRow()->setArticleNumber("5")->setQuantity(1)->setAmountExVat(100.0)->setVatPercent(0)->setDescription("E Specification")->setName('E Name')->setUnit("st")->setDiscountPercent(0));
     $orderResponse = $order->useInvoicePayment()->doRequest();
     $this->assertEquals(1, $orderResponse->accepted);
     // deliver order
     $deliver = WebPay::deliverOrder(Svea\SveaConfig::getDefaultConfig());
     $deliver->setCountryCode($this->country)->setOrderId($orderResponse->sveaOrderId)->setInvoiceDistributionType(DistributionType::POST);
     $deliverResponse = $deliver->deliverInvoiceOrder()->doRequest();
     $this->assertEquals(1, $deliverResponse->accepted);
     //print_r("\ntest_manual_setup_CreditOrderRows_testdata finished, now approve the following invoice: ". $deliverResponse->invoiceId . "\n");
 }
コード例 #3
0
 public function test_deliverOrder_deliverInvoiceOrder_with_order_rows_first_deliver_then_credit_order()
 {
     // create order using order row specified with ->setName() and ->setDescription
     $specifiedOrderRow = WebPayItem::orderRow()->setAmountExVat(100.0)->setVatPercent(25)->setQuantity(1);
     $order = TestUtil::createOrderWithoutOrderRows()->addOrderRow($specifiedOrderRow);
     $createOrderResponse = $order->useInvoicePayment()->doRequest();
     //print_r( $createOrderResponse );
     $this->assertInstanceOf("Svea\\WebService\\CreateOrderResponse", $createOrderResponse);
     $this->assertTrue($createOrderResponse->accepted);
     $createdOrderId = $createOrderResponse->sveaOrderId;
     // deliver order
     $deliverOrderBuilder = WebPay::deliverOrder(Svea\SveaConfig::getDefaultConfig())->setOrderId($createdOrderId)->setCountryCode("SE")->setInvoiceDistributionType(DistributionType::POST)->addOrderRow($specifiedOrderRow);
     $deliverOrderResponse = $deliverOrderBuilder->deliverInvoiceOrder()->doRequest();
     //print_r( $deliverOrderResponse );
     $this->assertInstanceOf("Svea\\WebService\\DeliverOrderResult", $deliverOrderResponse);
     $this->assertTrue($createOrderResponse->accepted);
     $deliveredInvoiceId = $deliverOrderResponse->invoiceId;
     // credit order
     $creditOrderBuilder = WebPay::deliverOrder(Svea\SveaConfig::getDefaultConfig())->setOrderId($createdOrderId)->setCountryCode("SE")->setInvoiceDistributionType(DistributionType::POST)->addOrderRow($specifiedOrderRow)->setCreditInvoice($deliveredInvoiceId);
     $creditOrderResponse = $creditOrderBuilder->deliverInvoiceOrder()->doRequest();
     //print_r( $creditOrderResponse );
     $this->assertInstanceOf("Svea\\WebService\\DeliverOrderResult", $deliverOrderResponse);
     $this->assertTrue($creditOrderResponse->accepted);
 }
コード例 #4
0
 function test_AddOrderRows_addInvoiceOrderRows_specified_with_price_specified_using_inc_vat_and_ex_vat()
 {
     $country = "SE";
     $order = TestUtil::createOrderWithoutOrderRows(TestUtil::createIndividualCustomer($country));
     $order->addOrderRow(WebPayItem::orderRow()->setArticleNumber("1")->setQuantity(1)->setAmountExVat(100.0)->setVatPercent(25)->setDescription("Specification")->setName('Product')->setUnit("st")->setDiscountPercent(0));
     $orderResponse = $order->useInvoicePayment()->doRequest();
     $this->assertEquals(1, $orderResponse->accepted);
     $addOrderRowsBuilder = new \Svea\AddOrderRowsBuilder(Svea\SveaConfig::getDefaultConfig());
     $addOrderRowsResponse = $addOrderRowsBuilder->setOrderId($orderResponse->sveaOrderId)->setCountryCode($country)->addOrderRow(WebPayItem::orderRow()->setArticleNumber("1")->setQuantity(1)->setAmountIncVat(1.0 * 1.25)->setVatPercent(25)->setDescription("Specification")->setName('Product')->setUnit("st")->setDiscountPercent(0))->addOrderRow(WebPayItem::orderRow()->setArticleNumber("1")->setQuantity(1)->setAmountExVat(4.0)->setAmountIncVat(4.0 * 1.25)->setDescription("Specification")->setName('Product')->setUnit("st")->setDiscountPercent(0))->addInvoiceOrderRows()->doRequest();
     $this->assertEquals(1, $addOrderRowsResponse->accepted);
 }
コード例 #5
0
 /**
  * test_manual_CancelOrderBuilderRows_Card_single_row_success_step_1
  *
  */
 function test_manual_CancelOrderBuilderRows_Card_multiple_rows_success_step_1()
 {
     // Stop here and mark this test as incomplete.
     $this->markTestIncomplete('skeleton for test_manual_CancelOrderBuilderRows_Card_single_row_success_step_1, step 1');
     // 1. remove (put in a comment) the above code to enable the test
     // 2. run the test, and get the paymenturl from the output
     // 3. go to the paymenturl and complete the transaction manually, making note of the response transactionid
     // 4. enter the transactionid into test_manual_queryOrder_queryCard_order_step_2() below and run the test
     $orderLanguage = "sv";
     $returnUrl = "http://foo.bar.com";
     $ipAddress = "127.0.0.1";
     // create order w/three rows
     $order = \TestUtil::createOrderWithoutOrderRows(TestUtil::createIndividualCustomer("SE")->setIpAddress($ipAddress));
     // 2x100 @25 = 25000 (5000)
     // 1x100 @25 = 12500 (2500)
     // 1x100 @12 = 11200 (1200)
     // amount = 48700, vat = 8700
     $country = "SE";
     $order->addOrderRow(WebPayItem::orderRow()->setQuantity(2)->setAmountExVat(100.0)->setVatPercent(25))->addOrderRow(WebPayItem::orderRow()->setQuantity(1)->setAmountExVat(100.0)->setVatPercent(25))->addOrderRow(WebPayItem::orderRow()->setQuantity(1)->setAmountExVat(100.0)->setVatPercent(12));
     $response = $order->usePayPageCardOnly()->setPayPageLanguage($orderLanguage)->setReturnUrl($returnUrl)->getPaymentUrl();
     // check that request was accepted
     $this->assertEquals(1, $response->accepted);
     // print the url to use to confirm the transaction
     //print_r( "\n test_manual_CancelOrderBuilderRows_Card_single_row_success_step_1(): " . $response->testurl ."\n ");
 }
コード例 #6
0
 /**
  * test_manual_queryOrder_queryDirectBank_order_step_1
  *
  */
 function test_manual_queryOrder_queryDirectBank_order_step_1()
 {
     // Stop here and mark this test as incomplete.
     $this->markTestIncomplete('skeleton for test_manual_queryOrder_queryDirectBank_order_step_1, step 1');
     // 1. remove (put in a comment) the above code to enable the test
     // 2. run the test, and get the paymenturl from the output
     // 3. go to the paymenturl and complete the transaction manually, making note of the response transactionid
     // 4. enter the transactionid into test_manual_queryOrder_queryCard_order_step_12() below and run the test
     $orderLanguage = "sv";
     $returnUrl = "http://foo.bar.com";
     $ipAddress = "127.0.0.1";
     // create order
     $order = \TestUtil::createOrderWithoutOrderRows(TestUtil::createIndividualCustomer("SE")->setIpAddress($ipAddress));
     // create order w/three rows (2xA, 1xB)
     $country = "SE";
     $a_quantity = 2;
     $a_amountExVat = 1000.0;
     $a_vatPercent = 25;
     $b_quantity = 1;
     $b_amountExVat = 100.0;
     $b_vatPercent = 12;
     $b_articleNumber = "Red 5";
     $b_unit = "pcs.";
     $b_name = "B Name";
     $b_description = "B Description";
     $b_discount = 0;
     $order->addOrderRow(WebPayItem::orderRow()->setQuantity($a_quantity)->setAmountExVat($a_amountExVat)->setVatPercent($a_vatPercent))->addOrderRow(WebPayItem::orderRow()->setQuantity($b_quantity)->setAmountExVat($b_amountExVat)->setVatPercent($b_vatPercent)->setArticleNumber($b_articleNumber)->setUnit($b_unit)->setName($b_name)->setDescription($b_description)->setDiscountPercent($b_discount));
     // set payment method
     // call getPaymentURL
     $response = $order->usePayPageDirectBankOnly()->setPayPageLanguage($orderLanguage)->setReturnUrl($returnUrl)->getPaymentUrl();
     // check that request was accepted
     $this->assertEquals(1, $response->accepted);
     // print the url to use to confirm the transaction
     //print_r( " test_manual_queryOrder_queryDirectBank_order_step_1(): " . $response->testurl ." ");
 }
コード例 #7
0
 public function test_queryOrder_queryInvoiceOrder_multiple_order_rows()
 {
     // create order using order row specified with ->setName() and ->setDescription
     $specifiedOrderRow = WebPayItem::orderRow()->setAmountExVat(100.0)->setVatPercent(25)->setQuantity(1)->setName("orderrow 1")->setDescription("description 1");
     // create order using order row specified with ->setName() and ->setDescription
     $specifiedOrderRow2 = WebPayItem::orderRow()->setAmountExVat(100.0)->setVatPercent(25)->setQuantity(1)->setName("orderrow 2")->setDescription("description 2");
     $order = TestUtil::createOrderWithoutOrderRows()->addOrderRow($specifiedOrderRow)->addOrderRow($specifiedOrderRow2);
     $createOrderResponse = $order->useInvoicePayment()->doRequest();
     ////print_r( $createOrderResponse );
     $this->assertInstanceOf("Svea\\WebService\\CreateOrderResponse", $createOrderResponse);
     $this->assertTrue($createOrderResponse->accepted);
     $createdOrderId = $createOrderResponse->sveaOrderId;
     // WPA::queryOrder()
     // ->queryInvoiceOrder()
     // query orderrows
     $queryOrderBuilder = WebPayAdmin::queryOrder(Svea\SveaConfig::getDefaultConfig())->setOrderId($createdOrderId)->setCountryCode("SE");
     $queryResponse = $queryOrderBuilder->queryInvoiceOrder()->doRequest();
     //print_r( $queryResponse);
     $this->assertEquals(1, $queryResponse->accepted);
     // assert that order rows are the same
     $this->assertEquals(1, $queryResponse->accepted);
     $this->assertEquals(1, $queryResponse->numberedOrderRows[0]->rowNumber);
     $this->assertEquals(1.0, $queryResponse->numberedOrderRows[0]->quantity);
     $this->assertEquals(100.0, $queryResponse->numberedOrderRows[0]->amountExVat);
     $this->assertEquals(25, $queryResponse->numberedOrderRows[0]->vatPercent);
     $this->assertEquals(null, $queryResponse->numberedOrderRows[0]->name);
     $this->assertEquals("orderrow 1: description 1", $queryResponse->numberedOrderRows[0]->description);
     $this->assertEquals(2, $queryResponse->numberedOrderRows[1]->rowNumber);
     $this->assertEquals(1.0, $queryResponse->numberedOrderRows[1]->quantity);
     $this->assertEquals(100.0, $queryResponse->numberedOrderRows[1]->amountExVat);
     $this->assertEquals(25, $queryResponse->numberedOrderRows[1]->vatPercent);
     $this->assertEquals(null, $queryResponse->numberedOrderRows[1]->name);
     $this->assertEquals("orderrow 2: description 2", $queryResponse->numberedOrderRows[1]->description);
 }