public function test_deliver_multiple_invoice_orderRows_returns_accepted_with_invoiceId()
 {
     // create order
     $country = "SE";
     $order = TestUtil::createOrder(TestUtil::createIndividualCustomer($country))->addOrderRow(WebPayItem::orderRow()->setDescription("second row")->setQuantity(1)->setAmountExVat(16.0)->setVatPercent(25))->addOrderRow(WebPayItem::orderRow()->setDescription("third row")->setQuantity(1)->setAmountExVat(24.0)->setVatPercent(25));
     $orderResponse = $order->useInvoicePayment()->doRequest();
     ////print_r( $orderResponse );
     $this->assertEquals(1, $orderResponse->accepted);
     $myOrderId = $orderResponse->sveaOrderId;
     // deliver first row in order
     $deliverOrderRowsRequest = WebPayAdmin::deliverOrderRows(Svea\SveaConfig::getDefaultConfig());
     $deliverOrderRowsRequest->setCountryCode($country);
     $deliverOrderRowsRequest->setOrderId($myOrderId);
     $deliverOrderRowsRequest->setInvoiceDistributionType(DistributionType::POST);
     $deliverOrderRowsRequest->setRowsToDeliver(array(1, 2));
     $deliverOrderRowsResponse = $deliverOrderRowsRequest->deliverInvoiceOrderRows()->doRequest();
     ////print_r( $deliverOrderRowsResponse );
     $this->assertInstanceOf('Svea\\AdminService\\DeliverPartialResponse', $deliverOrderRowsResponse);
     $this->assertEquals(true, $deliverOrderRowsResponse->accepted);
     // truth
     $this->assertEquals(1, $deliverOrderRowsResponse->accepted);
     // equals literal 1
     $this->assertEquals(0, $deliverOrderRowsResponse->resultcode);
     $this->assertEquals(270.0, $deliverOrderRowsResponse->amount);
     $this->assertEquals("Invoice", $deliverOrderRowsResponse->orderType);
     $this->assertNotNull($deliverOrderRowsResponse->invoiceId);
 }
コード例 #2
0
 public function test_DeliverOrdersRequest_on_open_order_returns_accepted_true()
 {
     // create order
     $country = "SE";
     $order = TestUtil::createOrder(TestUtil::createIndividualCustomer($country));
     $orderResponse = $order->useInvoicePayment()->doRequest();
     ////print_r( $orderResponse );
     $this->assertEquals(1, $orderResponse->accepted);
     $myOrderId = $orderResponse->sveaOrderId;
     // deliver order
     $DeliverOrderBuilder = new Svea\DeliverOrderBuilder(Svea\SveaConfig::getDefaultConfig());
     $DeliverOrderBuilder->setCountryCode($country);
     $DeliverOrderBuilder->setOrderId($myOrderId);
     $DeliverOrderBuilder->setInvoiceDistributionType(DistributionType::POST);
     $DeliverOrderBuilder->orderType = ConfigurationProvider::INVOICE_TYPE;
     $request = new Svea\AdminService\DeliverOrdersRequest($DeliverOrderBuilder);
     $response = $request->doRequest();
     ////print_r( $response );
     $this->assertInstanceOf('Svea\\AdminService\\DeliverordersResponse', $response);
     $this->assertEquals(true, $response->accepted);
     // truth
     $this->assertEquals(1, $response->accepted);
     // equals literal 1
     $this->assertEquals(0, $response->resultcode);
     $this->assertEquals(250.0, $response->amount);
     $this->assertEquals("Invoice", $response->orderType);
     $this->assertNotNull($response->invoiceId);
     $this->assertNull($response->contractNumber);
 }
コード例 #3
0
 public function test_queryOrder_queryPaymentPlanOrder_is_accepted()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $orderResponse = WebPay::createOrder($config)->addOrderRow(WebPayItem::orderRow()->setAmountExVat(999.9)->setVatPercent(24)->setQuantity(1))->addCustomerDetails(TestUtil::createIndividualCustomer("SE"))->setCountryCode("SE")->setOrderDate("2012-12-12")->usePaymentPlanPayment(TestUtil::getGetPaymentPlanParamsForTesting())->doRequest();
     $this->assertEquals(1, $orderResponse->accepted);
     $queryResponse = WebPayAdmin::queryOrder(Svea\SveaConfig::getDefaultConfig())->setOrderId($orderResponse->sveaOrderId)->setCountryCode('SE')->queryPaymentPlanOrder()->doRequest();
     $this->assertEquals(1, $queryResponse->accepted);
 }
