Enviar código de autenticación de pago con flujo de trabajo
Verify API admite la autenticación fuerte de clientes para los pagos. Para iniciar el proceso, facilite el número de teléfono del cliente (en Formato E.164 ), el beneficiario que recibirá el pago y el importe (en euros) de la transacción, a la dirección Punto final PSD2.
La API Verify devuelve un valor request_id. Utilícelo para identificar una solicitud de verificación específica en posteriores llamadas a la API, por ejemplo, al realizar un solicitud de cheque para ver si el usuario proporcionó el código correcto.
Sustituya las siguientes variables del código de ejemplo por sus propios valores:
| Clave | Descripción |
|---|---|
VONAGE_API_KEY | Your Vonage API key (see it on your dashboard). |
VONAGE_API_SECRET | Your Vonage API secret (also available on your dashboard). |
RECIPIENT_NUMBER | The phone number to verify |
PAYEE | Included in the message to describe the payment recipient |
AMOUNT | How much the payment is for (always in Euro) |
WORKFLOW_ID | Choose a workflow (number between 1 and 7), these are defined in the workflows guide |
Escriba el código
Añada lo siguiente a send-psd2-code-with-workflow.sh:
curl -X POST "https://api.nexmo.com/verify/psd2/json" \Ejecute su código
Guarde este archivo en su máquina y ejecútelo:
Requisitos previos
Añada lo siguiente a build.gradle:
implementation 'com.vonage:server-sdk-kotlin:2.1.1'Crea un archivo llamado StartPsd2VerificationWithWorkflow y añade el siguiente código al método main:
val client = Vonage {
apiKey(VONAGE_API_KEY)
apiSecret(VONAGE_API_SECRET)
}Escriba el código
Añada lo siguiente al método main del archivo StartPsd2VerificationWithWorkflow:
val response = client.verifyLegacy.psd2Verify(VERIFY_NUMBER, VERIFY_AMOUNT, VERIFY_PAYEE_NAME) {
workflow(VERIFY_PSD2_WORKFLOW_ID)
}
if (response.status == VerifyStatus.OK) {
println("Verification sent. Request ID: ${response.requestId}")
}
else {
println("Error: ${response.errorText}")
}Ejecute su código
Podemos utilizar el plugin aplicación para Gradle para simplificar la ejecución de nuestra aplicación. Actualiza tu build.gradle con lo siguiente:
apply plugin: 'application'
mainClassName = project.hasProperty('main') ? project.getProperty('main') : ''Ejecute el siguiente comando gradle para ejecutar su aplicación, sustituyendo com.vonage.quickstart.kt.verify.legacy por el paquete que contiene StartPsd2VerificationWithWorkflow:
Requisitos previos
Añada lo siguiente a build.gradle:
implementation 'com.vonage:server-sdk:9.3.1'Crea un archivo llamado StartPsd2VerificationWithWorkflow y añade el siguiente código al método main:
VonageClient client = VonageClient.builder()
.apiKey(VONAGE_API_KEY)
.apiSecret(VONAGE_API_SECRET)
.build();Escriba el código
Añada lo siguiente al método main del archivo StartPsd2VerificationWithWorkflow:
VerifyResponse response = client.getVerifyClient().psd2Verify(
VERIFY_NUMBER, VERIFY_AMOUNT, VERIFY_PAYEE_NAME, VERIFY_PSD2_WORKFLOW_ID
);
if (response.getStatus() == VerifyStatus.OK) {
System.out.printf("Request ID: %s", response.getRequestId());
}
else {
System.out.printf("Error: %s: %s", response.getStatus(), response.getErrorText());
}Ejecute su código
Podemos utilizar el plugin aplicación para Gradle para simplificar la ejecución de nuestra aplicación. Actualiza tu build.gradle con lo siguiente:
apply plugin: 'application'
mainClassName = project.hasProperty('main') ? project.getProperty('main') : ''Ejecute el siguiente comando gradle para ejecutar su aplicación, sustituyendo com.vonage.quickstart.verify por el paquete que contiene StartPsd2VerificationWithWorkflow:
Requisitos previos
Install-Package VonageCrea un archivo llamado SendPsd2WithWorkflow.cs y añade el siguiente código:
using Vonage;
using Vonage.Request;
using Vonage.Verify;Añada lo siguiente a SendPsd2WithWorkflow.cs:
var creds = Credentials.FromApiKeyAndSecret(vonageApiKey, vonageApiSecret);Escriba el código
Añada lo siguiente a SendPsd2WithWorkflow.cs:
var request = new Psd2Request { Amount = amount, Payee = payeeName, Number = recipientNumber, WorkflowId = Psd2Request.Workflow.TTS };Requisitos previos
composer require vonage/clientCrea un archivo llamado send_psd2_request_with_workflow.php y añade el siguiente código:
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
$client = new \Vonage\Client(new \Vonage\Client\Credentials\Container($basic));Escriba el código
Añada lo siguiente a send_psd2_request_with_workflow.php:
$request = new \Vonage\Verify\RequestPSD2(RECIPIENT_NUMBER, BRAND_NAME, AMOUNT, (int) WORKFLOW_ID);
$response = $client->verify()->requestPSD2($request);
echo "Started verification, `request_id` is " . $response['request_id'];Ejecute su código
Guarde este archivo en su máquina y ejecútelo:
Requisitos previos
pip install vonage python-dotenvEscriba el código
Añada lo siguiente a send-psd2-verification-request-with-workflow.py:
from vonage import Auth, Vonage
from vonage_verify_legacy import Psd2Request, StartVerificationResponse
client = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))
request = Psd2Request(
number=VERIFY_NUMBER,
payee=VERIFY_PAYEE_NAME,
amount=VERIFY_AMOUNT,
workflow_id=VERIFY_WORKFLOW_ID,
)
response: StartVerificationResponse = client.verify_legacy.start_psd2_verification(
request
)
print(response)Ejecute su código
Guarde este archivo en su máquina y ejecútelo:
Requisitos previos
gem install vonageCrea un archivo llamado send_psd2_code_with_workflow.rb y añade el siguiente código:
Ejecute su código
Guarde este archivo en su máquina y ejecútelo: