Inttegro PHP SDK

Otp
in package

OTP resource for managing one-time password sessions.

OTPs provide secure verification for sensitive operations. Initialize sessions, send codes via SMS or email, verify customer-provided codes, and manage OTP lifecycle. Used for payment confirmations, account verification, and authentication flows.

Tags
see
https://studio.inttegro.com/otp

for OTP integration guide

Table of Contents

Methods

__construct()  : mixed
cancel()  : OTPTransaction
Cancel an active OTP session, preventing further verification attempts.
initiate()  : OTPTransaction
Create a new OTP session and deliver the code to the recipient.
lookup()  : OTPTransaction
Retrieve details of an OTP session.
verify()  : OTPVerification
Verify a customer-provided OTP code against an active session.

Methods

cancel()

Cancel an active OTP session, preventing further verification attempts.

public cancel(array<string|int, mixed> $payload) : OTPTransaction

Invalidates an OTP session immediately. Use this when the customer abandons the verification flow or when the operation requiring OTP is cancelled. Cancelled sessions cannot be resumed or verified.

Parameters
$payload : array<string|int, mixed>

Cancellation parameters

  • transaction_id: string - OTP transaction to cancel (required)
  • reason: string - Reason for cancellation (required)
Tags
example

Cancel OTP session

$result = $client->otp->cancel([
    'transaction_id' => 'ot_abc123',
    'reason' => 'user_requested_new_code'
]);

echo "OTP session cancelled\n";
see
https://studio.inttegro.com/otp

for session management

Return values
OTPTransaction

Cancelled session

initiate()

Create a new OTP session and deliver the code to the recipient.

public initiate(array<string|int, mixed> $payload) : OTPTransaction

Initializes an OTP session and sends a verification code via SMS or email. The code is typically 6 digits and expires after a configured time period. Use OTPs for payment confirmations, sensitive account changes, or multi-factor authentication.

Parameters
$payload : array<string|int, mixed>

OTP initiation parameters

  • recipient: string - Phone number in international format (required)
  • sender: string - Sender identifier (required)
  • service_name: string - Service name in message (required)
  • request_meta: array - Request controls such as idempotency_key (optional)
  • purpose: string - Description of why OTP is needed (optional)
  • Additional transaction configuration parameters
Tags
example

Initialize OTP session

$transaction = $client->otp->initiate([
    'recipient' => '+233541234567',
    'sender' => 'Acme',
    'service_name' => 'Acme Bank',
    'request_meta' => ['idempotency_key' => 'otp_login_1700000000'],
    'purpose' => 'payment_confirmation'
]);

echo "OTP sent. Transaction ID: {$transaction->id}\n";
echo "Expires at: {$transaction->expiresAt}\n";
see
https://studio.inttegro.com/otp

for OTP implementation guide

Return values
OTPTransaction

Created OTP session

lookup()

Retrieve details of an OTP session.

public lookup(array<string|int, mixed> $payload) : OTPTransaction

Returns session information including status, expiration time, verification attempts, and recipient details. Use this to check session state or display remaining attempts to customers.

Parameters
$payload : array<string|int, mixed>

Lookup parameters

  • transaction_id: string - OTP transaction identifier to retrieve (required)
Tags
example

Lookup OTP session

$transaction = $client->otp->lookup([
    'transaction_id' => 'ot_abc123'
]);

echo "Status: {$transaction->status}\n";
echo "Expires: {$transaction->expiresAt}\n";
see
https://studio.inttegro.com/otp

for OTP overview

Return values
OTPTransaction

OTP session details

verify()

Verify a customer-provided OTP code against an active session.

public verify(array<string|int, mixed> $payload) : OTPVerification

Validates the OTP code entered by the customer. If the code matches and hasn't expired, verification succeeds and the session is marked complete. Failed verification attempts are tracked, and excessive failures may lock the session.

Parameters
$payload : array<string|int, mixed>

Verification parameters

  • transaction_id: string - OTP transaction identifier (required)
  • recipient: string - Recipient phone number (required)
  • token: string - Customer-provided OTP code (required, typically 6 digits)
Tags
example

Verify OTP code

$verification = $client->otp->verify([
    'transaction_id' => 'ot_abc123',
    'recipient' => '+233541234567',
    'token' => '123456'
]);

if ($verification->transaction->status === 'verified') {
    echo "OTP verified successfully!\n";
} else {
    echo "Invalid code. Status: {$verification->transaction->status}\n";
}
see
https://studio.inttegro.com/otp

for verification flow

Return values
OTPVerification

Verification result

On this page

Search results