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); }
public function test_setPayPageLanguage_with_recognised_language() { $orderLanguage = "sv"; $order = \TestUtil::createOrder(); $payment = $order->usePaymentMethod(\PaymentMethod::KORTCERT)->setPayPageLanguage($orderLanguage); $this->assertEquals($orderLanguage, $payment->langCode); }
public function test_deliver_multiple_invoice_orderRows_returns_accepted_with_invoiceId() { // create order $country = "SE"; $order = TestUtil::createOrder(TestUtil::createIndividualCustomer($country))->addOrderRow(WebPayItem::orderRow()->setDescription("second row")->setQuantity(1)->setAmountExVat(16.0)->setVatPercent(25))->addOrderRow(WebPayItem::orderRow()->setDescription("third row")->setQuantity(1)->setAmountExVat(24.0)->setVatPercent(25)); $orderResponse = $order->useInvoicePayment()->doRequest(); ////print_r( $orderResponse ); $this->assertEquals(1, $orderResponse->accepted); $myOrderId = $orderResponse->sveaOrderId; // deliver first row in order $deliverOrderRowsRequest = WebPayAdmin::deliverOrderRows(Svea\SveaConfig::getDefaultConfig()); $deliverOrderRowsRequest->setCountryCode($country); $deliverOrderRowsRequest->setOrderId($myOrderId); $deliverOrderRowsRequest->setInvoiceDistributionType(DistributionType::POST); $deliverOrderRowsRequest->setRowsToDeliver(array(1, 2)); $deliverOrderRowsResponse = $deliverOrderRowsRequest->deliverInvoiceOrderRows()->doRequest(); ////print_r( $deliverOrderRowsResponse ); $this->assertInstanceOf('Svea\\AdminService\\DeliverPartialResponse', $deliverOrderRowsResponse); $this->assertEquals(true, $deliverOrderRowsResponse->accepted); // truth $this->assertEquals(1, $deliverOrderRowsResponse->accepted); // equals literal 1 $this->assertEquals(0, $deliverOrderRowsResponse->resultcode); $this->assertEquals(270.0, $deliverOrderRowsResponse->amount); $this->assertEquals("Invoice", $deliverOrderRowsResponse->orderType); $this->assertNotNull($deliverOrderRowsResponse->invoiceId); }
function test_CancelOrderBuilder_PaymentPlan_success() { $country = "SE"; $order = TestUtil::createOrder(TestUtil::createIndividualCustomer($country))->addOrderRow(WebPayItem::orderRow()->setQuantity(1)->setAmountExVat(1000.0)->setVatPercent(25)); $orderResponse = $order->usePaymentPlanPayment(TestUtil::getGetPaymentPlanParamsForTesting())->doRequest(); $this->assertEquals(1, $orderResponse->accepted); $cancelResponse = WebPayAdmin::cancelOrder(Svea\SveaConfig::getDefaultConfig())->setOrderId($orderResponse->sveaOrderId)->setCountryCode($country)->cancelPaymentPlanOrder()->doRequest(); $this->assertEquals(1, $cancelResponse->accepted); }
public function test_deliverOrder_deliverInvoiceOrder_without_orderrows_use_admin_service_deliverOrders_and_is_accepted() { // create order, get orderid to deliver $createOrderBuilder = TestUtil::createOrder(); $createResponse = $createOrderBuilder->useInvoicePayment()->doRequest(); $this->assertEquals(1, $createResponse->accepted); $orderId = $createResponse->sveaOrderId; $DeliverOrderBuilder = WebPay::deliverOrder(Svea\SveaConfig::getDefaultConfig())->setCountryCode("SE")->setOrderId($orderId)->setInvoiceDistributionType(\DistributionType::POST); // example of raw deliver orders response to parse // //stdClass Object //( // [ErrorMessage] => // [ResultCode] => 0 // [OrdersDelivered] => stdClass Object // ( // [DeliverOrderResult] => stdClass Object // ( // [ClientId] => 79021 // [DeliveredAmount] => 250.00 // [DeliveryReferenceNumber] => 1033890 // [OrderType] => Invoice // [SveaOrderId] => 414157 // ) // // ) // //) $deliverResponse = $DeliverOrderBuilder->deliverInvoiceOrder()->doRequest(); ////print_r( $deliverResponse ); //Svea\AdminService\DeliverOrdersResponse Object //( // [clientId] => 79021 // [amount] => 250.00 // [invoiceId] => // [contractNumber] => // [orderType] => Invoice // [orderId] => 414168 // [accepted] => 1 // [resultcode] => 0 // [errormessage] => //) $this->assertInstanceOf("Svea\\AdminService\\DeliverOrdersResponse", $deliverResponse); $this->assertEquals(1, $deliverResponse->accepted); $this->assertEquals(0, $deliverResponse->resultcode); $this->assertEquals(null, $deliverResponse->errormessage); $this->assertEquals(79021, $deliverResponse->clientId); $this->assertEquals(250.0, $deliverResponse->amount); $this->assertStringMatchesFormat("%d", $deliverResponse->invoiceId); // %d => an unsigned integer value $this->assertEquals(null, $deliverResponse->contractNumber); $this->assertEquals("Invoice", $deliverResponse->orderType); $this->assertStringMatchesFormat("%d", $deliverResponse->orderId); // %d => an unsigned integer value }
/** * test_confirmTransaction_card_success creates an order using card payment, * pays using card & receives a transaction id, then confirms the transaction * * used as acceptance criteria/smoke test for credit transaction feature */ function test_confirmTransaction_card_success() { // not yet implemented, requires webdriver support // Stop here and mark this test as incomplete. $this->markTestIncomplete('not yet implemented, requires webdriver support'); // also, needs to have SUCCESS status set on transaction // set up order (from testUtil?) $order = TestUtil::createOrder(); // pay with card, receive transactionId $form = $order->UsePaymentMethod(PaymentMethod::KORTCERT)->setReturnUrl("http://myurl.se")->getPaymentForm(); $url = "https://test.sveaekonomi.se/webpay/payment"; // do request modeled on CardPaymentIntegrationTest.php // make sure the transaction has status AUTHORIZED at Svea // confirm transcation using above the transaction transactionId // assert response from confirmTransaction equals success }
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); }
/** * test_manual_recurring_payment_step_1 * * 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. */ public function test_manual_recurring_payment_step_1() { // Stop here and mark this test as incomplete. $this->markTestIncomplete('skeleton for manual test of recurring payment'); // 1. remove (put in a comment) the above code to enable the test // 2. run the test, and get the subscription paymenturl from the output // 3. go to the paymenturl and complete the transaction. // 4. go to https://test.sveaekonomi.se/webpay-admin/admin/start.xhtml // 5. retrieve the subscriptionId from the response in the transaction log // 6. use the subscriptionId to run $orderLanguage = "sv"; $returnUrl = "http://foo.bar.com"; $ipAddress = "127.0.0.1"; // create order $order = \TestUtil::createOrder(TestUtil::createIndividualCustomer("SE")->setIpAddress($ipAddress)); // set payment method // call getPaymentURL $response = $order->usePayPageCardOnly()->setPayPageLanguage($orderLanguage)->setReturnUrl($returnUrl)->setSubscriptionType(Svea\HostedService\CardPayment::RECURRINGCAPTURE)->getPaymentUrl(); // check that request was accepted $this->assertEquals(1, $response->accepted); // print the url to use to confirm the transaction //print_r( " test_manual_recurring_payment_step_1(): " . $response->testurl ." "); }
public function test_createOrder_Invoice_SE_Accepted() { $order = TestUtil::createOrder(); $response = $order->useInvoicePayment()->doRequest(); $this->assertEquals(1, $response->accepted); }
/** * test that <subscriptiontype> is included in payment request xml */ public function test_cardPayment_request_xml_includes_subscriptiontype() { $cardPayment = new CardPayment(\TestUtil::createOrder()->setClientOrderNumber("33")); $cardPayment->setSubscriptionType(CardPayment::RECURRINGCAPTURE)->setCallbackUrl("http://myurl.se")->setReturnUrl("http://myurl.se"); $paymentForm = $cardPayment->getPaymentForm(); $subscriptiontype = "<subscriptiontype>RECURRINGCAPTURE<\\/subscriptiontype>"; // remember to escape <_/_subscriptiontype> //$this->assertRegExp("/[a-zA-Z0-9<>]*".$subscriptiontype."[a-zA-Z0-9<>]*/","foo<subscriptiontype>RECURRINGCAPTURE</subscriptiontype>bar"); ////print_r($paymentForm->xmlMessage); $this->assertRegExp("/[a-zA-Z0-9<>]*" . $subscriptiontype . "[a-zA-Z0-9<>]*/", $paymentForm->xmlMessage); }
/** * test_manual_CardPayment_getPaymentURL */ public function test_CardPayment_getPaymentUrl_response_remake() { // Stop here and mark this test as incomplete. // $this->markTestIncomplete( // 'skeleton for manual test of card payment' // ); // 1. remove (put in a comment) the above code to enable the test // 2. run the test, and get the subscription paymenturl from the output // 3. go to the paymenturl and complete the transaction. // 4. go to https://test.sveaekonomi.se/webpay-admin/admin/start.xhtml // 5. retrieve the transactionid from the response in the transaction log $orderLanguage = "sv"; $returnUrl = "http://foo.bar.com"; $ipAddress = "127.0.0.1"; // create order $order = \TestUtil::createOrder(TestUtil::createIndividualCustomer("SE")->setIpAddress($ipAddress)); // set payment method // call getPaymentURL $response = $order->setClientOrderNumber("foobar" . date('c'))->usePaymentMethod(\PaymentMethod::KORTCERT)->setPayPageLanguage($orderLanguage)->setReturnUrl($returnUrl)->getPaymentUrl(); // check that request was accepted $this->assertEquals(1, $response->accepted); $this->assertEquals($response->testurl, $response->url); //url should always contain the url where the order is created in //and test is always test. In this case booth should therefore be test }
public function test_GetOrdersRequest_for_invoice_sets_company_customer_correctly() { // create order $country = "SE"; $order = TestUtil::createOrder(TestUtil::createCompanyCustomer($country)); //case( "SE" ): // return WebPayItem::companyCustomer() // ->setNationalIdNumber("4608142222") // ->setCompanyName("Tess T", "Persson") // ->setStreetAddress("Testgatan", 1) // ->setCoAddress("c/o Eriksson, Erik") // ->setLocality("Stan") // ->setZipCode("99999"); // break; $order->addOrderRow(TestUtil::createOrderRow(1000.0)); $orderResponse = $order->useInvoicePayment()->doRequest(); $this->assertEquals(1, $orderResponse->accepted); $countryCode = "SE"; $sveaOrderIdToGet = $orderResponse->sveaOrderId; $orderType = ConfigurationProvider::INVOICE_TYPE; $getOrdersBuilder = new Svea\QueryOrderBuilder(Svea\SveaConfig::getDefaultConfig()); $getOrdersBuilder->setOrderId($sveaOrderIdToGet); $getOrdersBuilder->setCountryCode($countryCode); $getOrdersBuilder->orderType = $orderType; $request = new Svea\AdminService\GetOrdersRequest($getOrdersBuilder); $getOrdersResponse = $request->doRequest(); // Example test_GetOrdersRequest_for_invoice_company_customer_order raw request response // //stdClass Object //( // /.../ // [Customer] => stdClass Object // ( // [CoAddress] => c/o Eriksson, Erik // [CompanyIdentity] => stdClass Object // ( // [CompanyIdentification] => // [CompanyVatNumber] => // ) // // [CountryCode] => SE // [CustomerType] => Company // [Email] => // [FullName] => Persson, Tess T // [HouseNumber] => // [IndividualIdentity] => // [Locality] => Stan // [NationalIdNumber] => 164608142222 // [PhoneNumber] => // [PublicKey] => // [Street] => Testgatan 1 // [ZipCode] => 99999 // ) // /.../ // ) ////print_r( $getOrdersResponse ); $this->assertInstanceOf('Svea\\AdminService\\GetOrdersResponse', $getOrdersResponse); $this->assertEquals(1, $getOrdersResponse->accepted); $this->assertEquals(0, $getOrdersResponse->resultcode); $this->assertEquals(null, $getOrdersResponse->errormessage); $this->assertInstanceOf("Svea\\CompanyCustomer", $getOrdersResponse->customer); $this->assertEquals("194608142222", $getOrdersResponse->customer->orgNumber); $this->assertEquals(null, $getOrdersResponse->customer->companyVatNumber); $this->assertEquals("Persson, Tess T", $getOrdersResponse->customer->companyName); $this->assertEquals(null, $getOrdersResponse->customer->email); $this->assertEquals(null, $getOrdersResponse->customer->phonenumber); $this->assertEquals("Testgatan 1", $getOrdersResponse->customer->streetAddress); $this->assertEquals("Testgatan 1", $getOrdersResponse->customer->street); $this->assertEquals("c/o Eriksson, Erik", $getOrdersResponse->customer->coAddress); $this->assertEquals("99999", $getOrdersResponse->customer->zipCode); $this->assertEquals("Stan", $getOrdersResponse->customer->locality); }