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 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);
 }
Пример #3
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 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]);
 }
Пример #6
0
 public function testPaymentPlanWithPriceAsDecimal()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $campaign = $this->getGetPaymentPlanParamsForTesting();
     $request = WebPay::createOrder($config)->addOrderRow(WebPayItem::orderRow()->setArticleNumber("1")->setQuantity(2)->setAmountExVat(240.0)->setAmountIncVat(300.0)->setDescription("CD"))->addCustomerDetails(WebPayItem::individualCustomer()->setNationalIdNumber(194605092222))->setCountryCode("SE")->setCustomerReference("33")->setOrderDate("2012-12-12")->setCurrency("SEK")->usePaymentPlanPayment($campaign)->prepareRequest();
     //couponrow
     $this->assertEquals(300.0, $request->request->CreateOrderInformation->OrderRows['OrderRow'][0]->PricePerUnit);
     $this->assertEquals(2, $request->request->CreateOrderInformation->OrderRows['OrderRow'][0]->NumberOfUnits);
     $this->assertEquals(25, $request->request->CreateOrderInformation->OrderRows['OrderRow'][0]->VatPercent);
 }
 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>
 }
 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);
 }
Пример #9
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());
     }
 }
Пример #10
0
 public static function individualCustomer()
 {
     return WebPayItem::individualCustomer();
 }
 /**
  * Function to use in testfunctions
  * @return SveaOrderId
  */
 private function getPaymentPlanOrderId()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $response = WebPay::createOrder($config)->addOrderRow(TestUtil::createOrderRow(1000.0, 1))->addCustomerDetails(WebPayItem::individualCustomer()->setNationalIdNumber(194605092222))->setCountryCode("SE")->setCustomerReference("33")->setOrderDate("2012-12-12")->setCurrency("SEK")->usePaymentPlanPayment(TestUtil::getGetPaymentPlanParamsForTesting())->doRequest();
     return $response->sveaOrderId;
 }
 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_add_publickey_for_private_customer()
 {
     $config = \Svea\SveaConfig::getTestConfig();
     $order = WebPay::createOrder($config)->addCustomerDetails(WebPayItem::individualCustomer()->setPublicKey('ac0f2573b58ff523'));
     $this->assertEquals('ac0f2573b58ff523', $order->customerIdentity->publicKey);
 }
 public function testOrderRowsInOrderAsAdded2()
 {
     $config = SveaConfig::getDefaultConfig();
     $request = \WebPay::createOrder($config);
     $request = $request->addFee(\WebPayItem::shippingFee()->setDescription("1")->setVatPercent(25)->setAmountIncVat(30.0))->addOrderRow(\WebPayItem::orderRow()->setDescription("2")->setQuantity(1)->setAmountIncVat(10.0)->setVatPercent(25))->addOrderRow(\WebPayItem::orderRow()->setDescription("3")->setQuantity(1)->setAmountIncVat(20.0)->setVatPercent(25))->addDiscount(\WebPayItem::relativeDiscount()->setDescription("4")->setDiscountPercent(10))->addCustomerDetails(\WebPayItem::individualCustomer()->setNationalIdNumber(194605092222))->setCountryCode("SE")->setCustomerReference("33")->setOrderDate("2012-12-12")->setCurrency("SEK")->useInvoicePayment()->prepareRequest();
     $this->assertEquals("1", $request->request->CreateOrderInformation->OrderRows['OrderRow'][0]->Description);
     $this->assertEquals("2", $request->request->CreateOrderInformation->OrderRows['OrderRow'][1]->Description);
     $this->assertEquals("3", $request->request->CreateOrderInformation->OrderRows['OrderRow'][2]->Description);
     $this->assertEquals("4", $request->request->CreateOrderInformation->OrderRows['OrderRow'][3]->Description);
 }
 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>
 }
