コード例 #1
0
 /**
  * @expectedException Svea\ValidationException
  */
 public function testCloseInvoiceOrder_missing_setOrderId_throws_ValidationException()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $orderId = $this->getInvoiceOrderId();
     $orderBuilder = WebPay::closeOrder($config);
     $request = $orderBuilder->setCountryCode("SE")->closeInvoiceOrder()->doRequest();
 }
コード例 #2
0
 public function testClosePaymentPlanOrder()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $orderBuilder = WebPay::closeOrder($config);
     $request = $orderBuilder->setCountryCode("SE")->setOrderId("id")->closePaymentPlanOrder()->prepareRequest();
     $this->assertEquals("id", $request->request->CloseOrderInformation->SveaOrderId);
 }
コード例 #3
0
 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);
 }
コード例 #4
0
 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);
 }
コード例 #5
0
 public function testXmlWithIndividualCustomer()
 {
     $customer = $this->individualCustomer;
     $customer->setName("Julius", "Caesar");
     $customer->setInitials("JS");
     $customer->setPhoneNumber("999999");
     $customer->setEmail("*****@*****.**");
     $customer->setIpAddress("123.123.123.123");
     $customer->setStreetAddress("Gatan", "23");
     $customer->setCoAddress("c/o Eriksson");
     $customer->setZipCode("9999");
     $customer->setLocality("Stan");
     $this->order = new Svea\CreateOrderBuilder(new Svea\SveaConfigurationProvider(Svea\SveaConfig::getDefaultConfig()));
     $this->order->setClientOrderNumber("1234")->setCountryCode("SE")->setCurrency("SEK")->addCustomerDetails($customer)->addOrderRow($this->orderRow);
     $payment = new FakeHostedPayment($this->order);
     $payment->order = $this->order;
     $payment->setReturnUrl("http://myurl.se");
     $xmlBuilder = new HostedXmlBuilder();
     $xml = $xmlBuilder->getOrderXML($payment->calculateRequestValues(), $this->order);
     $this->assertEquals(1, substr_count($xml, "<ssn>123456</ssn>"));
     $this->assertEquals(1, substr_count($xml, "<firstname>Julius</firstname>"));
     $this->assertEquals(1, substr_count($xml, "<lastname>Caesar</lastname>"));
     $this->assertEquals(1, substr_count($xml, "<initials>JS</initials>"));
     $this->assertEquals(1, substr_count($xml, "<phone>999999</phone>"));
     $this->assertEquals(1, substr_count($xml, "<email>test@svea.com</email>"));
     $this->assertEquals(1, substr_count($xml, "<address>Gatan</address>"));
     $this->assertEquals(1, substr_count($xml, "<housenumber>23</housenumber>"));
     $this->assertEquals(1, substr_count($xml, "<address2>c/o Eriksson</address2>"));
     $this->assertEquals(1, substr_count($xml, "<zip>9999</zip>"));
     $this->assertEquals(1, substr_count($xml, "<city>Stan</city>"));
     $this->assertEquals(1, substr_count($xml, "<country>SE</country>"));
 }
コード例 #6
0
 public function test_creditAmount_creditPaymentPlan_amount_exceeds_orderamount()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $orderInfo = $this->get_orderInfo_sent_inc_vat(1000.0, 25, 1, TRUE);
     $credit = WebPayAdmin::creditAmount($config)->setContractNumber($orderInfo->contractNumber)->setCountryCode('SE')->setDescription('credit desc')->setAmountIncVat(1500.0)->creditPaymentPlanAmount()->doRequest();
     $this->assertEquals(0, $credit->accepted);
 }
 private function getGetPaymentPlanParamsResponseForTesting()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $addressRequest = new GetPaymentPlanParams($config);
     $response = $addressRequest->setCountryCode("SE")->doRequest();
     return $response;
 }
