-
Notifications
You must be signed in to change notification settings - Fork 19
/
landingpage.php
75 lines (57 loc) · 2.06 KB
/
landingpage.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
* example file, how to handle a swish order request response
*
* @author Fredrik Sundell / fre-sund
*/
require_once '../../vendor/autoload.php';
use Svea\WebPay\Response\SveaResponse;
error_reporting( E_ALL );
ini_set('display_errors', 'On');
// get config object
$myConfig = \Svea\WebPay\Config\ConfigurationService::getTestConfig();
// the raw request response is posted to the returnurl (this page) from Svea.
$rawResponse = $_REQUEST;
// decode the raw response by passing it through the Svea\WebPay\Response\SveaResponse class
try
{
$myResponse = new SveaResponse($rawResponse, $countryCode = NULL, $myConfig);
}
catch (Exception $e)
{
echo $e->getMessage();
}
// The decoded response is available through the ->getResponse() method.
// Check the response attribute 'accepted' for true to see if the request succeeded, if not, see the attributes resultcode and/or errormessage
echo "<pre>Your request response:\n\n";
print_r( $myResponse->getResponse() );
echo "\n</pre><font color='blue'><pre>\n\n
An example of a successful request response. The 'accepted' attribute is true (1), and resultcode/errormessage is not set.
Svea\WebPay\HostedService\HostedResponse\HostedPaymentResponse Object
(
[transactionId] => 722742
[clientOrderNumber] => order #2019-11-29T14:28:35 01:00
[paymentMethod] => SWISH
[merchantId] => 1130
[amount] => 3.75
[currency] => SEK
[accepted] => 1
[resultcode] =>
[errormessage] =>
)
)";
echo "\n</pre><font color='red'><pre>\n\n
An example of a rejected request response -- 'accepted' is false (0) and resultcode/errormessage indicates that the clientOrderNumber above has been reused, which is prohibited.
Svea\HostedPaymentResponse Object
(
[transactionId] => 582828
[clientOrderNumber] => order #2019-11-29T14:28:35 01:00
[paymentMethod] => SWISH
[merchantId] => 1130
[amount] => 3.75
[currency] => SEK
[accepted] => 0
[resultcode] => 127 (CUSTOMERREFNO_ALREADY_USED)
[errormessage] => Customer reference number already used in another transaction.
)";
?>