public function test_createOrder_usePayPage_redirects_to_paypage()
 {
     $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")->usePayPage()->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);
     //print_r( $cr);
     $this->assertEquals(200, $info['http_code']);
     $this->assertEquals(2, $info['redirect_count']);
     $expected_infourl = "https://test.sveaekonomi.se/webpay/public/static/paypage.html";
     $start_of_actual_infourl = substr($info['url'], 0, strlen($expected_infourl));
     $this->assertEquals($expected_infourl, $start_of_actual_infourl);
 }
 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 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);
 }
Пример #4
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 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);
 }
 public function testBuildPayPagePaymentCallBackUrl()
 {
     $config = SveaConfig::getDefaultConfig();
     $rowFactory = new \TestUtil();
     $form = \WebPay::createOrder($config)->addOrderRow(\WebPayItem::orderRow()->setQuantity(2)->setAmountExVat(100.0)->setName('Prod')->setVatPercent(0))->setCountryCode("SE")->setClientOrderNumber("33")->setCurrency("SEK")->usePayPage()->setReturnUrl("myurl")->setCallbackUrl("http://myurl.se")->getPaymentForm();
     $xmlMessage = new \SimpleXMLElement($form->xmlMessage);
     $this->assertEquals("http://myurl.se", $xmlMessage->callbackurl);
 }
 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);
 }
 protected function setUp()
 {
     $this->order = \WebPay::createOrder(Svea\SveaConfig::getDefaultConfig());
     $this->individualCustomer = new Svea\IndividualCustomer();
     $this->individualCustomer->setNationalIdNumber("123456");
     $this->orderRow = new Svea\OrderRow();
     $this->orderRow->setAmountExVat(100.0);
     $this->orderRow->setVatPercent(25);
     $this->orderRow->setQuantity(2);
 }
 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);
 }
 public function test_bv_order_sent_incvat_two_decimals_with_both_discounts_with_amount_only()
 {
     //    print_r("\n\n-----test_bv_order_sent_incvat_two_decimals_with_both_discounts_with_amount_only()\n");
     $order = WebPay::createOrder(Svea\SveaConfig::getDefaultConfig())->addCustomerDetails(WebPayItem::individualCustomer()->setNationalIdNumber(194605092222))->setCountryCode("SE")->setCustomerReference("1337")->setOrderDate("2015-05-20")->setCurrency("SEK")->addOrderRow(WebPayItem::orderRow()->setAmountIncVat(1.0)->setVatPercent(6)->setQuantity(800)->setName("3.00i@6%*800"))->setClientOrderNumber(date('c'));
     $order->addDiscount(WebPayItem::fixedDiscount()->setAmountIncVat(240)->setDiscountId("fixedDiscount")->setName("-240i*1"));
     $order->addDiscount(WebPayItem::fixedDiscount()->setAmountIncVat(20)->setDiscountId("fixedDiscount2")->setName("-20i*1"));
     $request = $order->usePaymentMethod(PaymentMethod::KORTCERT)->setReturnUrl("https://test.sveaekonomi.se/webpay-admin/admin/merchantresponsetest.xhtml");
     $request = $request->getPaymentForm();
     //    print_r( $request->xmlMessage );
     // 240i@6% => 240 (13,58491) => 24000 (1358)
     $expectedDiscountRow = "  <row>\n" . "   <sku>fixedDiscount</sku>\n" . "   <name>-240i*1</name>\n" . "   <description></description>\n" . "   <amount>-24000</amount>\n" . "   <vat>-1358</vat>\n";
     "   <quantity>1</quantity>\n" . "  </row>\n";
     $this->assertEquals(1, substr_count($request->xmlMessage, $expectedDiscountRow));
     // 20i@6% => 2000 (1,132076) => 2000 (113)
     $expectedDiscountRow2 = "  <row>\n" . "   <sku>fixedDiscount2</sku>\n" . "   <name>-20i*1</name>\n" . "   <description></description>\n" . "   <amount>-2000</amount>\n" . "   <vat>-113</vat>\n";
     "   <quantity>1</quantity>\n" . "  </row>\n";
     $this->assertEquals(1, substr_count($request->xmlMessage, $expectedDiscountRow2));
     // lagt ordern med den dumpade xml:en från utskriften i tools/payment, ger detta response:
     //<response>
     //  <transaction id="600123">
     //    <paymentmethod>KORTCERT</paymentmethod>
     //    <merchantid>1130</merchantid>
     //    <customerrefno>2015-05-22T13:00:54 02:00</customerrefno>
     //    <amount>54000</amount>
     //    <currency>SEK</currency>
     //    <cardtype>VISA</cardtype>
     //    <maskedcardno>444433xxxxxx1100</maskedcardno>
     //    <expirymonth>02</expirymonth>
     //    <expiryyear>17</expiryyear>
     //    <authcode>594378</authcode>
     //    <customer>
     //      <firstname/>
     //      <lastname/>
     //      <initials/>
     //      <email/>
     //      <ssn>194605092222</ssn>
     //      <address/>
     //      <address2/>
     //      <city/>
     //      <country>SE</country>
     //      <zip/>
     //      <phone/>
     //      <vatnumber/>
     //      <housenumber/>
     //      <companyname/>
     //      <fullname/>
     //    </customer>
     //  </transaction>
     //  <statuscode>0</statuscode>
     //</response>
 }
 /** 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);
 }
 /**
  * split mean vat given by shop (i.e. when using a coupon in OpenCart) into two fixedDiscountRows
  */
 public function test_splitMeanToTwoTaxRatesToFormatFixedDiscountRows_OneRateInOrder()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $order = WebPay::createOrder($config);
     $order->addOrderRow(WebPayItem::orderRow()->setAmountExVat(100.0)->setVatPercent(25)->setQuantity(2));
     $discountExVatFromShop = 100;
     $meanVatRateFromShop = 25.0;
     $titleFromShop = "Coupon (1112)";
     $descriptionFromShop = "Value 100";
     $taxRates = Svea\Helper::getTaxRatesInOrder($order);
     $discountRows = Svea\Helper::splitMeanToTwoTaxRates($discountExVatFromShop, $meanVatRateFromShop, $titleFromShop, $descriptionFromShop, $taxRates);
     foreach ($discountRows as $row) {
         $order = $order->addDiscount($row);
     }
     $formatter = new Svea\WebService\WebServiceRowFormatter($order);
     $newRows = $formatter->formatRows();
     $newRow = $newRows[1];
     $this->assertEquals("Coupon (1112): Value 100", $newRow->Description);
     $this->assertEquals(-100, $newRow->PricePerUnit);
     $this->assertEquals(25, $newRow->VatPercent);
 }
 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);
 }
 public function test_fixedDiscount_amount_with_calculated_vat_rate_incvat_creates_discount_rows_using_incvat_and_vatpercent()
 {
     $order = WebPay::createOrder(Svea\SveaConfig::getDefaultConfig())->addCustomerDetails(WebPayItem::individualCustomer()->setNationalIdNumber(194605092222))->setCountryCode("SE")->setCustomerReference("33")->setOrderDate("2012-12-12")->setCurrency("SEK")->addOrderRow(WebPayItem::orderRow()->setAmountExVat(60.0)->setVatPercent(20)->setQuantity(1)->setName("exvatRow"))->addOrderRow(WebPayItem::orderRow()->setAmountExVat(30.0)->setVatPercent(10)->setQuantity(1)->setName("exvatRow2"))->addFee(WebPayItem::invoiceFee()->setAmountExVat(8.0)->setVatPercent(10)->setName("exvatInvoiceFee"))->addFee(WebPayItem::shippingFee()->setAmountExVat(16.0)->setVatPercent(10)->setName("exvatShippingFee"))->addDiscount(WebPayItem::fixedDiscount()->setAmountIncVat(10.0)->setDiscountId("TenCrownsOff")->setName("fixedDiscount: 10 off incvat"));
     $request = $order->useInvoicePayment()->prepareRequest();
     // all order rows
     $this->assertEquals(60.0, $request->request->CreateOrderInformation->OrderRows['OrderRow'][0]->PricePerUnit);
     $this->assertEquals(20, $request->request->CreateOrderInformation->OrderRows['OrderRow'][0]->VatPercent);
     $this->assertEquals(30.0, $request->request->CreateOrderInformation->OrderRows['OrderRow'][1]->PricePerUnit);
     $this->assertEquals(10, $request->request->CreateOrderInformation->OrderRows['OrderRow'][1]->VatPercent);
     // all invoice fee rows
     $this->assertEquals(8.0, $request->request->CreateOrderInformation->OrderRows['OrderRow'][2]->PricePerUnit);
     $this->assertEquals(10, $request->request->CreateOrderInformation->OrderRows['OrderRow'][2]->VatPercent);
     // all shipping fee rows
     $this->assertEquals(16.0, $request->request->CreateOrderInformation->OrderRows['OrderRow'][3]->PricePerUnit);
     $this->assertEquals(10, $request->request->CreateOrderInformation->OrderRows['OrderRow'][3]->VatPercent);
     // all discount rows
     // expected: fixedDiscount: 10 off incvat, order row amount are 66% at 20% vat, 33% at 10% vat
     // 1.2*0.66x + 1.1*0.33x = 10 => x = 8.6580 => 5.7143 @20% and 2.8571 @10% =
     $this->assertEquals(-5.7142857142857, $request->request->CreateOrderInformation->OrderRows['OrderRow'][4]->PricePerUnit);
     $this->assertEquals(20, $request->request->CreateOrderInformation->OrderRows['OrderRow'][4]->VatPercent);
     $this->assertEquals(-2.8571428571429, $request->request->CreateOrderInformation->OrderRows['OrderRow'][5]->PricePerUnit);
     $this->assertEquals(10, $request->request->CreateOrderInformation->OrderRows['OrderRow'][5]->VatPercent);
 }
 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']);
 }
 function test_manual_setup_CreditCardOrderRows_testdata()
 {
     // Stop here and mark this test as incomplete.
     $this->markTestIncomplete('1. test_manual_setup_CreditCardOrderRows_testdata -- run this first to setup order for CreditOrderRows tests to work with. 
         Run once, then make sure to approve the invoice in the admin interface. Then uncomment and run CreditOrderRows tests.               
          
         2. verktyg / confirm, merchant 1130, use this xml w/correct transactionid, todays date => status = CONFIRMED         
         <confirm>
         <transactionid>583004</transactionid>
         <capturedate>2014-06-02</capturedate>
         </confirm>
         
         3. schemalagda jobb / dailycapture kortcert task => status = SUCCESS');
     $orderLanguage = "sv";
     $returnUrl = "http://127.0.0.1";
     $ipAddress = "127.0.0.1";
     // create order
     $order = WebPay::createOrder(Svea\SveaConfig::getDefaultConfig())->setCountryCode($this->country)->setCurrency("SEK")->setCustomerReference("CreditCardOrderRows_testdata" . date('c'))->setClientOrderNumber("CreditCardOrderRows_testdata" . date('c'))->setOrderDate(date('c'));
     $order->addCustomerDetails(WebPayItem::individualCustomer()->setNationalIdNumber("194605092222")->setBirthDate(1946, 05, 00)->setName("Tess T", "Persson")->setStreetAddress("Testgatan", 1)->setCoAddress("c/o Eriksson, Erik")->setLocality("Stan")->setZipCode("99999")->setIpAddress($ipAddress));
     $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->usePaymentMethod(PaymentMethod::KORTCERT)->setPayPageLanguage($orderLanguage)->setReturnUrl($returnUrl)->getPaymentUrl();
     //print_r( $orderResponse );
     $this->assertEquals(1, $orderResponse->accepted);
     //print_r( "test_manual_setup_CreditCardOrderRows_testdata finished, now go to " . $orderResponse->testurl ." and complete payment.\n" );
 }
 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);
 }
