/**
  * @expectedException Svea\ValidationException
  * @expectedExceptionMessage -missing value : InvoiceDistributionType is required for deliverInvoiceOrder. Use function setInvoiceDistributionType().
  */
 public function testFailOnMissingInvoiceDetailsOnInvoiceDeliver()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $builder = WebPay::deliverOrder($config);
     $object = $builder->addOrderRow(TestUtil::createOrderRow())->addFee(WebPayItem::shippingFee()->setShippingId('33')->setName('shipping')->setDescription("Specification")->setAmountExVat(50)->setUnit("st")->setVatPercent(25)->setDiscountPercent(0))->setOrderId('id')->deliverInvoiceOrder();
     $object->prepareRequest();
 }
Exemplo n.º 2
0
 public function testOrderWithSEConfigFromFunction()
 {
     $request = \WebPay::createOrder(SveaConfig::getTestConfig())->addOrderRow(\TestUtil::createOrderRow())->addCustomerDetails(\WebPayItem::individualCustomer()->setNationalIdNumber(194605092222))->setCountryCode("SE")->setCustomerReference("33")->setOrderDate("2012-12-12")->setCurrency("SEK")->useInvoicePayment()->prepareRequest();
     $this->assertEquals("sverigetest", $request->request->Auth->Username);
     $this->assertEquals("sverigetest", $request->request->Auth->Password);
     $this->assertEquals(79021, $request->request->Auth->ClientNumber);
 }
 public function testPaymentMethodInvoiceNLCallbackUrl()
 {
     $config = SveaConfig::getDefaultConfig();
     $form = \WebPay::createOrder($config)->addOrderRow(\TestUtil::createOrderRow())->addCustomerDetails(\WebPayItem::individualCustomer()->setInitials("SB")->setBirthDate(1923, 12, 12)->setName("Sneider", "Boasman")->setEmail("*****@*****.**")->setPhoneNumber(999999)->setIpAddress("123.123.123")->setStreetAddress("Gatan", 23)->setCoAddress("c/o Eriksson")->setZipCode(9999)->setLocality("Stan"))->setCountryCode("NL")->setClientOrderNumber("33")->setOrderDate("2012-12-12")->setCurrency("SEK")->usePaymentMethod(\PaymentMethod::INVOICE)->setReturnUrl("http://myurl.se")->setCallbackUrl("http://myurl.se")->getPaymentForm();
     $xmlMessage = new \SimpleXMLElement($form->xmlMessage);
     $this->assertEquals("http://myurl.se", $xmlMessage->callbackurl);
 }
 public function test_createOrder_usePaymentMethod_KORTCERT_redirects_to_certitrade()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $rowFactory = new TestUtil();
     $form = WebPay::createOrder($config)->addOrderRow(TestUtil::createOrderRow())->run($rowFactory->buildShippingFee())->addDiscount(WebPayItem::relativeDiscount()->setDiscountId("1")->setDiscountPercent(50)->setUnit("st")->setName('Relative')->setDescription("RelativeDiscount"))->setCountryCode("SE")->setClientOrderNumber("foobar" . date('c'))->setOrderDate("2012-12-12")->setCurrency("SEK")->usePaymentMethod(PaymentMethod::KORTCERT)->setReturnUrl("http://myurl.se")->getPaymentForm();
     $url = "https://test.sveaekonomi.se/webpay/payment";
     /** CURL  **/
     $fields = array('merchantid' => urlencode($form->merchantid), 'message' => urlencode($form->xmlMessageBase64), 'mac' => urlencode($form->mac));
     $fieldsString = "";
     foreach ($fields as $key => $value) {
         $fieldsString .= $key . '=' . $value . '&';
     }
     rtrim($fieldsString, '&');
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_POST, count($fields));
     curl_setopt($ch, CURLOPT_POSTFIELDS, $fieldsString);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
     // follow redirects
     curl_setopt($ch, CURLOPT_HEADER, true);
     // include headers in transfer history
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     // return transfer history
     $cr = curl_exec($ch);
     $info = curl_getinfo($ch);
     curl_close($ch);
     $this->assertEquals(200, $info['http_code']);
     $this->assertEquals(1, $info['redirect_count']);
     $this->assertEquals("https://etest.certitrade.net/card/paywin/index", substr($info['url'], 0, 46));
 }
 /**
  * @expectedException Svea\ValidationException
  */
 public function testDeliverInvoiceOrder_missing_setInvoiceDistributionType_throws_ValidationException()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $orderId = $this->getInvoiceOrderId();
     $orderBuilder = WebPay::deliverOrder($config);
     $request = $orderBuilder->addOrderRow(TestUtil::createOrderRow())->setOrderId($orderId)->setNumberOfCreditDays(1)->setCountryCode("SE")->deliverInvoiceOrder()->doRequest();
 }
