ワークフローで支払い認証コードを送信する
Verify API は、決済のための強力な顧客認証をサポートしています。プロセスを開始するには、顧客の電話番号 ( E.164フォーマット )、支払いを受け取る受取人、取引金額(ユーロ)を、以下の宛先に送付する。 PSD2エンドポイント.
を返します。 request_id.を作成するときなど、その後の API 呼び出しで特定の検証リクエストを識別するために使用します。 チェックリクエスト で、ユーザーが正しいコードを入力したかどうかを確認する。
サンプルコードの以下の変数を、独自の値に置き換えてください:
| キー | 説明 |
|---|---|
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 |
Write the code
Add the following to send-psd2-code-with-workflow.sh:
curl -X POST "https://api.nexmo.com/verify/psd2/json" \Run your code
Save this file to your machine and run it:
Prerequisites
Add the following to build.gradle:
implementation 'com.vonage:server-sdk-kotlin:2.1.1'Create a class named StartPsd2VerificationWithWorkflow and add the following code to the main method:
val client = Vonage {
apiKey(VONAGE_API_KEY)
apiSecret(VONAGE_API_SECRET)
}Write the code
Add the following to the main method of the StartPsd2VerificationWithWorkflow class:
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}")
}Run your code
We can use the アプリケーション plugin for Gradle to simplify the running of our application. Update your build.gradle with the following:
apply plugin: 'application'
mainClassName = project.hasProperty('main') ? project.getProperty('main') : ''Run the following gradle command to execute your application, replacing com.vonage.quickstart.kt.verify.legacy with the package containing StartPsd2VerificationWithWorkflow:
Prerequisites
Add the following to build.gradle:
implementation 'com.vonage:server-sdk:9.3.1'Create a class named StartPsd2VerificationWithWorkflow and add the following code to the main method:
VonageClient client = VonageClient.builder()
.apiKey(VONAGE_API_KEY)
.apiSecret(VONAGE_API_SECRET)
.build();Write the code
Add the following to the main method of the StartPsd2VerificationWithWorkflow class:
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());
}Run your code
We can use the アプリケーション plugin for Gradle to simplify the running of our application. Update your build.gradle with the following:
apply plugin: 'application'
mainClassName = project.hasProperty('main') ? project.getProperty('main') : ''Run the following gradle command to execute your application, replacing com.vonage.quickstart.verify with the package containing StartPsd2VerificationWithWorkflow:
Prerequisites
Install-Package VonageCreate a file named SendPsd2WithWorkflow.cs and add the following code:
using Vonage;
using Vonage.Request;
using Vonage.Verify;Add the following to SendPsd2WithWorkflow.cs:
var creds = Credentials.FromApiKeyAndSecret(vonageApiKey, vonageApiSecret);Write the code
Add the following to SendPsd2WithWorkflow.cs:
var request = new Psd2Request { Amount = amount, Payee = payeeName, Number = recipientNumber, WorkflowId = Psd2Request.Workflow.TTS };Prerequisites
composer require vonage/clientCreate a file named send_psd2_request_with_workflow.php and add the following code:
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
$client = new \Vonage\Client(new \Vonage\Client\Credentials\Container($basic));Write the code
Add the following to 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'];Run your code
Save this file to your machine and run it:
Prerequisites
pip install vonage python-dotenvWrite the code
Add the following to 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)Run your code
Save this file to your machine and run it:
Prerequisites
gem install vonageCreate a file named send_psd2_code_with_workflow.rb and add the following code:
client = Vonage::Client.new(
api_key: VONAGE_API_KEY,
api_secret: VONAGE_API_SECRET
)Write the code
Add the following to send_psd2_code_with_workflow.rb:
response = client.verify.psd2(
number: VERIFY_NUMBER,
payee: VERIFY_PAYEE_NAME,
amount: VERIFY_AMOUNT
workflow_id: VERIFY_WORKFLOW_ID
)Run your code
Save this file to your machine and run it: