-
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
Showing
5 changed files
with
122 additions
and
22 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,39 @@ | ||
<?php | ||
|
||
/* | ||
WARNING !!! | ||
This is code example logic | ||
*/ | ||
|
||
$leeloo = new \Nouvu\Leeloo\Api( $config ); | ||
|
||
$leeloo -> setSqlCallback( [ | ||
'delete' => fn( int $id ) => $db -> query( 'DELETE FROM `leeloo_queue_cron` WHERE `id` = ' . $id ), | ||
'update' => fn( int $id, string $response ) => $db -> prepare( 'UPDATE `leeloo_queue_cron` SET `again` = `again` + 1, response = ? WHERE `id` = ?', [ $response, $id ] ), | ||
] ); | ||
|
||
$response = $lrm -> query( 'SELECT `id`, `method`, `data` FROM `leeloo_queue_cron` ORDER BY `id` ASC, `again` ASC LIMIT 30' ); | ||
|
||
while ( $queue = $response -> fetch( FETCH_ASSOC ) ) | ||
{ | ||
try | ||
{ | ||
$leeloo -> cron( $queue ); | ||
} | ||
catch ( \Nouvu\Leeloo\LeelooOrderFailed $e ) | ||
{ | ||
$logger -> set( $e -> getMessage() ) -> set( json_encode ( $leeloo -> getResponse() ) ) -> set( 'id row: ' . $queue['id'] ); | ||
} | ||
} | ||
|
||
/* CREATE TABLE `leeloo_queue_cron` ( | ||
`id` INT NOT NULL AUTO_INCREMENT, | ||
`method` VARCHAR(20) NOT NULL, | ||
`data` JSON NOT NULL, | ||
`response` JSON NOT NULL, | ||
`again` INT NOT NULL DEFAULT 1, | ||
`created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
PRIMARY KEY (`id`)) | ||
ENGINE = InnoDB | ||
DEFAULT CHARACTER SET = utf8 | ||
COLLATE = utf8_bin; */ |
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,29 @@ | ||
<?php | ||
|
||
$data = [ | ||
'email' => 'mail@mail.ru', | ||
'phone' => 'phone', | ||
'accountId' => $id_account, | ||
|
||
'id' => &$id_insert_order | ||
]; | ||
|
||
try | ||
{ | ||
$leeloo_order_id = $leeloo -> orderPending( $data, $offer ); | ||
|
||
$db -> query( 'INSERT... order pay, status = pending AND leeloo_order_id = {$leeloo_order_id}' ); | ||
|
||
$id_insert_order = $db -> last_insert_id(); | ||
} | ||
catch ( \Nouvu\Leeloo\LeelooOrderFailed $e ) | ||
{ | ||
$logger -> set( $e -> getMessage() ) -> set( json_encode ( $leeloo -> getResponse() ) ); | ||
|
||
$db -> query( 'INSERT... order pay, status = pending AND leeloo_order_id = null' ); | ||
|
||
$id_insert_order = $db -> last_insert_id(); | ||
|
||
$leeloo -> saveFailure(); | ||
} | ||
|
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,24 @@ | ||
<?php | ||
|
||
$data = [ | ||
'status' => 'RESOLVED', // REJECTED | ||
'price' => 10, | ||
'currency' => 'USD', | ||
'userComments' => 'Hello world', | ||
]; | ||
|
||
try | ||
{ | ||
$leeloo -> orderUpdate( $leeloo_order_id, $data ); | ||
/* | ||
$leeloo -> orderCompleted( $leeloo_order_id, 10, 'USD', 'Hello world' ); | ||
$leeloo -> orderFailed( $leeloo_order_id, 10, 'USD', 'Hello world' ); | ||
*/ | ||
} | ||
catch ( \Nouvu\Leeloo\LeelooOrderFailed $e ) | ||
{ | ||
$logger -> set( $e -> getMessage() ) -> set( json_encode ( $leeloo -> getResponse() ) ); | ||
|
||
$leeloo -> saveFailure(); | ||
} | ||
|
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