Exemplo n.º 6
0
 public function testPaymentPlanRequestObjectSpecifics()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $rowFactory = new TestUtil();
     $request = WebPay::createOrder($config)->addOrderRow(TestUtil::createOrderRow())->run($rowFactory->buildShippingFee())->addCustomerDetails(WebPayItem::individualCustomer()->setNationalIdNumber(194605092222))->setCountryCode("SE")->setCustomerReference("33")->setClientOrderNumber("nr26")->setOrderDate("2012-12-12")->setCurrency("SEK")->usePaymentPlanPayment("camp1")->prepareRequest();
     $this->assertEquals('camp1', $request->request->CreateOrderInformation->CreatePaymentPlanDetails['CampaignCode']);
     $this->assertEquals(0, $request->request->CreateOrderInformation->CreatePaymentPlanDetails['SendAutomaticGiroPaymentForm']);
 }
 public function testBuildDirectBankPaymentCallBackUrl()
 {
     $config = SveaConfig::getDefaultConfig();
     $rowFactory = new \TestUtil();
     $form = \WebPay::createOrder($config)->addOrderRow(\TestUtil::createOrderRow())->addCustomerDetails(\WebPayItem::individualCustomer()->setNationalIdNumber(194605092222))->setCountryCode("SE")->setClientOrderNumber("33")->setOrderDate("2012-12-12")->setCurrency("SEK")->usePayPageDirectBankOnly()->setReturnUrl("http://myurl.se")->setCallbackUrl("http://myurl.se")->getPaymentForm();
     $xmlMessage = new \SimpleXMLElement($form->xmlMessage);
     $this->assertEquals("http://myurl.se", $xmlMessage->callbackurl);
 }
 public function testpayPagePaymentIncludePaymentMethods()
 {
     $config = SveaConfig::getDefaultConfig();
     $rowFactory = new \TestUtil();
     $form = \WebPay::createOrder($config)->addOrderRow(\TestUtil::createOrderRow())->run($rowFactory->buildShippingFee())->addDiscount(\WebPayItem::relativeDiscount()->setDiscountId("1")->setDiscountPercent(50)->setUnit("st")->setName('Relative')->setDescription("RelativeDiscount"))->addCustomerDetails(\WebPayItem::individualCustomer()->setNationalIdNumber(194605092222))->setCountryCode("SE")->setClientOrderNumber("33")->setOrderDate("2012-12-12")->setCurrency("SEK")->usePayPage()->setReturnUrl("http://myurl.se")->includePaymentMethods(\PaymentMethod::KORTCERT, \PaymentMethod::SKRILL)->getPaymentForm();
     $xmlMessage = new \SimpleXMLElement($form->xmlMessage);
     //check to see if the first value is one of the excluded ones
     $this->assertEquals(SystemPaymentMethod::BANKAXESS, $xmlMessage->excludepaymentmethods->exclude[0]);
 }
Exemplo n.º 9
0
 public function testCardPaymentForEngCustomer()
 {
     $config = SveaConfig::getDefaultConfig();
     $rowFactory = new \TestUtil();
     $form = \WebPay::createOrder($config)->addOrderRow(\TestUtil::createOrderRow())->setCountryCode("SE")->setClientOrderNumber("33")->setOrderDate("2012-12-12")->setCurrency("GBP")->usePayPageCardOnly()->setReturnUrl("http://myurl.se")->getPaymentForm();
     $xmlMessage = new \SimpleXMLElement($form->xmlMessage);
     $payment = base64_decode($form->xmlMessageBase64);
     $payment_decoded = new \SimpleXMLElement($payment);
     //test values are as expected avter transforming xml to php object
     $this->assertEquals('GBP', $xmlMessage->currency);
 }
 public function testDeliverPaymentPlanOrder()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $orderId = $this->getPaymentPlanOrderId();
     $orderBuilder = WebPay::deliverOrder($config);
     $request = $orderBuilder->addOrderRow(TestUtil::createOrderRow(1000.0, 1))->setOrderId($orderId)->setCountryCode("SE")->deliverPaymentPlanOrder()->doRequest();
     $this->assertEquals(1, $request->accepted);
     $this->assertEquals(0, $request->resultcode);
     $this->assertEquals(1250, $request->amount);
     $this->assertEquals('PaymentPlan', $request->orderType);
 }