Пример #16
0
 public function testSetAuthorization()
 {
     $form = \WebPay::createOrder(new TestConf())->addCustomerDetails(\WebPayItem::individualCustomer()->setNationalIdNumber(194605092222)->setIpAddress("123.123.123"))->addOrderRow(\TestUtil::createOrderRow())->setCountryCode("SE")->setClientOrderNumber("33")->setOrderDate("2012-12-12")->setCurrency("SEK")->usePayPageCardOnly()->setPayPageLanguage("sv")->setReturnUrl("http://myurl.se")->getPaymentForm();
     $this->assertEquals("1130", $form->merchantid);
     $this->assertEquals('8a9cece566e808da63c6f07ff415ff9e127909d000d259aba24daa2fed6d9e3f8b0b62e8ad1fa91c7d7cd6fc3352deaae66cdb533123edf127ad7d1f4c77e7a3', $form->secretWord);
 }
Пример #17
0
 public function testBuildOrderWithCustomer()
 {
     $config = SveaConfig::getDefaultConfig();
     $sveaRequest = \WebPay::createOrder($config)->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"));
     $this->assertEquals(194605092222, $sveaRequest->customerIdentity->ssn);
     $this->assertEquals("SB", $sveaRequest->customerIdentity->initials);
     $this->assertEquals(19231212, $sveaRequest->customerIdentity->birthDate);
     $this->assertEquals("Tess", $sveaRequest->customerIdentity->firstname);
     $this->assertEquals("Testson", $sveaRequest->customerIdentity->lastname);
     $this->assertEquals("*****@*****.**", $sveaRequest->customerIdentity->email);
     $this->assertEquals(999999, $sveaRequest->customerIdentity->phonenumber);
     $this->assertEquals("123.123.123", $sveaRequest->customerIdentity->ipAddress);
     $this->assertEquals("Gatan", $sveaRequest->customerIdentity->street);
     $this->assertEquals(23, $sveaRequest->customerIdentity->housenumber);
     $this->assertEquals("c/o Eriksson", $sveaRequest->customerIdentity->coAddress);
     $this->assertEquals(9999, $sveaRequest->customerIdentity->zipCode);
     $this->assertEquals("Stan", $sveaRequest->customerIdentity->locality);
 }
 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;
 }
 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" );
 }
 /**
  * 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;
 }
 /**
  * @expectedException Svea\ValidationException
  * @expectedExceptionMessage -incorrect datatype : vatPercent is not of type int.
  */
 public function testFailOnVatNotInt()
 {
     $config = SveaConfig::getDefaultConfig();
     $builder = \WebPay::createOrder($config);
     $order = $builder->addOrderRow(\WebPayItem::orderRow()->setAmountExVat(100.0)->setVatPercent(20.33)->setQuantity(1))->setCountryCode("SE")->setOrderDate("Mon, 15 Aug 05 15:52:01 +0000")->addCustomerDetails(\WebPayItem::individualCustomer()->setNationalIdNumber(46111111))->useInvoicePayment();
     $order->prepareRequest();
 }