コード例 #4
0
 function test_CancelOrderBuilder_PaymentPlan_success()
 {
     $country = "SE";
     $order = TestUtil::createOrder(TestUtil::createIndividualCustomer($country))->addOrderRow(WebPayItem::orderRow()->setQuantity(1)->setAmountExVat(1000.0)->setVatPercent(25));
     $orderResponse = $order->usePaymentPlanPayment(TestUtil::getGetPaymentPlanParamsForTesting())->doRequest();
     $this->assertEquals(1, $orderResponse->accepted);
     $cancelResponse = WebPayAdmin::cancelOrder(Svea\SveaConfig::getDefaultConfig())->setOrderId($orderResponse->sveaOrderId)->setCountryCode($country)->cancelPaymentPlanOrder()->doRequest();
     $this->assertEquals(1, $cancelResponse->accepted);
 }
コード例 #5
0
 public function test_add_new_notes_invoice()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $orderResponse = WebPay::createOrder($config)->addOrderRow(WebPayItem::orderRow()->setAmountExVat(145.0)->setVatPercent(24)->setQuantity(1))->addCustomerDetails(TestUtil::createIndividualCustomer("SE"))->setCountryCode("SE")->setOrderDate("2012-12-12")->useInvoicePayment()->doRequest();
     $this->assertEquals(1, $orderResponse->accepted);
     $response = WebPayAdmin::updateOrder($config)->setCountryCode('SE')->setOrderId($orderResponse->sveaOrderId)->setNotes($this->notes)->updateInvoiceOrder()->doRequest();
     $this->assertEquals(1, $response->accepted);
     // query order and assert row totals
     $query2 = WebPayAdmin::queryOrder($config)->setOrderId($orderResponse->sveaOrderId)->setCountryCode('SE')->queryInvoiceOrder()->doRequest();
     $this->assertEquals(1, $query2->accepted);
     $this->assertEquals($this->notes, $query2->notes);
     //print_r($orderResponse->sveaOrderId);
 }
コード例 #6
0
 /** helper function, returns invoice for delivered order with one row, sent with PriceIncludingVat flag set to false */
 public function get_orderInfo_sent_ex_vat($amount, $vat, $quantity, $is_paymentplan = NULL)
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     if ($is_paymentplan) {
         $campaignCode = TestUtil::getGetPaymentPlanParamsForTesting();
     }
     $orderResponse = WebPay::createOrder($config)->addOrderRow(WebPayItem::orderRow()->setAmountExVat($amount)->setVatPercent($vat)->setQuantity($quantity))->addCustomerDetails(TestUtil::createIndividualCustomer("SE"))->setCountryCode("SE")->setOrderDate("2012-12-12");
     if ($is_paymentplan) {
         $orderResponse = $orderResponse->usePaymentPlanPayment($campaignCode)->doRequest();
     }
     $this->assertEquals(1, $orderResponse->accepted);
     if ($is_paymentplan) {
         $deliver = WebPay::deliverOrder($config)->setOrderId($orderResponse->sveaOrderId)->setCountryCode('SE')->deliverPaymentPlanOrder()->doRequest();
     }
     $this->assertEquals(1, $deliver->accepted);
     return new orderToCreditAmount($orderResponse->sveaOrderId, NULL, $deliver->contractNumber);
 }
コード例 #7
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
 }
 public function test_cancel_multiple_paymentplan_orderRows_()
 {
     // create order
     $country = "SE";
     $campaigncode = TestUtil::getGetPaymentPlanParamsForTesting();
     $order = TestUtil::createOrder(TestUtil::createIndividualCustomer($country))->addOrderRow(WebPayItem::orderRow()->setDescription("second row")->setQuantity(1)->setAmountExVat(1600.0)->setVatPercent(25))->addOrderRow(WebPayItem::orderRow()->setDescription("third row")->setQuantity(1)->setAmountExVat(2400.0)->setVatPercent(25));
     $orderResponse = $order->usePaymentPlanPayment($campaigncode)->doRequest();
     ////print_r( $orderResponse );
     $this->assertEquals(1, $orderResponse->accepted);
     $myOrderId = $orderResponse->sveaOrderId;
     // cancel first row in order
     $cancelOrderRowsRequest = WebPayAdmin::cancelOrderRows(Svea\SveaConfig::getDefaultConfig());
     $cancelOrderRowsRequest->setCountryCode($country);
     $cancelOrderRowsRequest->setOrderId($myOrderId);
     $cancelOrderRowsRequest->setRowsToCancel(array(1, 2));
     $cancelOrderRowsResponse = $cancelOrderRowsRequest->cancelPaymentPlanOrderRows()->doRequest();
     ////print_r( $cancelOrderRowsResponse );
     $this->assertInstanceOf('Svea\\AdminService\\CancelOrderRowsResponse', $cancelOrderRowsResponse);
     $this->assertEquals(1, $cancelOrderRowsResponse->accepted);
 }