Exemplo n.º 11
0
 public function testBuildOrderWithInvoicefee()
 {
     $rowFactory = new \TestUtil();
     $config = SveaConfig::getDefaultConfig();
     $sveaRequest = \WebPay::createOrder($config)->addOrderRow(\TestUtil::createOrderRow())->run($rowFactory->buildInvoiceFee());
     $this->assertEquals("Svea fee", $sveaRequest->invoiceFeeRows[0]->name);
     $this->assertEquals("Fee for invoice", $sveaRequest->invoiceFeeRows[0]->description);
     $this->assertEquals(50, $sveaRequest->invoiceFeeRows[0]->amountExVat);
     $this->assertEquals("st", $sveaRequest->invoiceFeeRows[0]->unit);
     $this->assertEquals(25, $sveaRequest->invoiceFeeRows[0]->vatPercent);
     $this->assertEquals(0, $sveaRequest->invoiceFeeRows[0]->discountPercent);
 }
 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);
 }
 public function test_generate_prepareRequest_addOrderRowsSoapRequest()
 {
     // Stop here and mark this test as incomplete.
     $this->markTestIncomplete('run once to generate testdata for prepareRequest_addOrderRowsSoapRequest()');
     // add order rows to builderobject
     $this->builderObject->orderRows[] = TestUtil::createOrderRow(1.0, 1);
     $this->builderObject->orderId = 123456;
     $addOrderRowsRequest = new Svea\AdminService\AddOrderRowsRequest($this->builderObject);
     $addOrderRowsSoapRequest = $addOrderRowsRequest->prepareRequest();
     // used once to get data for addOrderRowsRequest() below
     //print_r( "\ncopy the following to prepareRequest_addOrderRowsSoapRequest:\n\n".serialize($addOrderRowsSoapRequest)."\n\n" );
 }
 public function test_add_single_orderRow()
 {
     $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();
     $this->assertEquals(1, $orderResponse->accepted);
     // add order rows to builderobject
     $this->builderObject->orderRows[] = TestUtil::createOrderRow(1.0, 1);
     $this->builderObject->orderId = $orderResponse->sveaOrderId;
     $addOrderRowsRequest = new Svea\AdminService\AddOrderRowsRequest($this->builderObject);
     $addOrderRowsResponse = $addOrderRowsRequest->doRequest();
     $this->assertInstanceOf('Svea\\AdminService\\AddOrderRowsResponse', $addOrderRowsResponse);
     $this->assertEquals(1, $addOrderRowsResponse->accepted);
 }
 public function test_deliverOrder_deliverInvoiceOrder_with_orderrows_use_DeliverOrderEU_and_is_accepted()
 {
     // create order, get orderid to deliver
     $createOrderBuilder = TestUtil::createOrder();
     $response = $createOrderBuilder->useInvoicePayment()->doRequest();
     $this->assertEquals(1, $response->accepted);
     $orderId = $response->sveaOrderId;
     $DeliverOrderBuilder = WebPay::deliverOrder(Svea\SveaConfig::getDefaultConfig())->addOrderRow(TestUtil::createOrderRow())->setCountryCode("SE")->setOrderId($orderId)->setInvoiceDistributionType(\DistributionType::POST);
     $response = $DeliverOrderBuilder->deliverInvoiceOrder()->doRequest();
     ////print_r( $response );
     $this->assertEquals(1, $response->accepted);
     $this->assertInstanceOf("Svea\\WebService\\DeliverOrderResult", $response);
     // deliverOrderResult => deliverOrderEU
 }
 public function test_GetOrdersRequest_for_invoice_sets_company_customer_correctly()
 {
     // create order
     $country = "SE";
     $order = TestUtil::createOrder(TestUtil::createCompanyCustomer($country));
     //case( "SE" ):
     //    return WebPayItem::companyCustomer()
     //        ->setNationalIdNumber("4608142222")
     //        ->setCompanyName("Tess T", "Persson")
     //        ->setStreetAddress("Testgatan", 1)
     //        ->setCoAddress("c/o Eriksson, Erik")
     //        ->setLocality("Stan")
     //        ->setZipCode("99999");
     //    break;
     $order->addOrderRow(TestUtil::createOrderRow(1000.0));
     $orderResponse = $order->useInvoicePayment()->doRequest();
     $this->assertEquals(1, $orderResponse->accepted);
     $countryCode = "SE";
     $sveaOrderIdToGet = $orderResponse->sveaOrderId;
     $orderType = ConfigurationProvider::INVOICE_TYPE;
     $getOrdersBuilder = new Svea\QueryOrderBuilder(Svea\SveaConfig::getDefaultConfig());
     $getOrdersBuilder->setOrderId($sveaOrderIdToGet);
     $getOrdersBuilder->setCountryCode($countryCode);
     $getOrdersBuilder->orderType = $orderType;
     $request = new Svea\AdminService\GetOrdersRequest($getOrdersBuilder);
     $getOrdersResponse = $request->doRequest();
     // Example test_GetOrdersRequest_for_invoice_company_customer_order raw request response
     //
     //stdClass Object
     //(
     //      /.../
     //                    [Customer] => stdClass Object
     //                        (
     //                            [CoAddress] => c/o Eriksson, Erik
     //                            [CompanyIdentity] => stdClass Object
     //                                (
     //                                    [CompanyIdentification] =>
     //                                    [CompanyVatNumber] =>
     //                                )
     //
     //                            [CountryCode] => SE
     //                            [CustomerType] => Company
     //                            [Email] =>
     //                            [FullName] => Persson, Tess T
     //                            [HouseNumber] =>
     //                            [IndividualIdentity] =>
     //                            [Locality] => Stan
     //                            [NationalIdNumber] => 164608142222
     //                            [PhoneNumber] =>
     //                            [PublicKey] =>
     //                            [Street] => Testgatan 1
     //                            [ZipCode] => 99999
     //                        )
     //      /.../
     // )
     ////print_r( $getOrdersResponse );
     $this->assertInstanceOf('Svea\\AdminService\\GetOrdersResponse', $getOrdersResponse);
     $this->assertEquals(1, $getOrdersResponse->accepted);
     $this->assertEquals(0, $getOrdersResponse->resultcode);
     $this->assertEquals(null, $getOrdersResponse->errormessage);
     $this->assertInstanceOf("Svea\\CompanyCustomer", $getOrdersResponse->customer);
     $this->assertEquals("194608142222", $getOrdersResponse->customer->orgNumber);
     $this->assertEquals(null, $getOrdersResponse->customer->companyVatNumber);
     $this->assertEquals("Persson, Tess T", $getOrdersResponse->customer->companyName);
     $this->assertEquals(null, $getOrdersResponse->customer->email);
     $this->assertEquals(null, $getOrdersResponse->customer->phonenumber);
     $this->assertEquals("Testgatan 1", $getOrdersResponse->customer->streetAddress);
     $this->assertEquals("Testgatan 1", $getOrdersResponse->customer->street);
     $this->assertEquals("c/o Eriksson, Erik", $getOrdersResponse->customer->coAddress);
     $this->assertEquals("99999", $getOrdersResponse->customer->zipCode);
     $this->assertEquals("Stan", $getOrdersResponse->customer->locality);
 }
 public function test_addOrderRowsBuilder_addPaymentPlanOrderRowsBuilder_returns_AddOrderRowsRequest()
 {
     $orderId = "123456";
     $addOrderRowsObject = $this->addOrderRowsObject->setOrderId($orderId)->addOrderRow(\TestUtil::createOrderRow(1.0))->addPaymentPlanOrderRows();
     $this->assertInstanceOf("Svea\\AdminService\\AddOrderRowsRequest", $addOrderRowsObject);
 }
 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);
 }
 public function testBuildOrderWithCompanyCustomerDE()
 {
     $config = SveaConfig::getDefaultConfig();
     $request = \WebPay::createOrder($config);
     $request = $request->addOrderRow(\TestUtil::createOrderRow())->addCustomerDetails(\WebPayItem::companyCustomer()->setVatNumber("SE666666")->setCompanyName("MyCompany")->setEmail("*****@*****.**")->setPhoneNumber(999999)->setIpAddress("123.123.123")->setStreetAddress("Gatan", 23)->setCoAddress("c/o Eriksson")->setZipCode(9999)->setLocality("Stan"));
     $request = $request->setCountryCode("DE")->setCustomerReference("33")->setOrderDate("2012-12-12")->setCurrency("EUR")->useInvoicePayment()->prepareRequest();
     $this->assertEquals("SE666666", $request->request->CreateOrderInformation->CustomerIdentity->CompanyIdentity->CompanyVatNumber);
     $this->assertEquals("Company", $request->request->CreateOrderInformation->CustomerIdentity->CustomerType);
     $this->assertEquals("MyCompany", $request->request->CreateOrderInformation->CustomerIdentity->FullName);
 }