Пример #22
0
 /**
  * Add Customer details to Svea CreateOrder object
  *
  * @param type $order
  * @param type $additionalInfo
  * @return type Svea CreateOrder object
  */
 public function getSveaPaymentObject($order, $additionalInfo = null)
 {
     $svea = parent::getSveaPaymentObject($order, $additionalInfo);
     //Add more customer info
     $countryCode = $order->getBillingAddress()->getCountryId();
     $company = $additionalInfo['svea_customerType'];
     $address = $order->getBillingAddress()->getStreetFull();
     $addressArray = \Svea\Helper::splitStreetAddress($address);
     if ($company == "1") {
         $item = WebPayItem::companyCustomer();
         $item = $item->setEmail($order->getBillingAddress()->getEmail())->setCompanyName($order->getBillingAddress()->getCompany())->setStreetAddress($addressArray[1], $addressArray[2])->setZipCode($order->getBillingAddress()->getPostcode())->setLocality($order->getBillingAddress()->getCity())->setIpAddress(Mage::helper('core/http')->getRemoteAddr(false))->setPhoneNumber($order->getBillingAddress()->getTelephone());
         if ($countryCode == "DE" || $countryCode == "NL") {
             $item = $item->setVatNumber($additionalInfo['svea_vatNo']);
         } else {
             $item = $item->setNationalIdNumber($additionalInfo['svea_ssn']);
             $item = $item->setAddressSelector($additionalInfo['svea_addressSelector']);
         }
     } else {
         $item = WebPayItem::individualCustomer();
         // Not all countries has svea_ssn input
         if (array_key_exists('svea_ssn', $additionalInfo)) {
             $item = $item->setNationalIdNumber($additionalInfo['svea_ssn']);
         }
         $item = $item->setEmail($order->getBillingAddress()->getEmail())->setName($order->getBillingAddress()->getFirstname(), $order->getBillingAddress()->getLastname())->setStreetAddress($addressArray[1], $addressArray[2])->setZipCode($order->getBillingAddress()->getPostcode())->setLocality($order->getBillingAddress()->getCity())->setIpAddress(Mage::helper('core/http')->getRemoteAddr(false))->setPhoneNumber($order->getBillingAddress()->getTelephone());
         if ($countryCode == "DE" || $countryCode == "NL") {
             $validBirthday = true;
             foreach (array('svea_birthYear', 'svea_birthMonth', 'svea_birthDay') as $key) {
                 if (!array_key_exists($key, $additionalInfo) || trim($additionalInfo[$key]) === "") {
                     $validBirthday = false;
                 }
             }
             if ($validBirthday) {
                 $item = $item->setBirthDate($additionalInfo['svea_birthYear'], $additionalInfo['svea_birthMonth'], $additionalInfo['svea_birthDay']);
             }
         }
         if ($countryCode == "NL") {
             if (array_key_exists('svea_initials', $additionalInfo)) {
                 $item = $item->setInitials($additionalInfo['svea_initials']);
             }
         }
     }
     // Set public key on the object if publicKey is set in additionalInfo
     if (array_key_exists('svea_publicKey', $additionalInfo)) {
         $publicKey = $additionalInfo['svea_publicKey'];
         if ($publicKey !== '') {
             $item = $item->setPublicKey($publicKey);
             // $item = $item->setAddressSelector('');
         }
     }
     $svea = $svea->addCustomerDetails($item);
     return $svea;
 }
Пример #23
0
// required - use a not previously sent client side order identifier, i.e. "order #20140519-371"
// You may also chain fluent methods together:
$myOrder->setCustomerReference("customer #123")->setOrderDate("2014-05-28");
// Then specify the items bought as order rows, using the methods in the Svea\OrderRow class, and adding them to the order:
$firstBoughtItem = WebPayItem::orderRow();
$firstBoughtItem->setAmountExVat(10.99);
$firstBoughtItem->setVatPercent(25);
$firstBoughtItem->setQuantity(1);
$firstBoughtItem->setDescription("Billy");
$firstBoughtItem->setArticleNumber("123456789A");
// Add firstBoughtItem to order row
$myOrder->addOrderRow($firstBoughtItem);
// Add secondBoughtItem in a fluent fashion
$myOrder->addOrderRow(WebPayItem::orderRow()->setAmountIncVat(5.0)->setVatPercent(12)->setQuantity(2)->setDescription("Korv med bröd"));
// For card orders the ->addCustomerDetails() method is optional, but recommended, so we'll add what info we have
$myCustomerInformation = WebPayItem::individualCustomer();
// there's also a ::companyCustomer() method, used for non-person entities
// Set customer information, using the methods from the IndividualCustomer class
$myCustomerInformation->setName($customerFirstName, $customerLastName);
$sveaAddress = Svea\Helper::splitStreetAddress($customerAddress);
// Svea requires an address and a house number
$myCustomerInformation->setStreetAddress($sveaAddress[0], $sveaAddress[1]);
$myCustomerInformation->setZipCode($customerZipCode)->setLocality($customerCity);
$myOrder->addCustomerDetails($myCustomerInformation);
// 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::SVEACARDPAY).
$myCardOrderRequest = $myOrder->usePaymentMethod(PaymentMethod::SVEACARDPAY);
// Then set any additional required request attributes as detailed below. (See Svea\PaymentMethodPayment and Svea\HostedPayment classes for details.)
$myCardOrderRequest->setCardPageLanguage("SV")->setReturnUrl("http://localhost/" . getPath() . "/landingpage.php");
// The return url where we receive and process the finished request response
// Get a payment form object which you can use to send the payment request to Svea