コード例 #9
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");
 }
コード例 #10
0
 /**
  * test_manual_recurring_payment_step_1 
  * 
  * run this manually after you've performed a card transaction and have set
  * the transaction status to success using the tools in the logg admin.
  */
 public function test_manual_recurring_payment_step_1()
 {
     // Stop here and mark this test as incomplete.
     $this->markTestIncomplete('skeleton for manual test of recurring payment');
     // 1. remove (put in a comment) the above code to enable the test
     // 2. run the test, and get the subscription paymenturl from the output
     // 3. go to the paymenturl and complete the transaction.
     // 4. go to https://test.sveaekonomi.se/webpay-admin/admin/start.xhtml
     // 5. retrieve the subscriptionId from the response in the transaction log
     // 6. use the subscriptionId to run
     $orderLanguage = "sv";
     $returnUrl = "http://foo.bar.com";
     $ipAddress = "127.0.0.1";
     // create order
     $order = \TestUtil::createOrder(TestUtil::createIndividualCustomer("SE")->setIpAddress($ipAddress));
     // set payment method
     // call getPaymentURL
     $response = $order->usePayPageCardOnly()->setPayPageLanguage($orderLanguage)->setReturnUrl($returnUrl)->setSubscriptionType(Svea\HostedService\CardPayment::RECURRINGCAPTURE)->getPaymentUrl();
     // check that request was accepted
     $this->assertEquals(1, $response->accepted);
     // print the url to use to confirm the transaction
     //print_r( " test_manual_recurring_payment_step_1(): " . $response->testurl ." ");
 }
コード例 #11
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 ." ");
 }
コード例 #12
0
 function test_orderRow_discountPercent_50_percent_order_sent_as_incvat()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $orderResponse = WebPay::createOrder($config)->addOrderRow(WebPayItem::orderRow()->setAmountIncVat(125.0)->setVatPercent(25)->setQuantity(1)->setDiscountPercent(50))->addCustomerDetails(TestUtil::createIndividualCustomer("SE"))->setCountryCode("SE")->setOrderDate("2012-12-12")->useInvoicePayment()->doRequest();
     $this->assertEquals(1, $orderResponse->accepted);
     $this->assertEquals("62.50", $orderResponse->amount);
     // this is where
     $query = WebPayAdmin::queryOrder($config)->setCountryCode('SE')->setOrderId($orderResponse->sveaOrderId)->queryInvoiceOrder()->doRequest();
     $this->assertEquals(1, $query->accepted);
     $this->assertEquals(125.0, $query->numberedOrderRows[0]->amountIncVat);
     $this->assertEquals(25.0, $query->numberedOrderRows[0]->vatPercent);
     $this->assertEquals(50.0, $query->numberedOrderRows[0]->discountPercent);
 }
コード例 #13
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 ");
 }
コード例 #14
0
 /**
  * test_manual_CardPayment_getPaymentURL
  */
 public function test_CardPayment_getPaymentUrl_response_remake()
 {
     // Stop here and mark this test as incomplete.
     //        $this->markTestIncomplete(
     //            'skeleton for manual test of card payment'
     //        );
     // 1. remove (put in a comment) the above code to enable the test
     // 2. run the test, and get the subscription paymenturl from the output
     // 3. go to the paymenturl and complete the transaction.
     // 4. go to https://test.sveaekonomi.se/webpay-admin/admin/start.xhtml
     // 5. retrieve the transactionid from the response in the transaction log
     $orderLanguage = "sv";
     $returnUrl = "http://foo.bar.com";
     $ipAddress = "127.0.0.1";
     // create order
     $order = \TestUtil::createOrder(TestUtil::createIndividualCustomer("SE")->setIpAddress($ipAddress));
     // set payment method
     // call getPaymentURL
     $response = $order->setClientOrderNumber("foobar" . date('c'))->usePaymentMethod(\PaymentMethod::KORTCERT)->setPayPageLanguage($orderLanguage)->setReturnUrl($returnUrl)->getPaymentUrl();
     // check that request was accepted
     $this->assertEquals(1, $response->accepted);
     $this->assertEquals($response->testurl, $response->url);
     //url should always contain the url where the order is created in
     //and test is always test. In this case booth should therefore be test
 }