Пример #18
0
 public function test_createOrder_usePaymentMethod_KORTCERT_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'))->setCurrency("SEK")->setClientOrderNumber(date('c'));
     // prepareRequest() validates the order and throws SveaWebPayException on validation failure
     try {
         $request = $createOrder->usePaymentMethod(PaymentMethod::KORTCERT)->setReturnUrl("http://myurl.se")->getPaymentForm();
     } 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);
 }
Пример #20
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);
 }
Пример #21
0
 public function test_BuildCardPayment_With_InvoiceFee_ExVat_IncVat()
 {
     $config = SveaConfig::getDefaultConfig();
     $form = \WebPay::createOrder($config)->addOrderRow(\WebPayItem::orderRow()->setArticleNumber("1")->setQuantity(1)->setAmountExVat(240.0)->setAmountIncVat(300.0)->setDescription("CD"))->addFee(\WebPayItem::invoiceFee()->setAmountExVat(80)->setAmountIncVat(100)->setName("test_BuildCardPayment_With_InvoiceFee title")->setDescription("test_BuildCardPayment_With_InvoiceFee description")->setUnit("kr"))->setClientOrderNumber("33")->setCurrency("SEK")->setCountryCode("SE")->usePayPageCardOnly()->setReturnUrl("http://myurl.se")->getPaymentForm();
     $xmlMessage = new \SimpleXMLElement($form->xmlMessage);
     $this->assertEquals("8000", $xmlMessage->vat);
     $this->assertEquals("40000", $xmlMessage->amount);
 }
Пример #22
0
 /**
  * Creates Svea Create order object with Config auth values
  *
  * @param type $order
  * @param type Config $auth
  * @return Svea CreateOrder object
  */
 public function getPaymentRequest($order, $auth, $force = false)
 {
     if (!$order->hasData('svea_payment_request') || $force) {
         $conf = new SveaMageConfigProvider($auth);
         $sveaObj = WebPay::createOrder($conf);
         $order->setData('svea_payment_request', $sveaObj);
     }
     return $order->getData('svea_payment_request');
 }
 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);
 }
 public function test_add_publickey_for_private_customer_full_request()
 {
     $config = \Svea\SveaConfig::getTestConfig();
     $order = WebPay::createOrder($config)->addCustomerDetails(WebPayItem::companyCustomer()->setCompanyName('mycomp')->setNationalIdNumber('164701161111')->setPublicKey('ac0f2573b58ff523'))->setCountryCode('SE')->addOrderRow(WebPayItem::orderRow()->setAmountIncVat(125.0)->setVatPercent(25)->setQuantity(1))->setOrderDate(date('c'))->useInvoicePayment()->prepareRequest();
     $this->assertEquals('ac0f2573b58ff523', $order->request->CreateOrderInformation->CustomerIdentity->PublicKey);
 }