コード例 #8
0
 public function test_DeliverOrdersRequest_on_open_order_returns_accepted_true()
 {
     // create order
     $country = "SE";
     $order = TestUtil::createOrder(TestUtil::createIndividualCustomer($country));
     $orderResponse = $order->useInvoicePayment()->doRequest();
     ////print_r( $orderResponse );
     $this->assertEquals(1, $orderResponse->accepted);
     $myOrderId = $orderResponse->sveaOrderId;
     // deliver order
     $DeliverOrderBuilder = new Svea\DeliverOrderBuilder(Svea\SveaConfig::getDefaultConfig());
     $DeliverOrderBuilder->setCountryCode($country);
     $DeliverOrderBuilder->setOrderId($myOrderId);
     $DeliverOrderBuilder->setInvoiceDistributionType(DistributionType::POST);
     $DeliverOrderBuilder->orderType = ConfigurationProvider::INVOICE_TYPE;
     $request = new Svea\AdminService\DeliverOrdersRequest($DeliverOrderBuilder);
     $response = $request->doRequest();
     ////print_r( $response );
     $this->assertInstanceOf('Svea\\AdminService\\DeliverordersResponse', $response);
     $this->assertEquals(true, $response->accepted);
     // truth
     $this->assertEquals(1, $response->accepted);
     // equals literal 1
     $this->assertEquals(0, $response->resultcode);
     $this->assertEquals(250.0, $response->amount);
     $this->assertEquals("Invoice", $response->orderType);
     $this->assertNotNull($response->invoiceId);
     $this->assertNull($response->contractNumber);
 }
コード例 #9
0
 /**
  * @expectedException Svea\ValidationException
  * @expectedExceptionMessage -missing value : Description is required.
  */
 public function test_creditOrderRows_creditPyamentplanOrderRows_noDesciription()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $orderRows[] = WebPayItem::orderRow()->setAmountIncVat(10.0)->setVatPercent(25)->setQuantity(1);
     $orderRows[] = WebPayItem::orderRow()->setAmountIncVat(10.0)->setVatPercent(25)->setQuantity(1);
     $credit = WebPayAdmin::creditOrderRows($config)->setContractNumber(123123)->setCountryCode('SE')->addCreditOrderRows($orderRows)->creditPaymentplanOrderRows()->prepareRequest();
 }
コード例 #10
0
 /**
  * test_manual_recurring_payment_step_2 
  * 
  * run this test manually after you've performed a card transaction with 
  * subscriptiontype set and have gotten the transaction details needed
  */
 function test_manual_recurring_payment_step_2()
 {
     // Stop here and mark this test as incomplete.
     $this->markTestIncomplete('skeleton for manual test of recur transaction amount');
     // 1. enter the below values from the transaction log from test_manual_recurring_payment_step_1
     // 2. run the test and check the output for the subscriptionid and transactionid of the recur request
     // Set the below to match the original transaction, then run the test.
     $paymentmethod = "KORTCERT";
     $merchantid = 1130;
     $currency = "SEK";
     $cardtype = "VISA";
     $maskedcardno = "444433xxxxxx1100";
     $expirymonth = 02;
     $expiryyear = 16;
     $subscriptionid = 2960;
     // insert
     // the below applies to the recur request, and may differ from the original transaction
     $new_amount = "2500";
     // in minor currency
     $new_customerrefno = "test_manual_recurring_payment_step_1 " . date('c');
     // below is actual test, shouldn't need to change it
     $request = new Svea\HostedService\RecurTransaction(Svea\SveaConfig::getDefaultConfig());
     $request->countryCode = "SE";
     $request->subscriptionId = $subscriptionid;
     $request->currency = $currency;
     $request->customerRefNo = $new_customerrefno;
     $request->amount = $new_amount;
     $response = $request->doRequest();
     // check that request was accepted
     $this->assertEquals(1, $response->accepted);
     // print the subscription id that succeeded to use to confirm the transaction
     //print_r( " test_manual_recurring_payment_step_2() recur succeded using subscriptionid: " . $response->subscriptionid ." " );
     //print_r( " test_manual_recurring_payment_step_2() for more info, check logs for transaction: " . $response->transactionid ." " );
 }
コード例 #11
0
 public function setUp()
 {
     $this->builderObject = new Svea\OrderBuilder(Svea\SveaConfig::getDefaultConfig());
     $this->builderObject->orderId = 123456;
     $this->builderObject->orderType = \ConfigurationProvider::INVOICE_TYPE;
     $this->builderObject->countryCode = "SE";
     $this->builderObject->rowsToCancel = array(1);
 }
