コード例 #1
0
 public function test_createOrder_usePaymentMethod_KORTCERT_redirects_to_certitrade()
 {
     $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")->usePaymentMethod(PaymentMethod::KORTCERT)->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);
     $this->assertEquals(200, $info['http_code']);
     $this->assertEquals(1, $info['redirect_count']);
     $this->assertEquals("https://etest.certitrade.net/card/paywin/index", substr($info['url'], 0, 46));
 }
コード例 #2
0
 public function testPaymentPlanRequestObjectSpecifics()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $rowFactory = new TestUtil();
     $request = WebPay::createOrder($config)->addOrderRow(TestUtil::createOrderRow())->run($rowFactory->buildShippingFee())->addCustomerDetails(WebPayItem::individualCustomer()->setNationalIdNumber(194605092222))->setCountryCode("SE")->setCustomerReference("33")->setClientOrderNumber("nr26")->setOrderDate("2012-12-12")->setCurrency("SEK")->usePaymentPlanPayment("camp1")->prepareRequest();
     $this->assertEquals('camp1', $request->request->CreateOrderInformation->CreatePaymentPlanDetails['CampaignCode']);
     $this->assertEquals(0, $request->request->CreateOrderInformation->CreatePaymentPlanDetails['SendAutomaticGiroPaymentForm']);
 }
コード例 #3
0
 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]);
 }
コード例 #4
0
 public function testBuildOrderWithShippingFee()
 {
     $rowFactory = new \TestUtil();
     $config = SveaConfig::getDefaultConfig();
     $sveaRequest = \WebPay::createOrder($config)->run($rowFactory->buildShippingFee());
     $this->assertEquals("Specification", $sveaRequest->shippingFeeRows[0]->description);
     $this->assertEquals(50, $sveaRequest->shippingFeeRows[0]->amountExVat);
     $this->assertEquals(25, $sveaRequest->shippingFeeRows[0]->vatPercent);
 }
コード例 #5
0
 public function testPayPagePaymentWithSetPaymentMethodInvoice()
 {
     $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::companyCustomer()->setNationalIdNumber(4608142222))->setCountryCode("SE")->setClientOrderNumber("33")->setOrderDate("2012-12-12")->setCurrency("SEK")->usePaymentMethod(\PaymentMethod::INVOICE)->setReturnUrl("http://myurl.se")->getPaymentForm();
     $xmlMessage = new \SimpleXMLElement($form->xmlMessage);
     $this->assertEquals(SystemPaymentMethod::INVOICE_SE, $xmlMessage->paymentmethod[0]);
     $this->assertEquals("TRUE", $xmlMessage->iscompany);
     $this->assertEquals("4608142222", $xmlMessage->customer->ssn);
 }
コード例 #6
0
 public function testConfigureExcludedPaymentMethods()
 {
     $config = SveaConfig::getDefaultConfig();
     $rowFactory = new \TestUtil();
     $form = \WebPay::createOrder($config)->addOrderRow(\TestUtil::createOrderRow())->run($rowFactory->buildShippingFee())->addCustomerDetails(\WebPayItem::individualCustomer()->setNationalIdNumber(194605092222))->setCountryCode("SE")->setClientOrderNumber("33")->setOrderDate("2012-12-12")->setCurrency("SEK")->usePayPageDirectBankOnly()->setReturnUrl("http://myurl.se")->getPaymentForm();
     $xmlMessage = new \SimpleXMLElement($form->xmlMessage);
     //        $excluded = (array)$xmlMessage->excludepaymentmethods->exclude; // only works with php 5.5
     //        $this->assertTrue( in_array( SystemPaymentMethod::KORTCERT, $excluded ) );
     //        $this->assertTrue( in_array( SystemPaymentMethod::SKRILL, $excluded ) );
     //        $this->assertTrue( in_array( SystemPaymentMethod::PAYPAL, $excluded ) );
     $this->assertEquals(SystemPaymentMethod::KORTCERT, $xmlMessage->excludepaymentmethods->exclude[14]);
     $this->assertEquals(SystemPaymentMethod::SKRILL, $xmlMessage->excludepaymentmethods->exclude[15]);
     $this->assertEquals(SystemPaymentMethod::PAYPAL, $xmlMessage->excludepaymentmethods->exclude[16]);
 }
コード例 #7
0
 public function testBuildCardPayment()
 {
     $rowFactory = new \TestUtil();
     $config = SveaConfig::getDefaultConfig();
     $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::companyCustomer()->setNationalIdNumber("2345234"))->setCountryCode("SE")->setClientOrderNumber("33")->setOrderDate("2012-12-12")->setCurrency("SEK")->usePayPageCardOnly()->setReturnUrl("http://myurl.se")->getPaymentForm();
     $xmlMessage = new \SimpleXMLElement($form->xmlMessage);
     $payment = base64_decode($form->xmlMessageBase64);
     $payment_decoded = new \SimpleXMLElement($payment);
     //test values are as expected avter transforming xml to php object
     $this->assertEquals('SEK', $xmlMessage->currency);
     $this->assertEquals('18750', $xmlMessage->amount);
     $this->assertEquals('3750', $xmlMessage->vat);
     $this->assertEquals('12500', $xmlMessage->orderrows->row[0]->amount);
     $this->assertEquals('6250', $xmlMessage->orderrows->row[1]->amount);
     $this->assertEquals('-12500', $xmlMessage->orderrows->row[2]->amount);
 }
コード例 #8
0
 public function testInvoiceRequestObjectWithAuth()
 {
     $config = Svea\SveaConfig::getDefaultConfig();
     $rowFactory = new TestUtil();
     $request = WebPay::createOrder($config)->addOrderRow(TestUtil::createOrderRow())->run($rowFactory->buildShippingFee())->addCustomerDetails(WebPayItem::companyCustomer()->setNationalIdNumber(194605092222)->setAddressSelector("ad33"))->setCountryCode("SE")->setCustomerReference("33")->setClientOrderNumber("nr26")->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);
 }