feat: get status route
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Product;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class MyketService
|
||||
{
|
||||
private function sendRequest($url, $method, $params = [], $packageName)
|
||||
{
|
||||
$response = Http::send($method, $url, [
|
||||
'headers' => [
|
||||
'X-Access-Token' => $packageName->myket_access_token
|
||||
],
|
||||
'form_params' => $params
|
||||
]);
|
||||
|
||||
return json_decode($response, true);
|
||||
}
|
||||
|
||||
public function checkPurchase($product, $token)
|
||||
{
|
||||
$response = $this->sendRequest("https://developer.myket.ir/api/applications/{$product->packageName->name}/purchases/products/{$product->uuid}/tokens/$token", 'GET', [], $product->packageName);
|
||||
|
||||
if ($response['purchaseState']) {
|
||||
return [
|
||||
'status' => false,
|
||||
'message' => 'refunded',
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => true
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user