コード例 #12
0
 /**
  * @expectedException Svea\ValidationException
  * @expectedExceptionMessage No rows has been included. Use function beginOrderRow(), beginShippingfee() or beginInvoiceFee().
  * 
  * 2.0 goes directly to DeliverInvoice
  */
 public function testFailOnMissingOrderRowsOnInvoiceDeliver()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $builder = new \Svea\DeliverOrderBuilder($config);
     $builder->setOrderId('id')->setInvoiceDistributionType('Post');
     $object = new \Svea\WebService\DeliverInvoice($builder);
     $object->prepareRequest();
 }
コード例 #13
0
 public function testBuildRequest()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $addressRequest = WebPay::getPaymentPlanParams($config);
     $request = $addressRequest->setCountryCode("SE")->prepareRequest();
     $this->assertEquals(59999, $request->request->Auth->ClientNumber);
     //Check all in identity
     $this->assertEquals("sverigetest", $request->request->Auth->Username);
     //Check all in identity
     $this->assertEquals("sverigetest", $request->request->Auth->Password);
     //Check all in identity
 }
コード例 #14
0
 /**
  * test_manual_CancelOrderBuilder_Card_success 
  * 
  * run this manually after you've performed a card transaction and have set
  * the transaction status to success using the tools in the logg admin.
  */
 function test_manual_CancelOrderBuilder_Card_success()
 {
     // Stop here and mark this test as incomplete.
     $this->markTestIncomplete('skeleton for manual test of cancelOrder for a card order');
     // Set the below to match the transaction, then run the test.
     $customerrefno = "test_1396964349955";
     $transactionId = 580658;
     $request = WebPayAdmin::cancelOrder(Svea\SveaConfig::getDefaultConfig())->setOrderId($transactionId)->setCountryCode("SE")->cancelCardOrder()->doRequest();
     $this->assertInstanceOf("Svea\\HostedAdminResponse", $response);
     $this->assertEquals(1, $response->accepted);
     $this->assertEquals($customerrefno, $response->customerrefno);
 }
コード例 #15
0
 public function test_add_new_notes_invoice()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $orderResponse = WebPay::createOrder($config)->addOrderRow(WebPayItem::orderRow()->setAmountExVat(145.0)->setVatPercent(24)->setQuantity(1))->addCustomerDetails(TestUtil::createIndividualCustomer("SE"))->setCountryCode("SE")->setOrderDate("2012-12-12")->useInvoicePayment()->doRequest();
     $this->assertEquals(1, $orderResponse->accepted);
     $response = WebPayAdmin::updateOrder($config)->setCountryCode('SE')->setOrderId($orderResponse->sveaOrderId)->setNotes($this->notes)->updateInvoiceOrder()->doRequest();
     $this->assertEquals(1, $response->accepted);
     // query order and assert row totals
     $query2 = WebPayAdmin::queryOrder($config)->setOrderId($orderResponse->sveaOrderId)->setCountryCode('SE')->queryInvoiceOrder()->doRequest();
     $this->assertEquals(1, $query2->accepted);
     $this->assertEquals($this->notes, $query2->notes);
     //print_r($orderResponse->sveaOrderId);
 }
コード例 #16
0
 public function setUp()
 {
     // run before each test, in effect resetting the default order
     $this->order = WebPay::createOrder(Svea\SveaConfig::getDefaultConfig())->addCustomerDetails(WebPayItem::individualCustomer()->setNationalIdNumber(194605092222))->setCountryCode("SE")->setOrderDate(date('c'));
     $this->exvatRow = WebPayItem::orderRow()->setAmountExVat(80.0)->setVatPercent(25)->setQuantity(1)->setName("exvatRow");
     $this->exvatRow2 = WebPayItem::orderRow()->setAmountExVat(80.0)->setVatPercent(25)->setQuantity(1)->setName("exvatRow2");
     $this->exvatInvoiceFee = WebPayItem::invoiceFee()->setAmountExVat(8.0)->setVatPercent(25)->setName("exvatInvoiceFee");
     $this->exvatShippingFee = WebPayItem::shippingFee()->setAmountExVat(16.0)->setVatPercent(25)->setName("exvatShippingFee");
     $this->incvatRow = WebPayItem::orderRow()->setAmountIncvat(100.0)->setVatPercent(25)->setQuantity(1)->setName("incvatRow");
     $this->incvatRow2 = WebPayItem::orderRow()->setAmountIncvat(100.0)->setVatPercent(25)->setQuantity(1)->setName("incvatRow2");
     $this->incvatInvoiceFee = WebPayItem::invoiceFee()->setAmountIncvat(10.0)->setVatPercent(25)->setName("incvatInvoiceFee");
     $this->incvatShippingFee = WebPayItem::shippingFee()->setAmountIncvat(20.0)->setVatPercent(25)->setName("incvatShippingFee");
 }
