-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 634f92c
Showing
11 changed files
with
866 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "yogastama/tripay", | ||
"description": "A library for integration your tripay", | ||
"type": "library", | ||
"autoload": { | ||
"psr-4": { | ||
"Yogastama\\Tripay\\": "src/" | ||
} | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "yogastama", | ||
"email": "yogabagas69@gmail.com" | ||
} | ||
], | ||
"minimum-stability": "dev", | ||
"require": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Yogastama\Tripay; | ||
|
||
use Illuminate\Support\Facades\App; | ||
use Illuminate\Support\ServiceProvider; | ||
use Yogastama\Tripay\Library\Tripay; | ||
|
||
class YbTripayServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Register services. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
App::bind('Tripay', function() | ||
{ | ||
return new Tripay(); | ||
}); | ||
} | ||
|
||
/** | ||
* Bootstrap services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?php | ||
namespace Yogastama\Tripay\Library; | ||
|
||
use Illuminate\Support\Facades\Http; | ||
use Illuminate\Support\Facades\Facade; | ||
|
||
|
||
class Tripay { | ||
public $apiKey; | ||
public $privateApiKey; | ||
public $merchantCode; | ||
public $env; | ||
public function __construct() | ||
{ | ||
$this->apiKey = env('API_KEY_TRIPAY'); | ||
$this->privateApiKey = env('API_KEY_PRIVATE_TRIPAY'); | ||
$this->merchantCode = env('TRIPAY_MERCHANT_CODE'); | ||
$this->env = env('APP_ENV'); | ||
} | ||
public function generateSignature($params){ | ||
$privateKey = $this->privateApiKey; | ||
$merchantCode = $this->merchantCode; | ||
$merchantRef = $params['merchant_ref']; | ||
$amount = $params['amount']; | ||
|
||
$signature = hash_hmac('sha256', $merchantCode.$merchantRef.$amount, $privateKey); | ||
return $signature; | ||
} | ||
public function getInstruksiPembayaran($params){ | ||
$url = "https://tripay.co.id/api-sandbox/payment/instruction"; | ||
if ($this->env != 'local') { | ||
$url = 'https://tripay.co.id/api/payment/instruction'; | ||
} | ||
$http = Http::withToken($this->apiKey)->get($url, [ | ||
'code' => $params['code'], | ||
'pay_code' => $params['pay_code'] ?? '', | ||
'amount' => $params['amount'], | ||
'allow_html' => $params['allow_html'] | ||
]); | ||
return $http->body()['data']; | ||
} | ||
public function requestTransaksi($params){ | ||
$url = 'https://tripay.co.id/api-sandbox/transaction/create'; | ||
if($this->env != 'local'){ | ||
$url = 'https://tripay.co.id/api/transaction/create'; | ||
} | ||
$http = Http::withToken($this->apiKey) | ||
->post($url, | ||
[ | ||
'method' => $params['method'], | ||
'merchant_ref' => $params['merchant_ref'], | ||
'amount' => $params['amount'], | ||
'customer_name' => $params['customer_name'], | ||
'customer_email' => $params['customer_email'], | ||
'customer_phone' => $params['customer_phone'], | ||
'callback_url' => $params['callback_url'] ?? '', | ||
'return_url' => $params['return_url'], | ||
'expired_time' => $params['expired_time'] ?? '', | ||
'signature' => $params['signature'], | ||
'order_items' => $params['order_items'] | ||
]); | ||
return json_decode($http->body()); | ||
} | ||
public function getDetailTransaksi($params){ | ||
$url = "https://tripay.co.id/api-sandbox/transaction/detail"; | ||
if($this->env != 'local'){ | ||
$url = "https://tripay.co.id/api/transaction/detail"; | ||
} | ||
$http = Http::withToken($this->apiKey)->get($url, [ | ||
'reference' => $params['reference'], | ||
]); | ||
return json_decode($http->body()); | ||
} | ||
public function getChannelPembayaran(){ | ||
$url = "https://tripay.co.id/api-sandbox/merchant/payment-channel"; | ||
if($this->env != 'local'){ | ||
$url = "https://tripay.co.id/api/merchant/payment-channel"; | ||
} | ||
$http = Http::withToken($this->apiKey)->get($url); | ||
return json_decode($http->body())->data; | ||
} | ||
public function getTransaksi($page){ | ||
$url = "https://tripay.co.id/api-sandbox/merchant/transactions"; | ||
if($this->env != 'local'){ | ||
$url = "https://tripay.co.id/api/merchant/transactions"; | ||
} | ||
$http = Http::withToken($this->apiKey)->get($url, [ | ||
'page' => $page, | ||
'per_page' => 20, | ||
'sort' => 'desc' | ||
]); | ||
|
||
return json_decode($http->body()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
// autoload.php @generated by Composer | ||
|
||
require_once __DIR__ . '/composer/autoload_real.php'; | ||
|
||
return ComposerAutoloaderInita725fd8823d42e15e7c8464a90924109::getLoader(); |
Oops, something went wrong.