Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Fredrik Sundell committed Sep 11, 2019
2 parents c3fd4d7 + 15c5e48 commit ab2f83f
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 119 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sveaekonomi/webpay",
"version": "3.11.0",
"version": "3.11.1",
"description": "Php integration library for Svea Ekonomis payment methods",
"license": "Apache-2.0",
"authors": [
Expand Down
20 changes: 8 additions & 12 deletions example/cardorder_recur/recurorder.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,28 @@
->setAmountExVat(100.00)
->setVatPercent(25)
->setQuantity(1)
->setDescription("Månadsavgift via recur")
->setDescription("Monthly recurring fee")
);

// 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::KORTCERT), which processes card orders via SveaCardPay.
$myRecurOrderRequest = $myOrder->usePaymentMethod(PaymentMethod::SVEACARDPAY);

// For recurring card payments, use setSubscriptionId() on the request object, using the subscription id from the initial request response
// We now need to setSubscriptionId() on the request object, using the subscription id from the initial request response
$mySubscriptionId = file_get_contents("subscription.txt");
if ($mySubscriptionId) {

if ($mySubscriptionId)
{
$myRecurOrderRequest->setSubscriptionId($mySubscriptionId);
} // or, abort if subscription.txt is missing
else {
}
else // or, abort if subscription.txt is missing
{
echo "<pre>Error: subscription.txt not found, first run cardorder_recur.php to set up the card order subscription. aborting.";
die;
}

// Then set any additional required request attributes as detailed below. (See Svea\PaymentMethodPayment and Svea\HostedPayment classes for details.)
$myRecurOrderRequest
->setCardPageLanguage("SV")// ISO639 language code, i.e. "SV", "EN" etc. Defaults to English.
->setReturnUrl("http://localhost/" . getPath() . "/landingpage_recur.php"); // The return url where we receive and process the finished request response

// Send the recur payment request to Svea
$myRecurOrderResponse = $myRecurOrderRequest->doRecur();

// Then send the form to Svea, and receive the response on the landingpage after the customer has completed the card checkout at SveaCardPay
echo "<pre>";
print_r("the recur order response");
print_r($myRecurOrderResponse);
Expand Down
102 changes: 0 additions & 102 deletions src/Checkout/Model/CheckoutSubsystemInfo.php

This file was deleted.

6 changes: 3 additions & 3 deletions src/Helper/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,14 @@ static function getSveaLibraryProperties()
if (!defined('SVEA_REQUEST_DIR')) {
define('SVEA_REQUEST_DIR', dirname(__FILE__));
}
$composerFile = file_get_contents(SVEA_REQUEST_DIR . "/../../composer.json");
$composerFile= json_decode($composerFile, true);
$versionFile = file_get_contents(SVEA_REQUEST_DIR . "/../../version.json");
$versionFile= json_decode($versionFile, true);


// @todo change this to properly defined information
$library_properties = array(
'library_name' => 'PHP Integration Package',
'library_version' => $composerFile['version'],
'library_version' => $versionFile['version'],
);

return $library_properties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ protected function formatXml($hostedAdminResponseXML)
function calculateVatPercentFromVatAndAmount($vat, $amount)
{
$amountExVat = ($amount - $vat);
$unroundedVatPercent = ($amountExVat > 0) ? ($vat / $amountExVat) : 0.00; // catch potential divide by zero
$unroundedVatPercent = ($amountExVat != 0) ? ($vat / $amountExVat) : 0.00; // catch potential divide by zero
$vatPercent = Helper::bround($unroundedVatPercent, 2) * 100; // OrderRow has vatpercent as int.
return $vatPercent;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php


namespace Svea\WebPay\Test\UnitTest\HostedService\HandleOrder;


use Svea\WebPay\HostedService\HostedResponse\HostedAdminResponse\QueryTransactionResponse;

class QueryTransactionResponseTest extends \PHPUnit\Framework\TestCase
{
function test_calculateVatPercentFromVatAndAmount_returns_correct_vatpercent_if_transactions_contains_negative_row()
{
$queryTransactionResponse = new QueryTransactionResponse("", "", "");

$test = $queryTransactionResponse->calculateVatPercentFromVatAndAmount("-1252", "-6262");

$this->assertEquals("25.00", $test);
}

function test_calculateVatPercentFromVatAndAmount_returns_correct_vatpercent_if_transactions_contains_positive_row()
{
$queryTransactionResponse = new QueryTransactionResponse("", "", "");

$test = $queryTransactionResponse->calculateVatPercentFromVatAndAmount("1252", "6262");

$this->assertEquals("25.00", $test);
}

function test_calculateVatPercentFromVatAndAmount_returns_correct_vatpercent_if_transactions_contains_zero_amount_row()
{
$queryTransactionResponse = new QueryTransactionResponse("", "", "");

$test = $queryTransactionResponse->calculateVatPercentFromVatAndAmount("0", "0");

$this->assertEquals("0.00", $test);
}
}
3 changes: 3 additions & 0 deletions version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"version": "3.11.1"
}

0 comments on commit ab2f83f

Please sign in to comment.