<?phpusePlutu\Services\PlutuSadad;$mobileNumber ='090000000'; // Mobile number should start with 09$birthYear ='1991'; // Birth year$amount =5.0; // amount in float formattry { $api =newPlutuSadad; $api->setCredentials('api_key','access_token'); $apiResponse = $api->verify($mobileNumber, $birthYear, $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, InvalidBirthYearException, InvalidAmountException} catch (\Exception $e) { $exception = $e->getMessage();}
<?phpusePlutu\Services\PlutuSadad;$processId ='xxxxx'; // the Process ID that received in the verification step$code ='111111'; // OTP$amount =5.0; // amount in float format$invoiceNo ='inv-12345'; // invoice numbertry { $api =newPlutuSadad; $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.