api duitku dan profile add
This commit is contained in:
@@ -30,4 +30,140 @@ class DuitkuHelper
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public static function checkStatus($merchantOrderId)
|
||||
{
|
||||
$duitkuConfig = self::configuration();
|
||||
$data = [
|
||||
'merchantOrderId' => $merchantOrderId
|
||||
];
|
||||
try {
|
||||
$transactionList = \Duitku\Pop::transactionStatus($merchantOrderId, $duitkuConfig);
|
||||
|
||||
header('Content-Type: application/json');
|
||||
$transaction = json_decode($transactionList);
|
||||
|
||||
// var_dump($transactionList);
|
||||
|
||||
if ($transaction->statusCode == "00") {
|
||||
// Action Success
|
||||
} else if ($transaction->statusCode == "01") {
|
||||
// Action Pending
|
||||
} else {
|
||||
// Action Failed Or Expired
|
||||
}
|
||||
return $transaction;
|
||||
// return json_decode($transaction);
|
||||
} catch (Exception $e) {
|
||||
return $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('APP_URL').'/api/linksehat/callback-duitku'; // 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());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user