Exemplo n.º 20
0
 public function testInvoiceRequestObjectWithAuth()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $rowFactory = new TestUtil();
     $request = WebPay::createOrder($config)->addOrderRow(TestUtil::createOrderRow())->run($rowFactory->buildShippingFee())->addCustomerDetails(WebPayItem::companyCustomer()->setNationalIdNumber(194605092222)->setAddressSelector("ad33"))->setCountryCode("SE")->setCustomerReference("33")->setClientOrderNumber("nr26")->setOrderDate("2012-12-12")->setCurrency("SEK")->useInvoicePayment()->prepareRequest();
     $this->assertEquals('sverigetest', $request->request->Auth->Username);
     $this->assertEquals('sverigetest', $request->request->Auth->Password);
     $this->assertEquals(79021, $request->request->Auth->ClientNumber);
 }
Exemplo n.º 21
0
 public function testDeliverOrderWithShippingFeeAndRelativeDiscount()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $request = WebPay::deliverOrder($config);
     $request = $request->addOrderRow(TestUtil::createOrderRow())->addFee(WebPayItem::shippingFee()->setShippingId(1)->setName('shipping')->setDescription("Specification")->setAmountExVat(50)->setUnit("st")->setVatPercent(25)->setDiscountPercent(0))->addDiscount(WebPayItem::relativeDiscount()->setDiscountId("1")->setDiscountPercent(50)->setUnit("st")->setName('Relative')->setDescription("RelativeDiscount"));
     $request = $request->setOrderId("id")->setNumberOfCreditDays(1)->setInvoiceDistributionType(DistributionType::POST)->setCreditInvoice("id")->setCountryCode("SE")->deliverInvoiceOrder()->prepareRequest();
     $this->assertEquals(1, $request->request->DeliverOrderInformation->DeliverInvoiceDetails->OrderRows['OrderRow'][0]->ArticleNumber);
     $this->assertEquals("Product: Specification", $request->request->DeliverOrderInformation->DeliverInvoiceDetails->OrderRows['OrderRow'][0]->Description);
     $this->assertEquals(100.0, $request->request->DeliverOrderInformation->DeliverInvoiceDetails->OrderRows['OrderRow'][0]->PricePerUnit);
     $this->assertEquals(2, $request->request->DeliverOrderInformation->DeliverInvoiceDetails->OrderRows['OrderRow'][0]->NumberOfUnits);
     $this->assertEquals("st", $request->request->DeliverOrderInformation->DeliverInvoiceDetails->OrderRows['OrderRow'][0]->Unit);
     $this->assertEquals(25, $request->request->DeliverOrderInformation->DeliverInvoiceDetails->OrderRows['OrderRow'][0]->VatPercent);
     $this->assertEquals(0, $request->request->DeliverOrderInformation->DeliverInvoiceDetails->OrderRows['OrderRow'][0]->DiscountPercent);
     //shipping
     $this->assertEquals(1, $request->request->DeliverOrderInformation->DeliverInvoiceDetails->OrderRows['OrderRow'][1]->ArticleNumber);
     $this->assertEquals(1, $request->request->DeliverOrderInformation->DeliverInvoiceDetails->OrderRows['OrderRow'][1]->NumberOfUnits);
     $this->assertEquals(50.0, $request->request->DeliverOrderInformation->DeliverInvoiceDetails->OrderRows['OrderRow'][1]->PricePerUnit);
     $this->assertEquals("shipping: Specification", $request->request->DeliverOrderInformation->DeliverInvoiceDetails->OrderRows['OrderRow'][1]->Description);
     $this->assertEquals("st", $request->request->DeliverOrderInformation->DeliverInvoiceDetails->OrderRows['OrderRow'][1]->Unit);
     $this->assertEquals(25, $request->request->DeliverOrderInformation->DeliverInvoiceDetails->OrderRows['OrderRow'][1]->VatPercent);
     $this->assertEquals(0, $request->request->DeliverOrderInformation->DeliverInvoiceDetails->OrderRows['OrderRow'][1]->DiscountPercent);
     //relative discount
     $this->assertEquals("1", $request->request->DeliverOrderInformation->DeliverInvoiceDetails->OrderRows['OrderRow'][2]->ArticleNumber);
     $this->assertEquals(1, $request->request->DeliverOrderInformation->DeliverInvoiceDetails->OrderRows['OrderRow'][2]->NumberOfUnits);
     $this->assertEquals(-100.0, $request->request->DeliverOrderInformation->DeliverInvoiceDetails->OrderRows['OrderRow'][2]->PricePerUnit);
     $this->assertEquals("Relative: RelativeDiscount", $request->request->DeliverOrderInformation->DeliverInvoiceDetails->OrderRows['OrderRow'][2]->Description);
     $this->assertEquals("st", $request->request->DeliverOrderInformation->DeliverInvoiceDetails->OrderRows['OrderRow'][2]->Unit);
     $this->assertEquals(25, $request->request->DeliverOrderInformation->DeliverInvoiceDetails->OrderRows['OrderRow'][2]->VatPercent);
     $this->assertEquals(0, $request->request->DeliverOrderInformation->DeliverInvoiceDetails->OrderRows['OrderRow'][2]->DiscountPercent);
 }
 function test_validates_all_required_methods_for_creditOrderRows_creditCardOrderRows()
 {
     $request = WebPayAdmin::creditOrderRows(Svea\SveaConfig::getDefaultConfig())->setOrderId("123456")->setCountryCode("SE")->addCreditOrderRow(TestUtil::createOrderRow())->addCreditOrderRows(array(TestUtil::createOrderRow(), TestUtil::createOrderRow()))->setRowToCredit(1)->setRowsToCredit(array(2, 3))->addNumberedOrderRow(TestUtil::createNumberedOrderRow(100.0, 1, 1))->addNumberedOrderRows(array(TestUtil::createNumberedOrderRow(100.0, 1, 2), TestUtil::createNumberedOrderRow(100.0, 1, 3)));
     try {
         $request->creditCardOrderRows()->prepareRequest();
     } catch (Exception $e) {
         // fail on validation error
         $this->fail("Unexpected validation exception: " . $e->getMessage());
     }
 }
 public function testInvoiceRequestNLReproduceErrorIn471193()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $request = WebPay::createOrder($config)->addOrderRow(TestUtil::createOrderRow())->addCustomerDetails(WebPayItem::individualCustomer()->setBirthDate(1955, 03, 07)->setZipCode("1102 HG")->setName("foo", "bar")->setStreetAddress("foo", "bar")->setCoAddress(1337)->setLocality("dns")->setInitials("nsl"))->setCountryCode("NL")->setCustomerReference("33")->setOrderDate("2012-12-12")->setCurrency("SEK")->useInvoicePayment()->doRequest();
     //->prepareRequest();
     //var_dump($request->request->CreateOrderInformation->CustomerIdentity);
     $this->assertEquals(1, $request->accepted);
     $this->assertTrue($request->customerIdentity instanceof Svea\WebService\CreateOrderIdentity);
     //print_r( $request->sveaOrderId);
     // verify returned address is wrong
     $this->assertNotEquals("Sneider Boasman", $request->customerIdentity->fullName);
     $this->assertNotEquals("Gate 42", $request->customerIdentity->street);
     $this->assertNotEquals("23", $request->customerIdentity->houseNumber);
     $this->assertNotEquals("BARENDRECHT", $request->customerIdentity->locality);
     //$this->assertNotEquals( "1102 HG", $request->customerIdentity->zipCode );
     $this->assertEquals("foo bar", $request->customerIdentity->fullName);
     $this->assertEquals("foo", $request->customerIdentity->street);
     $this->assertEquals("bar", $request->customerIdentity->houseNumber);
     $this->assertEquals("dns", $request->customerIdentity->locality);
     $this->assertEquals("1102 HG", $request->customerIdentity->zipCode);
     //<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://webservices.sveaekonomi.se/webpay" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     //  <SOAP-ENV:Body>
     //    <ns1:CreateOrderEu>
     //      <ns1:request>
     //        <ns1:Auth>
     //          <ns1:ClientNumber>85997</ns1:ClientNumber>
     //          <ns1:Username>hollandtest</ns1:Username>
     //          <ns1:Password>hollandtest</ns1:Password>
     //        </ns1:Auth>
     //        <ns1:CreateOrderInformation>
     //          <ns1:ClientOrderNumber>133</ns1:ClientOrderNumber>
     //          <ns1:OrderRows>
     //            <ns1:OrderRow>
     //              <ns1:ArticleNumber>NTB03</ns1:ArticleNumber>
     //              <ns1:Description>Making candles and soaps for dummies: Making candles and soaps for dummies</ns1:Description>
     //              <ns1:PricePerUnit>12.12</ns1:PricePerUnit>
     //              <ns1:PriceIncludingVat xsi:nil="true" />
     //              <ns1:NumberOfUnits>2</ns1:NumberOfUnits>
     //              <ns1:Unit>st</ns1:Unit>
     //              <ns1:VatPercent>25</ns1:VatPercent>
     //              <ns1:DiscountPercent>0</ns1:DiscountPercent>
     //            </ns1:OrderRow>
     //            <ns1:OrderRow>
     //              <ns1:ArticleNumber>SHIP25</ns1:ArticleNumber>
     //              <ns1:Description>Frakt / Shipping</ns1:Description>
     //              <ns1:PricePerUnit>8.66</ns1:PricePerUnit>
     //              <ns1:PriceIncludingVat xsi:nil="true" />
     //              <ns1:NumberOfUnits>1</ns1:NumberOfUnits>
     //              <ns1:Unit>st</ns1:Unit>
     //              <ns1:VatPercent>25</ns1:VatPercent>
     //              <ns1:DiscountPercent>0</ns1:DiscountPercent>
     //            </ns1:OrderRow>
     //            <ns1:OrderRow>
     //              <ns1:ArticleNumber>HAND25</ns1:ArticleNumber>
     //              <ns1:Description>Expeditionsavgift / Handling</ns1:Description>
     //              <ns1:PricePerUnit>2.51</ns1:PricePerUnit>
     //              <ns1:PriceIncludingVat xsi:nil="true" />
     //              <ns1:NumberOfUnits>1</ns1:NumberOfUnits>
     //              <ns1:Unit>st</ns1:Unit>
     //              <ns1:VatPercent>25</ns1:VatPercent>
     //              <ns1:DiscountPercent>0</ns1:DiscountPercent>
     //            </ns1:OrderRow>
     //          </ns1:OrderRows>
     //          <ns1:CustomerIdentity>
     //            <ns1:Email>
     //            </ns1:Email>
     //            <ns1:PhoneNumber>
     //            </ns1:PhoneNumber>
     //            <ns1:IpAddress>
     //            </ns1:IpAddress>
     //            <ns1:FullName>asdf ghij</ns1:FullName>
     //            <ns1:Street>Postbus</ns1:Street>
     //            <ns1:CoAddress>
     //            </ns1:CoAddress>
     //            <ns1:ZipCode>1010 AB</ns1:ZipCode>
     //            <ns1:HouseNumber>626</ns1:HouseNumber>
     //            <ns1:Locality>Amsterdam</ns1:Locality>
     //            <ns1:CountryCode>NL</ns1:CountryCode>
     //            <ns1:CustomerType>Individual</ns1:CustomerType>
     //            <ns1:IndividualIdentity>
     //              <ns1:FirstName>asdf</ns1:FirstName>
     //              <ns1:LastName>ghij</ns1:LastName>
     //              <ns1:Initials>ag</ns1:Initials>
     //              <ns1:BirthDate>19550307</ns1:BirthDate>
     //            </ns1:IndividualIdentity>
     //          </ns1:CustomerIdentity>
     //          <ns1:OrderDate>2014-11-19</ns1:OrderDate>
     //          <ns1:AddressSelector>
     //          </ns1:AddressSelector>
     //          <ns1:OrderType>Invoice</ns1:OrderType>
     //        </ns1:CreateOrderInformation>
     //      </ns1:request>
     //    </ns1:CreateOrderEu>
     //  </SOAP-ENV:Body>
     //</SOAP-ENV:Envelope>
 }
 /**
  * Function to use in testfunctions
  * @return SveaOrderId
  */
 private function getInvoiceOrderId()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $request = WebPay::createOrder($config)->addOrderRow(TestUtil::createOrderRow())->addCustomerDetails(WebPayItem::individualCustomer()->setNationalIdNumber(194605092222))->setCountryCode("SE")->setCustomerReference("33")->setOrderDate("2012-12-12")->setCurrency("SEK")->useInvoicePayment()->doRequest();
     return $request->sveaOrderId;
 }