<?phpusePlutu\Services\PlutuAdfali;$mobileNumber ='090000000'; // Mobile number should start with 09$amount =5.0; // amount in float formattry { $api =newPlutuAdfali; $api->setCredentials('api_key','access_token'); $apiResponse = $api->verify($mobileNumber, $amount);if ($apiResponse->getOriginalResponse()->isSuccessful()) {// Process ID should be sent in the confirmation step $processId = $apiResponse->getProcessId(); } elseif ($apiResponse->getOriginalResponse()->hasError()) {// Possible errors from Plutu API// @see https://docs.plutu.ly/api-documentation/errors Plutu API Error Documentation $errorCode = $apiResponse->getOriginalResponse()->getErrorCode(); $errorMessage = $apiResponse->getOriginalResponse()->getErrorMessage(); $statusCode = $apiResponse->getOriginalResponse()->getStatusCode(); $responseData = $apiResponse->getOriginalResponse()->getBody(); }// Handle exceptions that may be thrown during the execution of the code// The following are the expected exceptions that may be thrown:// Check the "Handle Exceptions and Errors" section for more details// // InvalidAccessTokenException, InvalidApiKeyException// InvalidMobileNumberException, InvalidAmountException} catch (\Exception $e) { $exception = $e->getMessage();}
<?phpusePlutu\Services\PlutuAdfali;$processId ='xxxxx'; // the Process ID that received in the verification step$code ='1111'; // OTP$amount =5.0; // amount in float format$invoiceNo ='inv-12345'; // invoice numbertry { $api =newPlutuAdfali; $api->setCredentials('api_key','access_token'); $apiResponse = $api->confirm($processId, $code, $amount, $invoiceNo);if($apiResponse->getOriginalResponse()->isSuccessful()){// The transaction has been completed// Plutu Transaction ID $transactionId = $apiResponse->getTransactionId();// Response Data $data = $apiResponse->getOriginalResponse()->getBody(); } elseif($apiResponse->getOriginalResponse()->hasError()) {// Possible errors from Plutu API// @see https://docs.plutu.ly/api-documentation/errors Plutu API Error Documentation $errorCode = $apiResponse->getOriginalResponse()->getErrorCode(); $errorMessage = $apiResponse->getOriginalResponse()->getErrorMessage(); $statusCode = $apiResponse->getOriginalResponse()->getStatusCode(); $responseData = $apiResponse->getOriginalResponse()->getBody(); }// Handle exceptions that may be thrown during the execution of the code// The following are the expected exceptions that may be thrown:// Check the "Handle Exceptions and Errors" section for more details// // InvalidAccessTokenException, InvalidApiKeyException// InvalidProcessIdException, InvalidCodeException, InvalidAmountException, InvalidInvoiceNoException} catch (\Exception $e) { $exception = $e->getMessage();}
Check out the example Confirm Process (Pay) in the Plutu PHP Examples document on GitHub.