Last active
April 25, 2023 14:33
-
-
Save k0d3d/2548758e457b9cc10c7883cd5637a022 to your computer and use it in GitHub Desktop.
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
<?php | |
private function handlePaydayInvoiceUpdate($invoice_id, $action) { | |
$body = []; | |
if ($action == 'PAID') { | |
$body["status"] = "PAID"; | |
$body["paidDate"] = Carbon::now()->toDateTimeString(); | |
$body["paymentType"] = "d4a76367-d9dc-4fd0-9671-f789fee6cd16"; | |
} | |
if($action === "REFUND") { | |
$body["status"] = "CREDIT"; | |
} | |
if($action === "CANCEL") { | |
$body["status"] = "CANCELLED"; | |
} | |
Debugbar::info($body); | |
$customer_invoice = Http::withHeaders([ | |
"Authorization" => 'Bearer ' . $this->payday_credentials['accessToken'], | |
'Api-Version' => 'alpha' | |
])->put($this->payday_url . "/invoices/$invoice_id", $body); | |
Debugbar::info($customer_invoice->body()); | |
Debugbar::info($customer_invoice->status()); | |
return $customer_invoice->body(); | |
} | |
public function updatePaydayInvoice(PosRequest $pos_request, string $invoice_id) { | |
$request_all = $pos_request->all(); | |
$action = $request_all['action']; | |
$updateInvoice = $this->handlePaydayInvoiceUpdate($invoice_id, $action); | |
if ($updateInvoice) { | |
return ApiResponse::make('updated invoice', []); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment