Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['generatePayment'])) {
- $shopId = intval(111);
- $description = strval('Opłata za fakturę');
- $control = strval(1234576948);
- $price = floatval(100);
- $notifyURL = strval('xxxxx');
- $returnUrlSuccess = strval('xxxxx');
- $hash = 'hash';
- $data = $hash . "|" . $shopId . "|" . sprintf("%.2f", $price);
- if ($control != null && $control != "") {
- $data .= "|" . $control;
- }
- if ($description != null && $description != "") {
- $data .= "|" . $description;
- }
- if ($notifyURL != null && $notifyURL != "") {
- $data .= "|" . $notifyURL;
- }
- if ($returnUrlSuccess != null && $returnUrlSuccess != "") {
- $data .= "|" . $returnUrlSuccess;
- }
- $signature = hash('sha256', $data);
- $paybylinkData = [
- 'shopId' => $shopId,
- 'price' => $price,
- 'control' => $control,
- 'description' => $description,
- 'notifyURL' => $notifyURL,
- 'returnUrlSuccess' => $returnUrlSuccess,
- 'signature' => $signature
- ];
- $data_string = json_encode($paybylinkData);
- $ch = curl_init('https://secure.pbl.pl/api/v1/transfer/generate');
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
- 'Content-Type: application/json',
- 'Content-Length: ' . strlen($data_string))
- );
- $result = curl_exec($ch);
- $result = json_decode($result);
- if(isset($result->transactionId) AND !empty($result->transactionId)) {
- header('https://secure.pbl.pl/transfer/' . $result->transactionId)
- } else {
- echo 'Wystąpił błąd.';
- }
- }
- ?>
- <form method="post">
- <input type="hidden" name="generatePayment">
- <input type="submit" value="Zapłać">
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement