-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add quick pay function and add examples
- Loading branch information
Showing
4 changed files
with
96 additions
and
4 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
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
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,50 @@ | ||
<?php | ||
|
||
namespace RevenueMonster\SDK\Request; | ||
|
||
use Exception; | ||
use JsonSerializable; | ||
use Rakit\Validation\Validator; | ||
use RevenueMonster\SDK\Request\Order; | ||
use RevenueMonster\SDK\Exceptions\ValidationException; | ||
|
||
class QuickPay implements JsonSerializable | ||
{ | ||
public $authCode; | ||
public $order; | ||
public $ipAddress; | ||
public $terminalId; | ||
public $storeId; | ||
|
||
public function __construct(array $arguments = []) | ||
{ | ||
$this->order = new Order; | ||
} | ||
|
||
public function jsonSerialize() | ||
{ | ||
$data = [ | ||
'authCode' => $this->authCode, | ||
'order' => $this->order->jsonSerialize(), | ||
'ipAddress' => $this->ipAddress, | ||
'terminalId' => $this->terminalId, | ||
'storeId' => $this->storeId, | ||
]; | ||
|
||
$validator = new Validator; | ||
$validation = $validator->make($data, [ | ||
'authCode' => 'required', | ||
'order' => 'required', | ||
'ipAddress' => 'required|ip', | ||
'storeId' => 'required', | ||
]); | ||
|
||
$validation->validate(); | ||
|
||
if ($validation->fails()) { | ||
throw new ValidationException($validation->errors()); | ||
} | ||
|
||
return $data; | ||
} | ||
} |
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