-
Notifications
You must be signed in to change notification settings - Fork 0
/
generateInvoice.php
37 lines (29 loc) · 965 Bytes
/
generateInvoice.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
<?php
require_once './yowpayApi.php';
function generatePaymentLink($amount, $currency, $orderId, $language) {
$token = 'APP_TOKEN';
$secret = 'APP_SECRET';
$data = array(
'amount' => $amount,
'currency' => $currency,
'orderId' => $orderId,
'language' => $language,
'token' => $token,
'timestamp' => time()
);
$hash = YowPayApi::createSignature($data, $secret);
$queryParams = http_build_query($data);
$paymentLink = "https://yowpay.com/transaction/create?$queryParams&hash=$hash";
return $paymentLink;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$amount = $_POST['amount'];
$currency = $_POST['currency'];
$orderId = $_POST['orderId'];
$language = $_POST['language'];
$paymentLink = generatePaymentLink($amount, $currency, $orderId, $language);
// Redirect the user to the generated payment link
header("Location: $paymentLink");
exit();
}
?>