Add remaining project files (exclude ignored folders)

This commit is contained in:
WD - Dev
2025-07-05 15:11:40 +07:00
parent a96eb2b958
commit b440b80882
4697 changed files with 1365702 additions and 0 deletions
+105
View File
@@ -0,0 +1,105 @@
<?php
class FlipPaymentGateway
{
private $apiKey;
private $apiUrl;
// Konstruktor untuk inisialisasi API Key dan URL
public function __construct($apiKey, $apiUrl)
{
$this->apiKey = $apiKey;
$this->apiUrl = rtrim($apiUrl, '/');
}
// Fungsi untuk membuat transaksi
public function createBill($title, $amount, $sender_email, $sender_name, $sender_phone_number, $sender_address, $urlback = '')
{
$endpoint = '/bill';
if(!empty($urlback)){
$data = [
"title" => $title,
"amount" => $amount,
"type" => "MULTIPLE",
"is_address_required" => 0,
"is_phone_number_required" => 0,
"step" => 2,
"redirect_url" => $urlback,
"sender_email" => $sender_email,
"sender_name" => $sender_name,
"sender_phone_number" => $sender_phone_number,
"sender_address" => $sender_address
];
} else {
$data = [
"title" => $title,
"amount" => $amount,
"type" => "MULTIPLE",
"is_address_required" => 0,
"is_phone_number_required" => 0,
"step" => 2,
"sender_email" => $sender_email,
"sender_name" => $sender_name,
"sender_phone_number" => $sender_phone_number,
"sender_address" => $sender_address
];
}
// print_r($data);
return $this->sendRequest('POST', $endpoint, $data);
}
//Fungsi edit transaksi
public function editBill($linkid,$status,$title1, $amount1)
{
$endpoint = "/{$linkid}/bill";
$data = [
"title" => $title1,
"amount" => $amount1,
"type" => "MULTIPLE",
"is_address_required" => 0,
"is_phone_number_required" => 0,
"status" => $status
];
return $this->sendRequest('PUT', $endpoint, $data);
}
// Fungsi untuk memeriksa status transaksi
public function getBillStatus($transactionId)
{
$endpoint = "/{$transactionId}/bill";
return $this->sendRequest('GET', $endpoint);
}
// Fungsi untuk mengirimkan request ke API
private function sendRequest($method, $endpoint, $data = null)
{
$url = $this->apiUrl . $endpoint;
// echo $data;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
if ($method === 'POST') {
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
}
elseif ($method === 'PUT') {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
}
elseif ($method == 'GET') {
}
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/x-www-form-urlencoded"
));
curl_setopt($ch, CURLOPT_USERPWD, $this->apiKey.":");
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, TRUE);
}
}
?>
+21
View File
@@ -0,0 +1,21 @@
<?php
require 'Transaction.php';
$apiKey = 'JDJ5JDEzJG9IZXEwNDluN212TmtIc1BFZ3RLSk9kS0tka2I0UFk1dlFOaFZLZ3puTGY0ZTZKeTk5cVEy';
$apiUrl = 'https://bigflip.id/api/v2/pwf/';
$flip = new FlipPaymentGateway($apiKey,$apiUrl);
// $flip = new FlipPaymentGateway($apiUrl);
try {
// Membuat transaksi
// $response = $flip->createBill('Pembayaran Internet bulan Agustus 2024',180000, 'recipient@example.com', 'Wian', '081298698422', 'Sukabumi jawa barat');
$response = $flip->editBill('11966210','INACTIVE','Tambah saldo agen voucher', 50000);
//CEK Status Transaksi
// $response = $flip->getBillStatus('133642');
echo "<pre>";
print_r($response);
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}
?>