コード例 #17
0
 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>
 }
コード例 #18
0
 function testGetAllPaymentMethods()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $response = WebPay::getPaymentMethods($config)->setCountryCode("SE")->doRequest();
     //print_r( "testGetAllPaymentMethods: "); //print_r( $response );
     $this->assertEquals(PaymentMethod::BANKAXESS, $response[0]);
     $this->assertEquals(PaymentMethod::NORDEA_SE, $response[1]);
     $this->assertEquals(PaymentMethod::SEB_SE, $response[2]);
     $this->assertEquals(PaymentMethod::KORTCERT, $response[3]);
     $this->assertEquals(\Svea\SystemPaymentMethod::INVOICE_SE, $response[4]);
     $this->assertEquals(\Svea\SystemPaymentMethod::PAYMENTPLAN_SE, $response[5]);
     $this->assertEquals(PaymentMethod::INVOICE, $response[6]);
     $this->assertEquals(PaymentMethod::PAYMENTPLAN, $response[7]);
 }
コード例 #19
0
 /**
  * test_manual_recur_transaction_amount 
  * 
  * run this test manually after you've performed a card transaction with 
  * subscriptiontype set and have gotten the transaction details needed
  */
 function test_manual_recur_transaction_amount()
 {
     // Stop here and mark this test as incomplete.
     $this->markTestIncomplete('skeleton for manual test of recur transaction amount');
     // 1. go to https://test.sveaekonomi.se/webpay-admin/admin/start.xhtml
     // 2. go to verktyg -> betalning
     // 3. enter our test merchantid: 1130
     // 4. use the following xml, making sure to update to a unique customerrefno:
     // <paymentmethod>KORTCERT</paymentmethod><subscriptiontype>RECURRINGCAPTURE</subscriptiontype><currency>SEK</currency><amount>500</amount><vat>100</vat><customerrefno>test_recur_NN</customerrefno><returnurl>https://test.sveaekonomi.se/webpay-admin/admin/merchantresponsetest.xhtml</returnurl>
     // 5. the result should be:
     // <response><transaction id="581497"><paymentmethod>KORTCERT</paymentmethod><merchantid>1130</merchantid><customerrefno>test_recur_1</customerrefno><amount>500</amount><currency>SEK</currency><subscriptionid>2922</subscriptionid><cardtype>VISA</cardtype><maskedcardno>444433xxxxxx1100</maskedcardno><expirymonth>02</expirymonth><expiryyear>16</expiryyear><authcode>993955</authcode></transaction><statuscode>0</statuscode></response>
     // 6. enter the received subscription id, etc. below and run the test
     // Set the below to match the original transaction, then run the test.
     $paymentMethod = "KORTCERT";
     $merchantId = 1130;
     $currency = "SEK";
     $cardType = "VISA";
     $maskedCardNumber = "444433xxxxxx1100";
     $expiryMonth = 02;
     $expiryYear = 15;
     $subscriptionId = 3036;
     // the below applies to the recur request, and may differ from the original transaction
     $new_amount = "2500";
     // in minor currency
     $new_clientOrderNumber = "test_recur_" . date('c');
     // below is actual test, shouldn't need to change it
     $request = new RecurTransaction(Svea\SveaConfig::getDefaultConfig());
     $request->subscriptionId = $subscriptionId;
     $request->customerRefNo = $new_clientOrderNumber;
     $request->amount = $new_amount;
     $request->currency = $currency;
     $request->countryCode = "SE";
     $response = $request->doRequest();
     $this->assertInstanceOf("Svea\\HostedService\\RecurTransactionResponse", $response);
     ////print_r($response);
     $this->assertEquals(1, $response->accepted);
     $this->assertEquals("CARD", $response->paymentMethod);
     // CARD is alias for KORTCERT, and this alias is returned by webservice
     $this->assertEquals($merchantId, $response->merchantId);
     $this->assertEquals($currency, $response->currency);
     $this->assertEquals($cardType, $response->cardType);
     $this->assertEquals($maskedCardNumber, $response->maskedCardNumber);
     $this->assertEquals($expiryMonth, $response->expiryMonth);
     $this->assertEquals($expiryYear, $response->expiryYear);
     $this->assertEquals($subscriptionId, $response->subscriptionId);
     $this->assertObjectHasAttribute("transactionId", $response);
     $this->assertEquals($new_clientOrderNumber, $response->clientOrderNumber);
     $this->assertEquals($new_amount, $response->amount);
 }
