public function testPaymentPlanRequestReturnsAcceptedResult()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $campaigncode = TestUtil::getGetPaymentPlanParamsForTesting();
     $request = WebPay::createOrder($config)->addOrderRow(WebPayItem::orderRow()->setArticleNumber("1")->setQuantity(2)->setAmountExVat(1000.0)->setDescription("Specification")->setName('Prod')->setUnit("st")->setVatPercent(25)->setDiscountPercent(0))->addCustomerDetails(WebPayItem::individualCustomer()->setNationalIdNumber(194605092222)->setInitials("SB")->setBirthDate(1923, 12, 12)->setName("Tess", "Testson")->setEmail("*****@*****.**")->setPhoneNumber(999999)->setIpAddress("123.123.123")->setStreetAddress("Gatan", 23)->setCoAddress("c/o Eriksson")->setZipCode(9999)->setLocality("Stan"))->setCountryCode("SE")->setCustomerReference("33")->setClientOrderNumber("nr26")->setOrderDate("2012-12-12")->setCurrency("SEK")->usePaymentPlanPayment($campaigncode)->doRequest();
     $this->assertEquals(1, $request->accepted);
 }
 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);
 }
 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);
 }
 function test_CancelOrderBuilderRows_PaymentPlan_single_row_success()
 {
     $country = "SE";
     $order = TestUtil::createOrderWithoutOrderRows(TestUtil::createIndividualCustomer($country));
     $order->addOrderRow(TestUtil::createOrderRow(1000.0));
     $order->addOrderRow(TestUtil::createOrderRow(2000.0));
     $orderResponse = $order->usePaymentPlanPayment(TestUtil::getGetPaymentPlanParamsForTesting($country))->doRequest();
     $this->assertEquals(1, $orderResponse->accepted);
     $cancelBuilder = new \Svea\CancelOrderRowsBuilder(Svea\SveaConfig::getDefaultConfig());
     $cancelResponse = $cancelBuilder->setOrderId($orderResponse->sveaOrderId)->setCountryCode($country)->setRowToCancel(2)->cancelPaymentPlanOrderRows()->doRequest();
     $this->assertEquals(1, $cancelResponse->accepted);
 }
 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
 }
 /** 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);
 }
 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);
 }
 public function test_deliverOrder_deliverPaymentPlanOrder_with_orderrows_misleadingly_delivers_order_in_full()
 {
     // create order
     $config = Svea\SveaConfig::getDefaultConfig();
     $campaigncode = TestUtil::getGetPaymentPlanParamsForTesting();
     $order = WebPay::createOrder($config)->addOrderRow(WebPayItem::orderRow()->setArticleNumber("1")->setQuantity(2)->setAmountExVat(1000.0)->setDescription("Specification")->setName('Prod')->setUnit("st")->setVatPercent(25)->setDiscountPercent(0))->addOrderRow(WebPayItem::orderRow()->setArticleNumber("2")->setQuantity(2)->setAmountExVat(1000.0)->setDescription("Specification")->setName('Prod')->setUnit("st")->setVatPercent(25)->setDiscountPercent(0))->addCustomerDetails(WebPayItem::individualCustomer()->setNationalIdNumber(194605092222)->setInitials("SB")->setBirthDate(1923, 12, 12)->setName("Tess", "Testson")->setEmail("*****@*****.**")->setPhoneNumber(999999)->setIpAddress("123.123.123")->setStreetAddress("Gatan", 23)->setCoAddress("c/o Eriksson")->setZipCode(9999)->setLocality("Stan"))->setCountryCode("SE")->setCustomerReference("33")->setClientOrderNumber("nr26")->setOrderDate("2012-12-12")->setCurrency("SEK")->usePaymentPlanPayment($campaigncode)->doRequest();
     //print_r($order);
     $this->assertEquals(1, $order->accepted);
     $this->assertEquals(5000, $order->amount);
     // deliver order
     $orderId = $order->sveaOrderId;
     $orderBuilder = WebPay::deliverOrder($config);
     $deliverResponse = $orderBuilder->addOrderRow(WebPayItem::orderRow()->setArticleNumber("1")->setQuantity(2)->setAmountExVat(1000.0)->setDescription("Specification")->setName('Prod')->setUnit("st")->setVatPercent(25)->setDiscountPercent(0))->setOrderId($orderId)->setInvoiceDistributionType("Post")->setCountryCode("SE")->deliverPaymentPlanOrder()->doRequest();
     //print_r($deliverResponse);
     $this->assertEquals(1, $deliverResponse->accepted);
     $this->assertEquals(5000, $deliverResponse->amount);
 }
 function test_AddOrderRows_addPaymentPlanOrderRows_multiple_rows_success()
 {
     $country = "SE";
     $order = TestUtil::createOrderWithoutOrderRows(TestUtil::createIndividualCustomer($country));
     $order->addOrderRow(TestUtil::createOrderRow(1000.0, 1));
     $orderResponse = $order->usePaymentPlanPayment(TestUtil::getGetPaymentPlanParamsForTesting())->doRequest();
     $this->assertEquals(1, $orderResponse->accepted);
     $b_quantity = 1;
     $b_amountExVat = 100.0;
     $b_vatPercent = 12;
     $b_articleNumber = "1071e";
     $b_unit = "pcs.";
     $b_name = "B Name";
     $b_description = "B Description";
     $b_discount = 0;
     $addOrderRowsBuilder = new \Svea\AddOrderRowsBuilder(Svea\SveaConfig::getDefaultConfig());
     $addOrderRowsResponse = $addOrderRowsBuilder->setOrderId($orderResponse->sveaOrderId)->setCountryCode($country)->addOrderRow(TestUtil::createOrderRow(2.0, 1))->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))->addPaymentPlanOrderRows()->doRequest();
     $this->assertEquals(1, $addOrderRowsResponse->accepted);
     $createdOrderId = $orderResponse->sveaOrderId;
     ////print_r("test_AddOrderRows_addPaymentPlanOrderRows_multiple_rows_success: "); //print_r( $createdOrderId );
     // query orderrows
     $queryOrderBuilder = WebPayAdmin::queryOrder(Svea\SveaConfig::getDefaultConfig())->setOrderId($createdOrderId)->setCountryCode($country);
     $queryResponse = $queryOrderBuilder->queryPaymentPlanOrder()->doRequest();
     ////print_r( $queryResponse);
     $this->assertEquals(1, $queryResponse->accepted);
     // assert that order rows are the same
     $this->assertEquals($b_quantity, $queryResponse->numberedOrderRows[2]->quantity);
     $this->assertEquals($b_amountExVat, $queryResponse->numberedOrderRows[2]->amountExVat);
     $this->assertEquals($b_vatPercent, $queryResponse->numberedOrderRows[2]->vatPercent);
     $this->assertEquals($b_articleNumber, $queryResponse->numberedOrderRows[2]->articleNumber);
     $this->assertEquals($b_unit, $queryResponse->numberedOrderRows[2]->unit);
     $this->assertStringStartsWith($b_name, $queryResponse->numberedOrderRows[2]->description);
     $this->assertStringEndsWith($b_description, $queryResponse->numberedOrderRows[2]->description);
     $this->assertEquals($b_discount, $queryResponse->numberedOrderRows[2]->discountPercent);
     $this->assertEquals("NotDelivered", $queryResponse->numberedOrderRows[2]->status);
     $this->assertEquals(3, $queryResponse->numberedOrderRows[2]->rowNumber);
 }
Exemplo n.º 10
0
 public function test_createOrder_usePaymentPlanPayment_allows_orderRow_with_zero_amount()
 {
     $createOrder = WebPay::createOrder(Svea\SveaConfig::getDefaultConfig())->addOrderRow(WebPayItem::orderRow()->setQuantity(0.0)->setAmountIncVat(0.0)->setVatPercent(0))->addCustomerDetails(WebPayItem::individualCustomer()->setNationalIdNumber("4605092222"))->setCountryCode("SE")->setOrderDate(date('c'));
     $request = $createOrder->usePaymentPlanPayment(TestUtil::getGetPaymentPlanParamsForTesting());
     // prepareRequest() validates the order and throws SveaWebPayException on validation failure
     try {
         $request->prepareRequest();
     } catch (Exception $e) {
         // fail on validation error
         $this->fail("Unexpected validation exception: " . $e->getMessage());
     }
 }
 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);
 }
 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);
 }
 /**
  *  test_queryOrder_queryPaymentPlanOrder_order
  */
 function test_queryOrder_queryPaymentPlanOrder_order()
 {
     // 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 = "1071e";
     $b_unit = "pcs.";
     $b_name = "B Name";
     $b_description = "B Description";
     $b_discount = 0;
     $order = TestUtil::createOrderWithoutOrderRows(TestUtil::createIndividualCustomer($country))->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));
     $orderResponse = $order->usePaymentPlanPayment(TestUtil::getGetPaymentPlanParamsForTesting())->doRequest();
     $this->assertEquals(1, $orderResponse->accepted);
     $createdOrderId = $orderResponse->sveaOrderId;
     // query orderrows
     $queryOrderBuilder = WebPayAdmin::queryOrder(Svea\SveaConfig::getDefaultConfig())->setOrderId($createdOrderId)->setCountryCode($country);
     $queryResponse = $queryOrderBuilder->queryPaymentPlanOrder()->doRequest();
     ////print_r( $queryResponse);
     $this->assertEquals(1, $queryResponse->accepted);
     // assert that order rows are the same
     $this->assertEquals($a_quantity, $queryResponse->numberedOrderRows[0]->quantity);
     $this->assertEquals($a_amountExVat, $queryResponse->numberedOrderRows[0]->amountExVat);
     $this->assertEquals($b_quantity, $queryResponse->numberedOrderRows[1]->quantity);
     $this->assertEquals($b_amountExVat, $queryResponse->numberedOrderRows[1]->amountExVat);
     $this->assertEquals($b_vatPercent, $queryResponse->numberedOrderRows[1]->vatPercent);
     $this->assertEquals($b_articleNumber, $queryResponse->numberedOrderRows[1]->articleNumber);
     $this->assertEquals($b_unit, $queryResponse->numberedOrderRows[1]->unit);
     $this->assertStringStartsWith($b_name, $queryResponse->numberedOrderRows[1]->description);
     $this->assertStringEndsWith($b_description, $queryResponse->numberedOrderRows[1]->description);
     $this->assertEquals($b_discount, $queryResponse->numberedOrderRows[1]->discountPercent);
     $this->assertEquals(null, $queryResponse->numberedOrderRows[1]->creditInvoiceId);
     // not set
     $this->assertEquals(null, $queryResponse->numberedOrderRows[1]->invoiceId);
     // not set
     $this->assertEquals(2, $queryResponse->numberedOrderRows[1]->rowNumber);
     // rows are 1-indexed
     $this->assertEquals("NotDelivered", $queryResponse->numberedOrderRows[1]->status);
 }
 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);
 }