コード例 #15
0
 public function test_createOrder_Paymentplan_SE_Accepted()
 {
     $order = WebPay::createOrder(Svea\SveaConfig::getDefaultConfig())->addOrderRow(WebPayItem::orderRow()->setQuantity(1)->setAmountExVat(1000.0)->setVatPercent(25))->addCustomerDetails(TestUtil::createIndividualCustomer("SE"))->setCountryCode("SE")->setCurrency("SEK")->setOrderDate(date('c'));
     $response = $order->usePaymentPlanPayment(TestUtil::getGetPaymentPlanParamsForTesting())->doRequest();
     $this->assertEquals(1, $response->accepted);
 }
コード例 #16
0
 public function testOrderAndFixedDiscountSetWithMixedVat()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $order = WebPay::createOrder($config)->addOrderRow(WebPayItem::orderRow()->setAmountIncVat(123.9876)->setVatPercent(24)->setQuantity(1))->addDiscount(WebPayItem::fixedDiscount()->setAmountExVat(9.999000000000001))->addCustomerDetails(TestUtil::createIndividualCustomer("SE"))->setCountryCode("SE")->setOrderDate("2012-12-12");
     $request = $order->useInvoicePayment()->prepareRequest();
     $this->assertEquals(99.98999999999999, $request->request->CreateOrderInformation->OrderRows['OrderRow'][0]->PricePerUnit);
     $this->assertEquals(24, $request->request->CreateOrderInformation->OrderRows['OrderRow'][0]->VatPercent);
     $this->assertFalse($request->request->CreateOrderInformation->OrderRows['OrderRow'][0]->PriceIncludingVat);
     // 9.999 *1.24 = 12.39876
     $this->assertEquals(-9.999000000000001, $request->request->CreateOrderInformation->OrderRows['OrderRow'][1]->PricePerUnit);
     $this->assertEquals(24, $request->request->CreateOrderInformation->OrderRows['OrderRow'][1]->VatPercent);
     $this->assertFalse($request->request->CreateOrderInformation->OrderRows['OrderRow'][1]->PriceIncludingVat);
     // check that service accepts order
     $response = $order->useInvoicePayment()->doRequest();
     $this->assertEquals(true, $response->accepted);
 }
コード例 #17
0
 public function testCreateOrderWithDiscountAsAmountExAndDeliverWithAmountIncvat()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $campaigncode = TestUtil::getGetPaymentPlanParamsForTesting();
     $order = WebPay::createOrder($config)->addOrderRow(WebPayItem::orderRow()->setAmountIncVat(1239.876)->setVatPercent(24)->setQuantity(1))->addDiscount(WebPayItem::fixedDiscount()->setAmountIncVat(8)->setVatPercent(24))->addDiscount(WebPayItem::relativeDiscount()->setDiscountPercent(10))->addCustomerDetails(TestUtil::createIndividualCustomer("SE"))->setCountryCode("SE")->setOrderDate("2012-12-12")->usePaymentPlanPayment($campaigncode)->doRequest();
     $request = WebPay::deliverOrder($config);
     $request = $request->addOrderRow(WebPayItem::orderRow()->setAmountExVat(999.9)->setVatPercent(24)->setQuantity(1))->addDiscount(WebPayItem::fixedDiscount()->setAmountExVat(8)->setVatPercent(24))->addDiscount(WebPayItem::relativeDiscount()->setDiscountPercent(10))->setOrderId($order->sveaOrderId)->setInvoiceDistributionType(DistributionType::POST)->setCountryCode("SE")->deliverPaymentPlanOrder()->doRequest();
     $this->assertEquals(1, $request->accepted);
 }