コード例 #20
0
 /**
  * @expectedException Svea\ValidationException
  * @expectedExceptionMessage -String length : The field Notes must be a string with a maximum length of 200.
  *
  */
 public function test_updateorder_addnotes_chars_validate_invoice()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $request = WebPayAdmin::updateOrder($config)->setCountryCode('SE')->setOrderId('test')->setNotes('Lorem ipsum dolor sit amet, consectetur adipiscing elit.
                 Nullam faucibus turpis ut nibh cursus, volutpat consectetur odio
                 consequat. Quisque fermentum, augue eget scelerisque hendrerit,
                 libero odio mollis metus, eleifend semper enim ligula eu eros.
                 Nullam varius, nunc sit amet tincidunt volutpat, sem sapien semper
                 libero, at consectetur arcu nulla quis dolor. Nunc bibendum vulputate
                 consequat. Mauris luctus dolor non dui aliquet, ut finibus metus porttitor.
                 Etiam ut lacinia augue, id fringilla lorem. Duis vel pellentesque purus,
                 in feugiat ligula. Curabitur efficitur, nunc et mattis volutpat,
                 urna turpis tempus magna, nec convallis nisi mauris ut eros. ')->updateInvoiceOrder()->prepareRequest();
     $this->assertEquals($this->notes, $request->Notes->enc_value);
 }
コード例 #21
0
 /**
  * test_manual_annul_card 
  * 
  * run this manually after you've performed a card transaction and have set
  * the transaction status to success using the tools in the logg admin.
  */
 function test_manual_annul_card()
 {
     // Stop here and mark this test as incomplete.
     $this->markTestIncomplete('skeleton for manual test of annul card transaction');
     // Set the below to match the transaction, then run the test.
     $customerrefno = "794";
     $transactionId = 587947;
     $request = new AnnulTransaction(Svea\SveaConfig::getDefaultConfig());
     $request->transactionId = $transactionId;
     $request->countryCode = "SE";
     $response = $request->doRequest();
     //print_r( $response);
     $this->assertInstanceOf("Svea\\HostedService\\AnnulTransactionResponse", $response);
     $this->assertEquals(1, $response->accepted);
     $this->assertStringMatchesFormat("%d", $response->transactionId);
     // %d => an unsigned integer value
     $this->assertEquals($customerrefno, $response->clientOrderNumber);
 }
