|
|
@@ -121,16 +121,34 @@ class Supply extends Controller |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Should check that cost is not greater than price and store order |
|
|
|
//information if completed. return false/NULL if an error occured |
|
|
|
public static function orderSmmkings($order, $supplier) { |
|
|
|
if ($supplier->supplier != 'smmkings') { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
//Check that the order is not already pending. Probably by calling |
|
|
|
//another function. |
|
|
|
|
|
|
|
//Check supplier cost here to make sure the request is a good idea |
|
|
|
|
|
|
|
$response = Http::post(config("services.smmkings.link"), ['key' => |
|
|
|
config("services.smmkings.key"), 'action' => 'add', |
|
|
|
'service' => $supplier->supplier_id, 'link' => |
|
|
|
$order->url, 'quantity' => $order->quantity])->json(); |
|
|
|
|
|
|
|
//This should log the error for later reporting |
|
|
|
if (array_key_exists('error', $response)){ |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
//store order information here |
|
|
|
|
|
|
|
$status = Http::post(config("services.smmkings.link"), ['key' => |
|
|
|
config("services.smmkings.key"), 'action' => 'status', |
|
|
|
'order' => $response['order']])->json(); |
|
|
|
|
|
|
|
return $response; |
|
|
|
} |
|
|
|
|
|
|
|