コード例 #1
0
 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);
 }
コード例 #2
0
 /**
  * Investigation of github php-integration issue #39.
  *
  * Also, an example of how to parse a HostedPaymentRequest response, i.e. at
  * the WebPay::createOrder()->..->useCardPayment->getPaymentForm() returnurl
  * by passing the response post data through SveaResponse() to get a response
  * object matching the original payment request.
  */
 public function test_successful_test_card_order_has_accepted_non_zero()
 {
     // getSingleCountryConfig fetches a SveaConfigurationProvider object that implements ConfigurationProvider
     // as we don't set any parameters, the object contains only default values, i.e. the merchantid used is 1130
     $config = SveaConfig::getSingleCountryConfig(null, null, null, null, null, null, null, null, null, false);
     // $message, $mac and $merchantid below was taken from server logs for a test card transaction to the merchant 1130
     $message = "PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0nVVRGLTgnPz48cmVzcG9uc2U+PHRyYW5zYWN0aW9uIGlkPSI1ODEzODAiPjxwYXltZW50bWV0aG9kPktPUlRDRVJUPC9wYXltZW50bWV0aG9kPjxtZXJjaGFudGlkPjExMzA8L21lcmNoYW50aWQ+PGN1c3RvbWVycmVmbm8+MzY8L2N1c3RvbWVycmVmbm8+PGFtb3VudD4xODU3ODwvYW1vdW50PjxjdXJyZW5jeT5TRUs8L2N1cnJlbmN5PjxjYXJkdHlwZT5WSVNBPC9jYXJkdHlwZT48bWFza2VkY2FyZG5vPjQ0NDQzM3h4eHh4eDExMDA8L21hc2tlZGNhcmRubz48ZXhwaXJ5bW9udGg+MDE8L2V4cGlyeW1vbnRoPjxleHBpcnl5ZWFyPjE1PC9leHBpcnl5ZWFyPjxhdXRoY29kZT40NTM2MjY8L2F1dGhjb2RlPjxjdXN0b21lcj48Zmlyc3RuYW1lLz48bGFzdG5hbWUvPjxpbml0aWFscy8+PGVtYWlsPnRlc3RAdGltLWludGVybmF0aW9uYWwubmV0PC9lbWFpbD48c3NuPjwvc3NuPjxhZGRyZXNzPktsb2NrYXJnYXRhbiA1QzwvYWRkcmVzcz48YWRkcmVzczIvPjxjaXR5PlbDpHN0ZXLDpXM8L2NpdHk+PGNvdW50cnk+U0U8L2NvdW50cnk+PHppcD43MjM0NDwvemlwPjxwaG9uZT40NjcwNDE2MDA5MDwvcGhvbmU+PHZhdG51bWJlci8+PGhvdXNlbnVtYmVyPjU8L2hvdXNlbnVtYmVyPjxjb21wYW55bmFtZS8+PGZ1bGxuYW1lLz48L2N1c3RvbWVyPjwvdHJhbnNhY3Rpb24+PHN0YXR1c2NvZGU+MDwvc3RhdHVzY29kZT48L3Jlc3BvbnNlPg==";
     $mac = "0411ed66739c251308b70c642fc5f7282f89050421408b74bdd909fb0c13c37c4c2efd6da3593dc388dd28952478aeb1ce5259caf33fd68d364fc4f82914e055";
     $merchantId = $config->getMerchantId(\ConfigurationProvider::HOSTED_TYPE, "SE");
     // the $rawresponse is similar to what we get posted back to our return url following a CardPayment post to i.e. the certitrade payment page
     $rawresponse = array();
     $rawresponse['response'] = $message;
     $rawresponse['mac'] = $mac;
     $rawresponse['merchantId'] = $merchantId;
     // $rawresponse is then put into the SveaResponse constructor along with the country and config object
     $sveaResponse = new \SveaResponse($rawresponse, "SE", $config);
     // the resulting $response HostedPaymentResponse object contains all relevant information about the payment
     $response = $sveaResponse->getResponse();
     // uncomment the following to see the resulting response
     //        //print_r( $response ); // accepted is show as having value of 1
     //        var_dump( $response );  // note that var_dump lists accepted as 'int(1)' meaning an int with value 1 (in contrast to 'string(3) "SEK"')
     //
     //        if( empty($response->accepted) ) { //print_r( "test accepted is empty" ); }
     //        if( !empty($response->accepted) ) { //print_r( "test accepted not empty" ); }
     $this->assertInstanceOf('Svea\\HostedService\\HostedPaymentResponse', $response);
     $this->assertEquals(1, $response->accepted);
 }