コード例 #18
0
 function test_splitMeanAcrossTaxRates_8()
 {
     $discountAmount = 10.0;
     $discountGivenExVat = false;
     $discountMeanVatPercent = 16.0;
     $discountName = 'Name';
     $discountDescription = 'Description';
     $allowedTaxRates = array(25, 6);
     $discountRows = Helper::splitMeanAcrossTaxRates($discountAmount, $discountMeanVatPercent, $discountName, $discountDescription, $allowedTaxRates, $discountGivenExVat);
     $order = \WebPay::createOrder(SveaConfig::getDefaultConfig())->addOrderRow(\WebPayItem::orderRow()->setAmountExVat(100.0)->setVatPercent(25)->setQuantity(1))->addDiscount($discountRows[0])->addDiscount($discountRows[1])->addCustomerDetails(\TestUtil::createIndividualCustomer("SE"))->setCountryCode("SE")->setOrderDate("2012-12-12");
     $response = $order->useInvoicePayment()->doRequest();
     $this->assertEquals(1, $response->accepted);
     $this->assertEquals(115.0, $response->amount);
 }
コード例 #19
0
 public function test_getRequestTotals_reference_1321_00_ex_behaviour()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $order = WebPay::createOrder($config)->addOrderRow(WebPayItem::orderRow()->setAmountExVat(1321.0)->setVatPercent(6)->setQuantity(1))->addCustomerDetails(TestUtil::createIndividualCustomer("SE"))->setCountryCode("SE")->setOrderDate("2016-04-14");
     $preview_total = $order->useInvoicePayment()->getRequestTotals();
     $this->assertEquals(1400.26, $preview_total['total_incvat']);
     $this->assertEquals(1321.0, $preview_total['total_exvat']);
     $this->assertEquals(79.26000000000001, $preview_total['total_vat']);
 }
コード例 #20
0
 public function test_getRequestTotals_reference_1400_00_inc_cant_be_done_with_compensation_row()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $order = WebPay::createOrder($config)->addOrderRow(WebPayItem::orderRow()->setAmountIncVat(1400.0)->setVatPercent(6)->setQuantity(1))->addCustomerDetails(TestUtil::createIndividualCustomer("SE"))->setCountryCode("SE")->setOrderDate("2016-04-14");
     $preview_total = $order->useInvoicePayment()->getRequestTotals();
     $this->assertEquals(1400.0, $preview_total['total_incvat']);
     $this->assertEquals(1320.75, $preview_total['total_exvat']);
     $this->assertEquals(79.25, $preview_total['total_vat']);
     $target_total = 1400.0;
     $order->addDiscount(WebPayItem::fixedDiscount()->setAmountIncVat(-0.25)->setVatPercent(0));
     $compensated_preview_total = $order->useInvoicePayment()->getRequestTotals();
     $this->assertEquals(1400.25, $compensated_preview_total['total_incvat']);
     // should be 1400.00!
     $this->assertEquals(1321.0, $compensated_preview_total['total_exvat']);
     $this->assertEquals(79.25, $compensated_preview_total['total_vat']);
     $response = $order->useInvoicePayment()->doRequest();
     $this->assertEquals(1, $response->accepted);
     $this->assertEquals($compensated_preview_total['total_incvat'], $response->amount);
 }
コード例 #21
0
 function test_orderrow_response_exvat()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $orderResponse = WebPay::createOrder($config)->addOrderRow(WebPayItem::orderRow()->setAmountExVat(145.0)->setVatPercent(24)->setQuantity(1))->addCustomerDetails(TestUtil::createIndividualCustomer("SE"))->setCountryCode("SE")->setCurrency("SEK")->setOrderDate("2012-12-12")->useInvoicePayment()->doRequest();
     $response = WebPayAdmin::queryOrder($config)->setCountryCode('SE')->setOrderId($orderResponse->sveaOrderId)->queryInvoiceOrder()->doRequest();
     //print_r($response);
     $this->assertEquals(1, $response->accepted);
     $this->assertEquals(145.0, $response->numberedOrderRows[0]->amountExVat);
     $this->assertEquals(null, $response->numberedOrderRows[0]->amountIncVat);
 }