Пример #26
0
/**
 * example file, how to create a recurring card order request
 *
 * @author Kristian Grossman-madsen for Svea WebPay
 */
error_reporting(E_ALL);
ini_set('display_errors', 'On');
// Include Svea PHP integration package.
$svea_directory = "../../src/";
require_once $svea_directory . "Includes.php";
// get config object
$myConfig = Svea\SveaConfig::getTestConfig();
//replace with class holding your merchantid, secretword, et al, adopted from package Config/SveaConfig.php
// Start the order creation process by creating the order builder object by calling WebPay::createOrder():
$myOrder = WebPay::createOrder($myConfig);
// You then add information to the order object by using the methods in the Svea\CreateOrderBuilder class.
// For a Card order, the following methods are required:
$myOrder->setCountryCode("SE");
// customer country, we recommend basing this on the customer billing address
$myOrder->setCurrency("SEK");
// order currency
$myOrder->setClientOrderNumber("order #" . date('c'));
// required - use a not previously sent client side order identifier, i.e. "order #20140519-371"
// Add order item in a fluent fashion
$myOrder->addOrderRow(WebPayItem::orderRow()->setAmountExVat(100.0)->setVatPercent(25)->setQuantity(1)->setDescription("Månadsavgift via recur"));
// We have now completed specifying the order, and wish to send the payment request to Svea. To do so, we first select a payment method.
// For card orders, we recommend using the ->usePaymentMethod(PaymentMethod::KORTCERT), which processes card orders via SveaCardPay.
$myRecurOrderRequest = $myOrder->usePaymentMethod(PaymentMethod::SVEACARDPAY);
// For recurring card payments, use setSubscriptionId() on the request object, using the subscription id from the initial request response
$mySubscriptionId = file_get_contents("subscription.txt");
 /**
  * Regression test for float to int conversion error, where we lost accuracy
  * on straight cast of 25f (eg. 24.9999999964) to 24i
  * See also test in InvoicePaymentIntegrationTest, Jira issue WEB-193
  */
 public function test_regressiontest_for_float_to_int_conversion_errorS()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $order = WebPay::createOrder($config);
     $order->addOrderRow(WebPayItem::orderRow()->setAmountExVat(100.0)->setVatPercent(25)->setQuantity(1))->addFee(WebPayItem::shippingFee()->setAmountExVat(0.0)->setVatPercent(0))->addFee(WebPayItem::invoiceFee()->setAmountExVat(23.2)->setVatPercent(25));
     $formatter = new WebServiceRowFormatter($order);
     $resultRows = $formatter->formatRows();
     $testedRow = $resultRows[0];
     $this->assertEquals(100, $testedRow->PricePerUnit);
     $this->assertEquals(25, $testedRow->VatPercent);
     $testedRow = $resultRows[1];
     $this->assertEquals(0, $testedRow->PricePerUnit);
     $this->assertEquals(0, $testedRow->VatPercent);
     $testedRow = $resultRows[2];
     $this->assertEquals(23.2, $testedRow->PricePerUnit);
     $this->assertEquals(25, $testedRow->VatPercent);
 }
 /**
  * @expectedException Svea\ValidationException
  * @expectedExceptionMessage -missing value : ReturnUrl is required. Use function setReturnUrl().
  */
 public function testFailOnMissingReturnUrl()
 {
     $config = SveaConfig::getDefaultConfig();
     $builder = \WebPay::createOrder($config);
     $order = $builder->addOrderRow(\TestUtil::createHostedOrderRow())->setCountryCode("SE")->setCurrency("SEK")->setClientOrderNumber("34")->usePayPage();
     // ->setReturnUrl("myurl.se")
     $order->getPaymentForm();
 }
 private static function create_only_incvat_order_and_fee_rows_order()
 {
     $order = WebPay::createOrder(Svea\SveaConfig::getDefaultConfig())->addCustomerDetails(WebPayItem::individualCustomer()->setNationalIdNumber(194605092222))->setCountryCode("SE")->setCustomerReference("33")->setOrderDate("2012-12-12")->setCurrency("SEK")->addOrderRow(WebPayItem::orderRow()->setAmountIncVat(72.0)->setVatPercent(20)->setQuantity(1)->setName("incvatRow"))->addOrderRow(WebPayItem::orderRow()->setAmountIncVat(33.0)->setVatPercent(10)->setQuantity(1)->setName("incvatRow2"))->addFee(WebPayItem::invoiceFee()->setAmountIncVat(8.800000000000001)->setVatPercent(10)->setName("incvatInvoiceFee"))->addFee(WebPayItem::shippingFee()->setAmountIncVat(17.6)->setVatPercent(10)->setName("incvatShippingFee"));
     return $order;
 }
Пример #30
0
 /**
  * @expectedException Exception
  * @expectedExceptionMessage Invalid or missing Country code
  */
 function test_usepaymentmethodpayment_without_countrycode_required_fail_when_using_defaultconfig()
 {
     $order = \WebPay::createOrder(SveaConfig::getDefaultConfig());
     $order->addOrderRow(\WebPayItem::orderRow()->setAmountExVat(100.0)->setVatPercent(25)->setQuantity(2))->setCurrency('SEK')->setClientOrderNumber('1010101')->usePaymentMethod(\PaymentMethod::KORTCERT)->setReturnUrl('testurl.com')->getPaymentForm();
 }