コード例 #3
0
 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);
 }
コード例 #4
0
 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);
 }
コード例 #5
0
 public function testDefaultTestConfig()
 {
     $config = SveaConfig::getDefaultConfig();
     $this->assertEquals("sverigetest", $config->getUsername("Invoice", "SE"));
     $this->assertEquals("sverigetest", $config->getPassword("PaymentPlan", "SE"));
     $this->assertEquals("16997", $config->getClientNumber("PaymentPlan", "DE"));
     $this->assertEquals("1130", $config->getMerchantId("HOSTED", "NL"));
     $this->assertEquals("https://webservices.sveaekonomi.se/webpay_test/SveaWebPay.asmx?WSDL", $config->getEndPoint("Invoice"));
 }
コード例 #6
0
 /**
  * @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();
 }
コード例 #7
0
 function setUp()
 {
     $this->queryOrderObject = new QueryOrderBuilder(SveaConfig::getDefaultConfig());
 }
コード例 #8
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);
 }
コード例 #9
0
 /**
  * @expectedException Svea\InvalidCountryException
  */
 public function test_getSveaSingleCountryConfig_throws_InvalidCountryException_for_invalid_country()
 {
     $config = SveaConfig::getSingleCountryConfig(null, null, null, null, null, null, null, null, null, null);
     $config->getUsername(\ConfigurationProvider::INVOICE_TYPE, "NO");
 }
コード例 #10
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);
 }
コード例 #11
0
 function setUp()
 {
     $this->deliverOrderRowsObject = new deliverOrderRowsBuilder(SveaConfig::getDefaultConfig());
 }
コード例 #12
0
 /**
  * @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();
 }
コード例 #13
0
 public function testOrderRowsInOrderAsAdded2OnHosted()
 {
     $config = SveaConfig::getDefaultConfig();
     $request = \WebPay::createOrder($config);
     $form = $request->addFee(\WebPayItem::shippingFee()->setDescription("1")->setVatPercent(25)->setAmountIncVat(30))->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))->setCountryCode("SE")->setClientOrderNumber("33")->setOrderDate("2012-12-12")->setCurrency("SEK")->usePaymentMethod(\PaymentMethod::SVEACARDPAY)->setReturnUrl("http://myurl.se")->getPaymentForm();
     $xmlMessage = new \SimpleXMLElement($form->xmlMessage);
     $this->assertEquals('1', $xmlMessage->orderrows->row[0]->description);
     $this->assertEquals('2', $xmlMessage->orderrows->row[1]->description);
     $this->assertEquals('3', $xmlMessage->orderrows->row[2]->description);
     $this->assertEquals('4', $xmlMessage->orderrows->row[3]->description);
 }
コード例 #14
0
 public function testBuildOrderWithClientOrderNumber()
 {
     $config = SveaConfig::getDefaultConfig();
     $sveaRequest = \WebPay::createOrder($config)->setClientOrderNumber("33");
     $this->assertEquals("33", $sveaRequest->clientOrderNumber);
 }
コード例 #15
0
 function setUp()
 {
     $this->cancelOrderRowsObject = new CancelOrderRowsBuilder(SveaConfig::getDefaultConfig());
 }
コード例 #16
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();
 }
コード例 #17
0
 function setUp()
 {
     $this->updateOrderRowsObject = new UpdateOrderRowsBuilder(SveaConfig::getDefaultConfig());
 }