コード例 #22
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);
 }
 public function test_add_single_orderRow_type_mismatch_created_inc_updated_ex()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $orderResponse = WebPay::createOrder($config)->addOrderRow(WebPayItem::orderRow()->setAmountIncVat(123.9876)->setVatPercent(24)->setQuantity(1))->addCustomerDetails(TestUtil::createIndividualCustomer("SE"))->setCountryCode("SE")->setCurrency("SEK")->setOrderDate("2012-12-12")->useInvoicePayment()->doRequest();
     $this->assertEquals(1, $orderResponse->accepted);
     // query order and assert row totals
     $query = WebPayAdmin::queryOrder($config)->setOrderId($orderResponse->sveaOrderId)->setCountryCode('SE')->queryInvoiceOrder()->doRequest();
     $this->assertEquals(1, $query->accepted);
     $this->assertEquals("123.99", $query->numberedOrderRows[0]->amountIncVat);
     // sent 123.9876 inc => 123.99 queried
     $this->assertEquals("24", $query->numberedOrderRows[0]->vatPercent);
     $response = WebPayAdmin::updateOrderRows($config)->setCountryCode('SE')->setOrderId($orderResponse->sveaOrderId)->updateOrderRow(WebPayItem::numberedOrderRow()->setRowNumber(1)->setAmountExVat(99.98999999999999)->setVatPercent(24)->setQuantity(1))->updateInvoiceOrderRows()->doRequest();
     $this->assertEquals(1, $response->accepted);
     // query order and assert row totals
     $query2 = WebPayAdmin::queryOrder($config)->setOrderId($orderResponse->sveaOrderId)->setCountryCode('SE')->queryInvoiceOrder()->doRequest();
     $this->assertEquals(1, $query2->accepted);
     $this->assertEquals("123.99", $query2->numberedOrderRows[0]->amountIncVat);
     // sent 99.99 ex * 1.24 => sent 123.9876 inc => 123.99 queried
     $this->assertEquals("24", $query2->numberedOrderRows[0]->vatPercent);
     //print_r($orderResponse->sveaOrderId);
 }
コード例 #24
0
 public function testDiscountPercentAndVatPercentWhenPriceSetAsIncVatAndVatPercent()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $campaign = $this->getGetPaymentPlanParamsForTesting();
     $request = WebPay::createOrder($config)->addOrderRow(WebPayItem::orderRow()->setAmountIncVat(123.9876)->setVatPercent(24)->setQuantity(1))->addDiscount(WebPayItem::relativeDiscount()->setDiscountPercent(10))->addCustomerDetails(TestUtil::createIndividualCustomer("SE"))->setCountryCode("SE")->setOrderDate("2012-12-12")->useInvoicePayment()->prepareRequest();
     $this->assertEquals(123.9876, $request->request->CreateOrderInformation->OrderRows['OrderRow'][0]->PricePerUnit);
     $this->assertEquals(24, $request->request->CreateOrderInformation->OrderRows['OrderRow'][0]->VatPercent);
     $this->assertTrue($request->request->CreateOrderInformation->OrderRows['OrderRow'][0]->PriceIncludingVat);
     $this->assertEquals(-12.39876, $request->request->CreateOrderInformation->OrderRows['OrderRow'][1]->PricePerUnit);
     $this->assertEquals(24, $request->request->CreateOrderInformation->OrderRows['OrderRow'][1]->VatPercent);
     $this->assertTrue($request->request->CreateOrderInformation->OrderRows['OrderRow'][0]->PriceIncludingVat);
 }
コード例 #25
0
 public function test_createOrder_useInvoicePayment()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $request = WebPay::createOrder($config)->addOrderRow(WebPayItem::orderRow()->setAmountIncVat(123.9876)->setVatPercent(24)->setQuantity(1))->addCustomerDetails(TestUtil::createIndividualCustomer("SE"))->setCountryCode("SE")->setOrderDate("2012-12-12")->useInvoicePayment()->doRequest();
     $this->assertEquals(1, $request->accepted);
 }
コード例 #26
0
 public function test_deliverOrder_deliverPaymentPlanOrder_without_orderrows_use_DeliverOrderEU_and_is_accepted()
 {
     $order = WebPay::createOrder(Svea\SveaConfig::getDefaultConfig())->addOrderRow(WebPayItem::orderRow()->setQuantity(1)->setAmountExVat(1000.0)->setVatPercent(25))->addCustomerDetails(TestUtil::createIndividualCustomer("SE"))->setCountryCode("SE")->setCurrency("SEK")->setOrderDate(date('c'));
     $response = $order->usePaymentPlanPayment(TestUtil::getGetPaymentPlanParamsForTesting())->doRequest();
     $this->assertEquals(1, $response->accepted);
     $orderId = $response->sveaOrderId;
     $DeliverOrderBuilder = WebPay::deliverOrder(Svea\SveaConfig::getDefaultConfig())->setCountryCode("SE")->setOrderId($orderId);
     $response = $DeliverOrderBuilder->deliverPaymentPlanOrder()->doRequest();
     ////print_r( $response );
     $this->assertEquals(1, $response->accepted);
     $this->assertInstanceOf("Svea\\WebService\\DeliverOrderResult", $response);
 }