Skip to content

Commit ab06c6a

Browse files
committed
add PSD2 code snippets
1 parent 067726e commit ab06c6a

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

verify/send_psd2_code.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# frozen_string_literal: true
2+
3+
require 'dotenv/load'
4+
require 'nexmo'
5+
6+
NEXMO_API_KEY = ENV['NEXMO_API_KEY']
7+
NEXMO_API_SECRET = ENV['NEXMO_API_SECRET']
8+
TO_NUMBER = ENV['TO_NUMBER']
9+
10+
client = Nexmo::Client.new(
11+
api_key: NEXMO_API_KEY,
12+
api_secret: NEXMO_API_SECRET
13+
)
14+
15+
response = client.verify.psd2(
16+
number: TO_NUMBER,
17+
payee: 'AcmeInc',
18+
amount: 12.34
19+
)
20+
21+
if response
22+
# display the Verify PSD2 `request_id`
23+
puts response.request_id
24+
end
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# frozen_string_literal: true
2+
3+
require 'dotenv/load'
4+
require 'nexmo'
5+
6+
NEXMO_API_KEY = ENV['NEXMO_API_KEY']
7+
NEXMO_API_SECRET = ENV['NEXMO_API_SECRET']
8+
TO_NUMBER = ENV['TO_NUMBER']
9+
10+
WORKFLOW_ID = ARGV[0]
11+
if WORKFLOW_ID.empty?
12+
puts 'Please supply the workflow_id'
13+
exit
14+
end
15+
16+
client = Nexmo::Client.new(
17+
api_key: NEXMO_API_KEY,
18+
api_secret: NEXMO_API_SECRET
19+
)
20+
21+
response = client.verify.psd2(
22+
number: TO_NUMBER,
23+
payee: 'AcmeInc',
24+
amount: 12.34,
25+
workflow_id: WORKFLOW_ID
26+
)
27+
28+
if response
29+
# display the Verify PSD2 `request_id`
30+
puts response.request_id
31+
end

0 commit comments

Comments
 (0)