-
Notifications
You must be signed in to change notification settings - Fork 0
/
paymentOnDeliveryPaymentRequest.php
55 lines (39 loc) · 2.05 KB
/
paymentOnDeliveryPaymentRequest.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
<?php
/*This file generates the payment request and sends it to the WL Sips server
For more information on this use case, please refer to the following documentation:
https://documentation.sips.worldline.com/en/WLSIPS.004-GD-Functionality-set-up-guide.html#Payment-upon-shipping */
session_start();
include('Common/sealCalculationPaypagePost.php');
include('Common/flatten.php');
include('Common/transactionIdCalculation.php');
//PAYMENT REQUEST
// parameters.php initializes some session data like $_SESSION['merchantId'], $_SESSION['secretKey'], $_SESSION['normalReturnUrl'] and $_SESSION["urlForPaymentInitialisation"]
// You can change these values in parameters.php according to your needs and architecture
include('parameters.php');
// Merchants migrating from WL Sips 1.0 to WL Sips 2.0 must provide a transactionId. This easily done below. (second example used as default).
// Example with the merchant's own transactionId (typically when you increment Ids from your database)
// $s10TransactionReference=array(
// "s10TransactionId" => "000001",
// // "s10TransactionIdDate" => "not needed", Please note that the date is not needed, Sips server will apply its date.
// );
//
// Example with transactionId automatic generation, like the WL Sips 1.0 API was doing.
$s10TransactionReference=get_s10TransactionReference();
$requestData = array(
"normalReturnUrl" => $_SESSION['normalReturnUrl'],
"merchantId" => $_SESSION['merchantId'],
"amount" => "2000", //Note that the amount entered in the "amount" field is in cents
"orderChannel" => "INTERNET",
"currencyCode" => "978",
"keyVersion" => "1",
"responseEncoding" => "base64",
"s10TransactionReference" => $s10TransactionReference,
"captureMode" => "VALIDATION",
"captureDay" => "3",
);
$dataStr = flatten_to_sips_payload($requestData);
$dataStrEncode = base64_encode($dataStr);
$_SESSION['seal'] = compute_seal_from_string($_SESSION['sealAlgorithm'], $dataStrEncode, $_SESSION['secretKey']);
$_SESSION['data'] = $dataStrEncode;
header('Location: Common/redirectionForm.php');
?>