Download the PHP package otp-com/sdk-php without Composer

On this page you can find all versions of the php package otp-com/sdk-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sdk-php

otp.com PHP SDK

PHP client for the otp.com OTP API: send a one-time password, verify the code the user entered, resend it on another channel.

Requires PHP 8.1+ and Guzzle 7.

Install

Quickstart

Get an API key from the otp.com panel under API Keys. otp_live_… sends for real, otp_test_… runs in sandbox. Keep it server-side; it is a bearer credential.

The code itself is never returned by the API. recipient is a phone number in E.164 or an email address; which one is valid depends on the channels enabled for your app.

Model constructors take the wire field names (otp_id, not otpId).

Retries that must not double-send

Pass an idempotency key and a repeat of the same call replays the first response instead of sending a second code. Reusing a key with a different body is a 409.

WhatsApp: the code comes back to the user

Verification is identical on every channel, but WhatsApp delivery has one extra step. When routing picks WhatsApp, the code has not been sent yet and the response carries an action URL:

Then call verifyOtp exactly as on SMS. The action URL is null on every other channel. Don't poll for a WhatsApp OTP to approve itself: nothing leaves pending without a verifyOtp call. If the user has no WhatsApp, resend on a channel they do have.

Resending

A resend before the cooldown elapses is a 429; a channel that isn't enabled for your app or the recipient is a 409.

Checking status

Useful for reconciliation and support tooling. It is not a substitute for verifyOtp, which is what actually approves an OTP.

Errors

Any non-2xx response throws OtpCom\Sdk\ApiException. The body is always {"error": {"type", "message", "details"?}}, where type is a stable machine-readable class.

Status When
401 Missing or invalid API key, disabled app, or suspended company
404 Unknown otp_id (also returned for another company's OTP, to avoid probing)
409 No enabled channel, channel not enabled, resend not allowed, or idempotency-key conflict
422 Request body failed validation
429 Resend cooldown has not elapsed

Configuration

Pass your own Guzzle client to control timeouts, proxies, retries, and logging middleware.

API reference

Method Endpoint Returns
sendOtp POST /otp/send OtpResponse
verifyOtp POST /otp/verify VerifyResponse
resendOtp POST /otp/resend OtpResponse
getOtpStatus GET /otp/{otp_id} OtpStatusResponse

Regenerating

Everything in this repo except this README is generated from openapi.yaml by OpenAPI Generator. Fix the contract, not lib/; a pull request against generated files will be overwritten by the next regeneration.

README.md is listed in .openapi-generator-ignore so it survives regeneration. When the contract changes, update it by hand.

License

MIT


All versions of sdk-php with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-curl Version *
ext-json Version *
ext-mbstring Version *
guzzlehttp/guzzle Version ^7.3
guzzlehttp/psr7 Version ^1.7 || ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package otp-com/sdk-php contains the following files

Loading the files please wait ...