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
Creates the otp resource client.
cancel()  : Transaction
Cancel an active OTP session, preventing further verification attempts.
initiate()  : Transaction
Create a new OTP session and deliver the code to the recipient.
lookup()  : Transaction
Retrieve details of an OTP session.
verify()  : Verification
Verify a customer-provided OTP code against an active session.

Methods

__construct()

Creates the otp resource client.

public __construct(HttpClient $http) : mixed
Parameters
$http : HttpClient

Shared authenticated HTTP transport used by this resource client.

cancel()

Cancel an active OTP session, preventing further verification attempts.

public cancel(array<string, mixed> $payload) : Transaction

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, 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
Transaction —

Cancelled session

initiate()

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

public initiate(array<string, mixed> $payload) : Transaction

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, 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 - One of the Inttegro\Otp\Purpose wire values (required)
  • 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->format(DATE_RFC3339) . "\n";
see
https://studio.inttegro.com/otp

for OTP implementation guide

Return values
Transaction —

Created OTP session

lookup()

Retrieve details of an OTP session.

public lookup(array<string, mixed> $payload) : Transaction

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, 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->format(DATE_RFC3339) . "\n";
see
https://studio.inttegro.com/otp

for OTP overview

Return values
Transaction —

OTP session details

verify()

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

public verify(array<string, mixed> $payload) : Verification

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, 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
Verification —

Verification result

On this page

Search results