setSandboxMode(true); // set sanitizer (default : true) $duitkuConfig->setSanitizedMode(false); // set log parameter (default : true) $duitkuConfig->setDuitkuLogs(false); return $duitkuConfig; } public static function paymentMethod() { $duitkuConfig = self::configuration(); try { $paymentAmount = "10000"; //"YOUR_AMOUNT"; $paymentMethodList = \Duitku\Pop::getPaymentMethod($paymentAmount, $duitkuConfig); header('Content-Type: application/json'); return $paymentMethodList; } catch (Exception $e) { return $e->getMessage(); } } public static function checkStatus($merchantOrderId) { $duitkuConfig = self::configuration(); $data = [ 'merchantOrderId' => $merchantOrderId ]; try { $transactionList = \Duitku\Pop::transactionStatus($merchantOrderId, $duitkuConfig); $transaction = json_decode($transactionList); if ($transaction->statusCode == "00" || $transaction->statusCode == "01") { // Transaksi berhasil atau dalam proses return $transaction; } else { // Transaksi gagal atau kedaluwarsa return ['error' => true]; } } catch (\Duitku\Exceptions\DuitkuException $e) { // Tangani pengecualian yang terkait dengan Duitku return ['error' => true, 'message' => $e->getMessage()]; } catch (Exception $e) { // Tangani pengecualian umum return ['error' => true, 'message' => $e->getMessage()]; } } public static function createInvoice($data) { #CONTOH DARI DUITKU // $paymentMethod = ""; // PaymentMethod list => https://docs.duitku.com/pop/id/#payment-method // $paymentAmount = 10000; // Amount // $email = "customer@gmail.com"; // your customer email // $phoneNumber = "081234567890"; // your customer phone number (optional) // $productDetails = "Test Payment"; // $merchantOrderId = "2"; // from merchant, unique // $additionalParam = ''; // optional // $merchantUserInfo = ''; // optional // $customerVaName = 'John Doe'; // display name on bank confirmation display // $callbackUrl = 'http://YOUR_SERVER/callback'; // url for callback // $returnUrl = 'http://YOUR_SERVER/return'; // url for redirect // $expiryPeriod = 60; // set the expired time in minutes // // Customer Detail // $firstName = "John"; // $lastName = "Doe"; // // Address // $alamat = "Jl. Kembangan Raya"; // $city = "Jakarta"; // $postalCode = "11530"; // $countryCode = "ID"; $paymentMethod = $data['paymentMethod']; // PaymentMethod list => https://docs.duitku.com/pop/id/#payment-method $paymentAmount = $data['paymentAmount']; // Amount $email = $data['email']; // your customer email $phoneNumber = $data['phoneNumber']; // your customer phone number (optional) $productDetails = $data['productDetails']; $merchantOrderId = $data['merchantOrderId']; // from merchant, unique $additionalParam = $data['additionalParam']; // optional $merchantUserInfo = $data['merchantUserInfo']; // optional $customerVaName = $data['customerVaName']; // display name on bank confirmation display $callbackUrl = env('DUITKU_PAYMENT_CALLBACK_URL'); // url for callback $returnUrl = env('APP_URL').'/api/linksehat/redirect-duitku';; // url for redirect $expiryPeriod = 60; // set the expired time in minutes // Customer Detail $firstName = $data['firstName']; $lastName = $data['lastName']; // Address $alamat = $data['alamat']; $city = $data['city']; $postalCode = $data['postalCode']; $countryCode = "ID"; $address = array( 'firstName' => $firstName, 'lastName' => $lastName, 'address' => $alamat, 'city' => $city, 'postalCode' => $postalCode, 'phone' => $phoneNumber, 'countryCode' => $countryCode ); $customerDetail = array( 'firstName' => $firstName, 'lastName' => $lastName, 'email' => $email, 'phoneNumber' => $phoneNumber, 'billingAddress' => $address, 'shippingAddress' => $address ); // Item Details $item1 = array( 'name' => $productDetails, 'price' => $paymentAmount, 'quantity' => 1 ); $itemDetails = array( $item1 ); $params = array( 'paymentAmount' => $paymentAmount, 'merchantOrderId' => $merchantOrderId, 'productDetails' => $productDetails, 'additionalParam' => $additionalParam, 'merchantUserInfo' => $merchantUserInfo, 'customerVaName' => $customerVaName, 'email' => $email, 'phoneNumber' => $phoneNumber, 'itemDetails' => $itemDetails, 'customerDetail' => $customerDetail, 'callbackUrl' => $callbackUrl, 'returnUrl' => $returnUrl, 'expiryPeriod' => $expiryPeriod ); $duitkuConfig = self::configuration(); try { // createInvoice Request $responseDuitkuPop = \Duitku\Pop::createInvoice($params, $duitkuConfig); header('Content-Type: application/json'); return json_decode($responseDuitkuPop); } catch (Exception $e) { return json_decode($e->getMessage()); } } }