コード例 #22
0
 public function testResultGetPaymentPlanParams()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $paymentPlanRequest = new GetPaymentPlanParams($config);
     $request = $paymentPlanRequest->setCountryCode("SE")->doRequest();
     $this->assertEquals(1, $request->accepted);
     $this->assertEquals(0, $request->resultcode);
     //        $this->assertEquals(213060, $request->campaignCodes[0]->campaignCode);//don't test to be flexible
     $this->assertEquals('Köp nu betala om 3 månader (räntefritt)', $request->campaignCodes[0]->description);
     $this->assertEquals('InterestAndAmortizationFree', $request->campaignCodes[0]->paymentPlanType);
     $this->assertEquals(3, $request->campaignCodes[0]->contractLengthInMonths);
     $this->assertEquals(100, $request->campaignCodes[0]->initialFee);
     $this->assertEquals(29, $request->campaignCodes[0]->notificationFee);
     $this->assertEquals(0, $request->campaignCodes[0]->interestRatePercent);
     $this->assertEquals(3, $request->campaignCodes[0]->numberOfInterestFreeMonths);
     $this->assertEquals(3, $request->campaignCodes[0]->numberOfPaymentFreeMonths);
     $this->assertEquals(1000, $request->campaignCodes[0]->fromAmount);
     $this->assertEquals(50000, $request->campaignCodes[0]->toAmount);
 }
 public function test_cancel_multiple_paymentplan_orderRows_()
 {
     // create order
     $country = "SE";
     $campaigncode = TestUtil::getGetPaymentPlanParamsForTesting();
     $order = TestUtil::createOrder(TestUtil::createIndividualCustomer($country))->addOrderRow(WebPayItem::orderRow()->setDescription("second row")->setQuantity(1)->setAmountExVat(1600.0)->setVatPercent(25))->addOrderRow(WebPayItem::orderRow()->setDescription("third row")->setQuantity(1)->setAmountExVat(2400.0)->setVatPercent(25));
     $orderResponse = $order->usePaymentPlanPayment($campaigncode)->doRequest();
     ////print_r( $orderResponse );
     $this->assertEquals(1, $orderResponse->accepted);
     $myOrderId = $orderResponse->sveaOrderId;
     // cancel first row in order
     $cancelOrderRowsRequest = WebPayAdmin::cancelOrderRows(Svea\SveaConfig::getDefaultConfig());
     $cancelOrderRowsRequest->setCountryCode($country);
     $cancelOrderRowsRequest->setOrderId($myOrderId);
     $cancelOrderRowsRequest->setRowsToCancel(array(1, 2));
     $cancelOrderRowsResponse = $cancelOrderRowsRequest->cancelPaymentPlanOrderRows()->doRequest();
     ////print_r( $cancelOrderRowsResponse );
     $this->assertInstanceOf('Svea\\AdminService\\CancelOrderRowsResponse', $cancelOrderRowsResponse);
     $this->assertEquals(1, $cancelOrderRowsResponse->accepted);
 }
コード例 #24
0
 /**
  * 1. create an Invoice|PaymentPlan order
  * 2. note the client credentials, order number and type, and insert below
  * 3. run the test
  */
 public function test_manual_CancelOrderRequest()
 {
     // Stop here and mark this test as incomplete.
     //        $this->markTestIncomplete(
     //            'skeleton for test_manual_CancelOrderRequest'
     //        );
     $countryCode = "SE";
     $sveaOrderIdToClose = 349698;
     $orderType = \ConfigurationProvider::INVOICE_TYPE;
     $cancelOrderBuilder = new Svea\CancelOrderBuilder(Svea\SveaConfig::getDefaultConfig());
     $cancelOrderBuilder->setCountryCode($countryCode);
     $cancelOrderBuilder->setOrderId($sveaOrderIdToClose);
     $cancelOrderBuilder->orderType = $orderType;
     $request = new Svea\AdminService\CancelOrderRequest($cancelOrderBuilder);
     $response = $request->doRequest();
     ////print_r("cancelorderrequest: "); //print_r( $response );
     $this->assertInstanceOf('Svea\\AdminService\\CancelOrderResponse', $response);
     $this->assertEquals(1, $response->accepted);
     $this->assertEquals(0, $response->resultcode);
 }
コード例 #25
0
 function test_listPaymentMethods_request_success()
 {
     $request = new Svea\HostedService\ListPaymentMethods(Svea\SveaConfig::getDefaultConfig());
     $request->countryCode = "SE";
     $response = $request->doRequest();
     $this->assertInstanceOf("Svea\\HostedService\\ListPaymentMethodsResponse", $response);
     //print_r( "test_listPaymentMethods_request_success: "); //print_r( $response );
     $this->assertEquals(1, $response->accepted);
     $this->assertInternalType("array", $response->paymentmethods);
     // from getpaymentmethods call, tied to merchantid
     $this->assertEquals(PaymentMethod::BANKAXESS, $response->paymentmethods[0]);
     $this->assertEquals(PaymentMethod::NORDEA_SE, $response->paymentmethods[1]);
     $this->assertEquals(PaymentMethod::SEB_SE, $response->paymentmethods[2]);
     $this->assertEquals(PaymentMethod::KORTCERT, $response->paymentmethods[3]);
     $this->assertEquals(\Svea\SystemPaymentMethod::INVOICE_SE, $response->paymentmethods[4]);
     $this->assertEquals(\Svea\SystemPaymentMethod::PAYMENTPLAN_SE, $response->paymentmethods[5]);
     // from ListPaymentMethods implementation, tied to clientid
     $this->assertEquals(PaymentMethod::INVOICE, $response->paymentmethods[6]);
     $this->assertEquals(PaymentMethod::PAYMENTPLAN, $response->paymentmethods[7]);
 }
コード例 #26
0
 /**
  * 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);
 }
コード例 #27
0
 function test_manual_alsoDoConfim_set_to_true_does_lowerTransaction_followed_by_confirmTransaction()
 {
     // Stop here and mark this test as incomplete.
     $this->markTestIncomplete('test_manual_query_card_queryTransaction_returntype');
     // 1. go to https://test.sveaekonomi.se/webpay-admin/admin/start.xhtml
     // 2. go to verktyg -> betalning
     // 3. enter our test merchantid: 1130
     // 4. use the following xml, making sure to update to a unique customerrefno:
     // <paymentmethod>KORTCERT</paymentmethod><currency>SEK</currency><amount>25500</amount><vat>600</vat><customerrefno>test_manual_query_card_2</customerrefno><returnurl>https://test.sveaekonomi.se/webpay/admin/merchantresponsetest.xhtml</returnurl><orderrows><row><name>Orderrow1</name><amount>500</amount><vat>100</vat><description>Orderrow description</description><quantity>1</quantity><sku>123</sku><unit>st</unit></row><row><name>Orderrow2</name><amount>12500</amount><vat>2500</vat><description>Orderrow2 description</description><quantity>2</quantity><sku>124</sku><unit>m2</unit></row></orderrows>
     // 5. the result should be:
     // <response><transaction id="580964"><paymentmethod>KORTCERT</paymentmethod><merchantid>1130</merchantid><customerrefno>test_manual_query_card_3</customerrefno><amount>25500</amount><currency>SEK</currency><cardtype>VISA</cardtype><maskedcardno>444433xxxxxx1100</maskedcardno><expirymonth>02</expirymonth><expiryyear>15</expiryyear><authcode>898924</authcode></transaction><statuscode>0</statuscode></response>
     // 6. enter the received transaction id below and run the test
     // Set the below to match the transaction, then run the test.
     $transactionId = 586184;
     $lowerTransactionRequest = new LowerTransaction(Svea\SveaConfig::getDefaultConfig());
     $lowerTransactionRequest->countryCode = "SE";
     $lowerTransactionRequest->transactionId = $transactionId;
     $lowerTransactionRequest->amountToLower = "1";
     $lowerTransactionRequest->alsoDoConfirm = true;
     $response = $lowerTransactionRequest->doRequest();
     //print_r( $response);
     $this->assertEquals(1, $response->accepted);
     $this->assertInstanceOf("Svea\\HostedService\\ConfirmTransactionResponse", $response);
 }
コード例 #28
0
 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;
 }
コード例 #29
0
 public function test_paymentPlanPricePerMonth_returns_PaymentPlanPricePerMonth()
 {
     $campaigns = WebPay::getPaymentPlanParams(Svea\SveaConfig::getDefaultConfig())->setCountryCode("SE")->doRequest();
     $this->assertTrue($campaigns->accepted);
     $pricesPerMonth = Svea\Helper::paymentPlanPricePerMonth(2000, $campaigns, true);
     $this->assertInstanceOf("Svea\\WebService\\PaymentPlanPricePerMonth", $pricesPerMonth);
     //        $this->assertEquals(213060, $pricesPerMonth->values[0]['campaignCode']); //don't test to be flexible
     $this->assertEquals(2029, $pricesPerMonth->values[0]['pricePerMonth']);
 }
コード例 #30
0
 /**
  * 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);
 }