# Send OTP (One Time Password)

### Sending OTP

| Parameters    | Descriptions                                                               |
| ------------- | -------------------------------------------------------------------------- |
| receiver\_otp | Receiver number (e.g, \[code country]\[number] 6283838204803)              |
| message       | This parameter's type data is callable, so you can custom your message OTP |

```php
function send(string $receiver_otp, callable $message = NULL)
```

This function has a default message

```php
protected string $otp_message = 'Dear Customer, Your OTP is [otp]. Use this Passcode to complete your activity that needed the OTP code. Thank you.';
```

#### Example

{% tabs %}
{% tab title="Default message" %}

```php
\Ardzz\Wavel\Wavel::OTP()->send(receiver_otp: '6283838204803');
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Custom message" %}

```php
\Ardzz\Wavel\Wavel::OTP()->send(
    receiver_otp: '6283838204803',
    message: fn($OTPCode) => "Hello Ardhana, this is your OTP code {$OTPCode}"
);
```

{% endtab %}
{% endtabs %}

### Validating OTP

| Parameters    | Descriptions                                                                                                 |
| ------------- | ------------------------------------------------------------------------------------------------------------ |
| receiver\_otp | The receiver OTP marked as identifier to verify their OTP code (e.g, \[code country]\[number] 6283838204803) |
| code          | OTP Code that given to `receiver_otp`                                                                        |

```php
function validate(string $receiver_otp, string|int $code)
```

#### Example

```php
$validate = \Ardzz\Wavel\Wavel::OTP()->validate(
    receiver_otp: '6283838204803',
    code: '123456'
);

if($validate){
    echo 'OTP is valid';
}else{
    echo 'OTP is invalid';
}
```
