メインコンテンツへスキップ

テストカード番号とテストデータ

Omise のテスト環境ですべての支払いシナリオをテストするための完全なテストカード番号と支払いデータです。これらのカードを使用して、成功支払い、拒否、3D Secure 認証、さまざまな失敗シナリオをシミュレートできます。

概要

Omise は、サポートされているすべての支払い方法に対応する包括的なテストデータを提供しています。これらのテストカードと支払い方法により、本番環境に移行する前に統合を徹底的にテストでき、成功シナリオ、拒否理由、不正検出、3D Secure 認証、地域の支払い方法をカバーできます。

主な機能

  • 完全なカード対応: すべての主要なカードブランド用のテストカード
  • 3D Secure テスト: 成功および失敗した認証の両方をテスト
  • 拒否シナリオ: 特定の拒否理由とレスポンスをテスト
  • 地域方法: サポートされている各市場のカードと支払い方法
  • 実世界シナリオ: エッジケースと特殊条件をテスト
  • CVV と有効期限テスト: 検証とセキュリティチェックをテスト

標準テストカード

成功支払いカード

成功支払いシナリオをテストするには、これらのカードを使用してください:

カードブランドカード番号CVV有効期限3D Secure説明
Visa4242424242424242任意の3桁任意の将来の日付登録されていない標準的な成功支払い
Visa4111111111111111任意の3桁任意の将来の日付登録されていない代替 Visa テストカード
Mastercard5555555555554444任意の3桁任意の将来の日付登録されていない標準的な成功支払い
Mastercard5454545454545454任意の3桁任意の将来の日付登録されていない代替 Mastercard テストカード
JCB3530111333300000任意の3桁任意の将来の日付登録されていない標準 JCB 支払い
American Express378282246310005任意の4桁任意の将来の日付登録されていない標準 Amex 支払い
American Express371449635398431任意の4桁任意の将来の日付登録されていない代替 Amex テストカード
Diners Club36227206271667任意の3桁任意の将来の日付登録されていない標準 Diners 支払い
Discover6011111111111117任意の3桁任意の将来の日付登録されていない標準 Discover 支払い

重要な注釈

  • CVV: 有効な CVV を使用してください (ほとんどのカードは 3 桁、American Express は 4 桁)
  • 有効期限: MM/YY または MM/YYYY 形式で将来の日付を使用してください
  • カード名義人: 任意の名前を使用してください (最小 2 文字)
  • 金額: さまざまな支払い金額をテストするには、任意の有効な金額を使用してください

3D Secure テストカード

成功 3D Secure 認証

3D Secure 認証が必要で正常に完了するカード:

カードブランドカード番号CVV有効期限認証説明
Visa4000000000000002任意の3桁任意の将来の日付成功3DS 登録済み、認証成功
Mastercard5200000000000007任意の3桁任意の将来の日付成功3DS 登録済み、認証成功
JCB3530111333300001任意の3桁任意の将来の日付成功3DS 登録済み、認証成功

失敗 3D Secure 認証

3D Secure 認証に失敗するカード:

カードブランドカード番号CVV有効期限認証説明
Visa4000000000000010任意の3桁任意の将来の日付失敗3DS 登録済み、認証失敗
Mastercard5200000000000015任意の3桁任意の将来の日付失敗3DS 登録済み、認証失敗
Visa4000000000000028任意の3桁任意の将来の日付拒否3DS 登録済み、発行者により拒否

3D Secure 認証フロー

// JavaScript - 3D Secure 支払いのテスト
const Omise = require('omise')({
secretKey: 'skey_test_xxxxxxxxxx',
omiseVersion: '2019-05-29'
});

async function test3DSecurePayment() {
try {
// 1. 3DS テストカードでトークンを作成
const token = await Omise.tokens.create({
card: {
name: 'Test User',
number: '4000000000000002', // 3DS enrolled card
expiration_month: 12,
expiration_year: 2026,
security_code: '123'
}
});

// 2. チャージを作成 (3DS の authorize_uri が返される)
const charge = await Omise.charges.create({
amount: 100000, // 1,000.00 THB
currency: 'THB',
card: token.id,
return_uri: 'https://example.com/orders/complete'
});

console.log('Charge Status:', charge.status); // 'pending'
console.log('3DS Authorization URL:', charge.authorize_uri);

// 顧客が authorize_uri で 3DS 認証を完了
// 完了後、return_uri にリダイレクトされます

// 3. チャージを取得して最終ステータスを確認
const updatedCharge = await Omise.charges.retrieve(charge.id);
console.log('Final Status:', updatedCharge.status); // 'successful'

} catch (error) {
console.error('Error:', error.message);
}
}

test3DSecurePayment();
# Python - 3D Secure 支払いのテスト
import omise

omise.api_secret = 'skey_test_xxxxxxxxxx'
omise.api_version = '2019-05-29'

def test_3ds_payment():
try:
# 1. 3DS テストカードでトークンを作成
token = omise.Token.create(
card={
'name': 'Test User',
'number': '4000000000000002', # 3DS enrolled card
'expiration_month': 12,
'expiration_year': 2026,
'security_code': '123'
}
)

# 2. チャージを作成 (3DS の authorize_uri が返される)
charge = omise.Charge.create(
amount=100000, # 1,000.00 THB
currency='THB',
card=token.id,
return_uri='https://example.com/orders/complete'
)

print(f'Charge Status: {charge.status}') # 'pending'
print(f'3DS Authorization URL: {charge.authorize_uri}')

# 顧客が authorize_uri で 3DS 認証を完了
# 完了後、return_uri にリダイレクトされます

# 3. チャージを取得して最終ステータスを確認
updated_charge = omise.Charge.retrieve(charge.id)
print(f'Final Status: {updated_charge.status}') # 'successful'

except omise.errors.BaseError as e:
print(f'Error: {e.message}')

test_3ds_payment()
# Ruby - 3D Secure 支払いのテスト
require 'omise'

Omise.api_key = 'skey_test_xxxxxxxxxx'
Omise.api_version = '2019-05-29'

def test_3ds_payment
begin
# 1. 3DS テストカードでトークンを作成
token = Omise::Token.create(
card: {
name: 'Test User',
number: '4000000000000002', # 3DS enrolled card
expiration_month: 12,
expiration_year: 2026,
security_code: '123'
}
)

# 2. チャージを作成 (3DS の authorize_uri が返される)
charge = Omise::Charge.create(
amount: 100_000, # 1,000.00 THB
currency: 'THB',
card: token.id,
return_uri: 'https://example.com/orders/complete'
)

puts "Charge Status: #{charge.status}" # 'pending'
puts "3DS Authorization URL: #{charge.authorize_uri}"

# 顧客が authorize_uri で 3DS 認証を完了
# 完了後、return_uri にリダイレクトされます

# 3. チャージを取得して最終ステータスを確認
updated_charge = Omise::Charge.retrieve(charge.id)
puts "Final Status: #{updated_charge.status}" # 'successful'

rescue Omise::Error => e
puts "Error: #{e.message}"
end
end

test_3ds_payment
<?php
// PHP - 3D Secure 支払いのテスト
require_once 'vendor/autoload.php';

define('OMISE_API_VERSION', '2019-05-29');
define('OMISE_SECRET_KEY', 'skey_test_xxxxxxxxxx');

function test3DSecurePayment() {
try {
// 1. 3DS テストカードでトークンを作成
$token = OmiseToken::create([
'card' => [
'name' => 'Test User',
'number' => '4000000000000002', // 3DS enrolled card
'expiration_month' => 12,
'expiration_year' => 2026,
'security_code' => '123'
]
]);

// 2. チャージを作成 (3DS の authorize_uri が返される)
$charge = OmiseCharge::create([
'amount' => 100000, // 1,000.00 THB
'currency' => 'THB',
'card' => $token['id'],
'return_uri' => 'https://example.com/orders/complete'
]);

echo "Charge Status: {$charge['status']}\n"; // 'pending'
echo "3DS Authorization URL: {$charge['authorize_uri']}\n";

// 顧客が authorize_uri で 3DS 認証を完了
// 完了後、return_uri にリダイレクトされます

// 3. チャージを取得して最終ステータスを確認
$updatedCharge = OmiseCharge::retrieve($charge['id']);
echo "Final Status: {$updatedCharge['status']}\n"; // 'successful'

} catch (Exception $e) {
echo "Error: {$e->getMessage()}\n";
}
}

test3DSecurePayment();
?>
// Go - 3D Secure 支払いのテスト
package main

import (
"fmt"
"github.com/omise/omise-go"
"github.com/omise/omise-go/operations"
)

func test3DSecurePayment() {
client, _ := omise.NewClient(
"pkey_test_xxxxxxxxxx",
"skey_test_xxxxxxxxxx",
)
client.APIVersion = "2019-05-29"

// 1. 3DS テストカードでトークンを作成
token, createTokenErr := client.CreateToken(&operations.CreateToken{
Name: "Test User",
Number: "4000000000000002", // 3DS enrolled card
ExpirationMonth: 12,
ExpirationYear: 2026,
SecurityCode: "123",
})
if createTokenErr != nil {
fmt.Printf("Error creating token: %v\n", createTokenErr)
return
}

// 2. チャージを作成 (3DS の authorize_uri が返される)
charge, createChargeErr := client.CreateCharge(&operations.CreateCharge{
Amount: 100000, // 1,000.00 THB
Currency: "THB",
Card: token.ID,
ReturnURI: "https://example.com/orders/complete",
})
if createChargeErr != nil {
fmt.Printf("Error creating charge: %v\n", createChargeErr)
return
}

fmt.Printf("Charge Status: %s\n", charge.Status) // 'pending'
fmt.Printf("3DS Authorization URL: %s\n", charge.AuthorizeURI)

// 顧客が authorize_uri で 3DS 認証を完了
// 完了後、return_uri にリダイレクトされます

// 3. チャージを取得して最終ステータスを確認
updatedCharge, retrieveErr := client.GetCharge(charge.ID)
if retrieveErr != nil {
fmt.Printf("Error retrieving charge: %v\n", retrieveErr)
return
}

fmt.Printf("Final Status: %s\n", updatedCharge.Status) // 'successful'
}

func main() {
test3DSecurePayment()
}

拒否されたカードテスト番号

特定の拒否理由

これらのカードで特定の拒否シナリオをテストしてください:

カード番号拒否理由説明
4000000000000101資金不足カードに資金が不足しています
4000000000000119処理エラー一般的な処理エラー
4000000000000127紛失カードカードが紛失として報告されています
4000000000000135盗難カードカードが盗難として報告されています
4000000000000143期限切れカードカードの有効期限が切れています
4000000000000150無効な CVVCVV 検証に失敗しました
4000000000000168無効なカード番号カード番号が無効です
4000000000000176無効な有効期限有効期限が無効です
4000000000000184取引不許可このカードでは取引が許可されていません
4000000000000192不正の疑い取引が不正としてフラグ付けされています
4000000000000200カード制限カードに制限があります
4000000000000218引き出し限度額超過金額がカード限度額を超えています
4000000000000226発行者利用不可カード発行者システムが利用できません
4000000000000234取引拒否発行者からの一般的な拒否

拒否された支払いのテスト

// JavaScript - 拒否された支払いのテスト
const Omise = require('omise')({
secretKey: 'skey_test_xxxxxxxxxx'
});

async function testDeclinedPayment() {
try {
const token = await Omise.tokens.create({
card: {
name: 'Test User',
number: '4000000000000101', // Insufficient funds
expiration_month: 12,
expiration_year: 2026,
security_code: '123'
}
});

const charge = await Omise.charges.create({
amount: 100000,
currency: 'THB',
card: token.id
});

console.log('Charge Status:', charge.status); // 'failed'
console.log('Failure Code:', charge.failure_code); // 'insufficient_funds'
console.log('Failure Message:', charge.failure_message);

} catch (error) {
console.error('Error:', error.message);
}
}

testDeclinedPayment();
# Python - 適切なエラーハンドリングを使用した拒否された支払いのテスト
import omise

omise.api_secret = 'skey_test_xxxxxxxxxx'

def test_declined_payment():
try:
token = omise.Token.create(
card={
'name': 'Test User',
'number': '4000000000000101', # Insufficient funds
'expiration_month': 12,
'expiration_year': 2026,
'security_code': '123'
}
)

charge = omise.Charge.create(
amount=100000,
currency='THB',
card=token.id
)

print(f'Charge Status: {charge.status}') # 'failed'
print(f'Failure Code: {charge.failure_code}') # 'insufficient_funds'
print(f'Failure Message: {charge.failure_message}')

except omise.errors.BaseError as e:
print(f'Error: {e.message}')

test_declined_payment()

地域別テストカード

タイのテストカード

タイ市場でのテスト専用のカード:

カードブランドカード番号通貨説明
Visa4242424242424242THB標準タイ Visa カード
Mastercard5555555555554444THB標準タイ Mastercard
JCB3530111333300000THBタイで人気の JCB カード
UnionPay6200000000000005THB中国人観光客向け UnionPay カード

シンガポールのテストカード

カードブランドカード番号通貨説明
Visa4242424242424242SGDシンガポール Visa カード
Mastercard5555555555554444SGDシンガポール Mastercard

マレーシアのテストカード

カードブランドカード番号通貨説明
Visa4242424242424242MYRマレーシア Visa カード
Mastercard5555555555554444MYRマレーシア Mastercard

日本のテストカード

カードブランドカード番号通貨説明
Visa4242424242424242JPY日本 Visa カード
Mastercard5555555555554444JPY日本 Mastercard
JCB3530111333300000JPY日本 JCB カード
JCB3566002020360505JPY代替 JCB カード

代替支払い方法のテストデータ

PromptPay テストデータ

タイ市場での PromptPay 支払いをテストします:

フィールドテスト値説明
電話番号0812345678有効なタイの携帯電話番号
電話番号+66812345678国コード付きの有効な番号
国民ID1234567890123有効な13桁のタイID
金額任意の金額テストには最小額はありません
// JavaScript - PromptPay 支払いのテスト
const Omise = require('omise')({
secretKey: 'skey_test_xxxxxxxxxx'
});

async function testPromptPayPayment() {
try {
const source = await Omise.sources.create({
type: 'promptpay',
amount: 100000,
currency: 'THB'
});

console.log('Source ID:', source.id);
console.log('QR Code URL:', source.scannable_code.image.download_uri);

const charge = await Omise.charges.create({
amount: 100000,
currency: 'THB',
source: source.id,
return_uri: 'https://example.com/orders/complete'
});

console.log('Charge Status:', charge.status); // 'pending'

// テストモードでは、支払いを手動で成功としてマークできます
// または、タイムアウト期間後に自動的に期限切れになります

} catch (error) {
console.error('Error:', error.message);
}
}

testPromptPayPayment();

TrueMoney Wallet テストデータ

TrueMoney Wallet 支払いをテストします:

フィールドテスト値説明
電話番号0812345678有効なタイの携帯電話番号
金額20 - 1000000THB サブユニットでの金額
// JavaScript - TrueMoney Wallet 支払いのテスト
async function testTrueMoneyPayment() {
try {
const source = await Omise.sources.create({
type: 'truemoney',
amount: 100000,
currency: 'THB',
phone_number: '0812345678'
});

const charge = await Omise.charges.create({
amount: 100000,
currency: 'THB',
source: source.id,
return_uri: 'https://example.com/orders/complete'
});

console.log('Charge Status:', charge.status);
console.log('Authorization URL:', charge.authorize_uri);

} catch (error) {
console.error('Error:', error.message);
}
}

testTrueMoneyPayment();

Rabbit LINE Pay テストデータ

Rabbit LINE Pay 支払いをテストします:

フィールドテスト値説明
金額1 - 5000000THB サブユニットでの金額
通貨THBタイバーツのみ
# Python - Rabbit LINE Pay のテスト
import omise

omise.api_secret = 'skey_test_xxxxxxxxxx'

def test_rabbit_linepay():
try:
source = omise.Source.create(
type='rabbit_linepay',
amount=100000,
currency='THB'
)

charge = omise.Charge.create(
amount=100000,
currency='THB',
source=source.id,
return_uri='https://example.com/orders/complete'
)

print(f'Charge Status: {charge.status}')
print(f'Authorization URL: {charge.authorize_uri}')

except omise.errors.BaseError as e:
print(f'Error: {e.message}')

test_rabbit_linepay()

インターネットバンキングテストデータ

サポートされているタイの銀行向けインターネットバンキング支払いをテストします:

銀行コード銀行名テストアカウント説明
bblBangkok Bank任意のユーザー名/パスワード成功支払いをシミュレート
kbankKasikorn Bank任意のユーザー名/パスワード成功支払いをシミュレート
scbSiam Commercial Bank任意のユーザー名/パスワード成功支払いをシミュレート
bayBank of Ayudhya任意のユーザー名/パスワード成功支払いをシミュレート
ktbKrung Thai Bank任意のユーザー名/パスワード成功支払いをシミュレート
# Ruby - インターネットバンキング支払いのテスト
require 'omise'

Omise.api_key = 'skey_test_xxxxxxxxxx'

def test_internet_banking
begin
source = Omise::Source.create(
type: 'internet_banking_bbl',
amount: 100_000,
currency: 'THB'
)

charge = Omise::Charge.create(
amount: 100_000,
currency: 'THB',
source: source.id,
return_uri: 'https://example.com/orders/complete'
)

puts "Charge Status: #{charge.status}"
puts "Authorization URL: #{charge.authorize_uri}"

rescue Omise::Error => e
puts "Error: #{e.message}"
end
end

test_internet_banking

モバイルバンキングテストデータ

モバイルバンキング支払いをテストします:

銀行コード銀行名通貨説明
mobile_banking_scbSCB EasyTHBSCB モバイルバンキング
mobile_banking_kbankK PLUSTHBKasikorn モバイルバンキング
mobile_banking_bayKrungsri MobileTHBBank of Ayudhya モバイル
mobile_banking_bblBualuang mBankingTHBBangkok Bank モバイル
<?php
// PHP - モバイルバンキング支払いのテスト
require_once 'vendor/autoload.php';

define('OMISE_SECRET_KEY', 'skey_test_xxxxxxxxxx');

function testMobileBanking() {
try {
$source = OmiseSource::create([
'type' => 'mobile_banking_scb',
'amount' => 100000,
'currency' => 'THB'
]);

$charge = OmiseCharge::create([
'amount' => 100000,
'currency' => 'THB',
'source' => $source['id'],
'return_uri' => 'https://example.com/orders/complete'
]);

echo "Charge Status: {$charge['status']}\n";
echo "Authorization URL: {$charge['authorize_uri']}\n";

} catch (Exception $e) {
echo "Error: {$e->getMessage()}\n";
}
}

testMobileBanking();
?>

PayNow テストデータ (シンガポール)

シンガポール向け PayNow 支払いをテストします:

フィールドテスト値説明
金額100 - 10000000SGD サブユニットでの金額
通貨SGDシンガポールドルのみ
// Go - PayNow 支払いのテスト
package main

import (
"fmt"
"github.com/omise/omise-go"
"github.com/omise/omise-go/operations"
)

func testPayNow() {
client, _ := omise.NewClient(
"pkey_test_xxxxxxxxxx",
"skey_test_xxxxxxxxxx",
)

// PayNow ソースを作成
source, createErr := client.CreateSource(&operations.CreateSource{
Type: "paynow",
Amount: 100000, // 1,000.00 SGD
Currency: "SGD",
})
if createErr != nil {
fmt.Printf("Error creating source: %v\n", createErr)
return
}

// チャージを作成
charge, chargeErr := client.CreateCharge(&operations.CreateCharge{
Amount: 100000,
Currency: "SGD",
Source: source.ID,
ReturnURI: "https://example.com/orders/complete",
})
if chargeErr != nil {
fmt.Printf("Error creating charge: %v\n", chargeErr)
return
}

fmt.Printf("Charge Status: %s\n", charge.Status)
fmt.Printf("QR Code URL: %s\n", charge.Source.ScannableCode.Image.DownloadURI)
}

func main() {
testPayNow()
}

FPX テストデータ (マレーシア)

マレーシアの銀行向け FPX (Financial Process Exchange) をテストします:

銀行コード銀行名テストアカウント説明
fpx_mb2uMaybank2u任意の認証情報成功支払いをシミュレート
fpx_cimbclicksCIMB Clicks任意の認証情報成功支払いをシミュレート
fpx_pbbPublic Bank任意の認証情報成功支払いをシミュレート
fpx_rhbRHB Bank任意の認証情報成功支払いをシミュレート

実世界のテストシナリオ

シナリオ 1: マルチ通貨テスト

異なる通貨で同じ取引をテストします:

// JavaScript - マルチ通貨テスト
const currencies = ['THB', 'SGD', 'MYR', 'JPY', 'USD', 'EUR'];
const testCard = '4242424242424242';

async function testMultiCurrency() {
for (const currency of currencies) {
try {
const token = await Omise.tokens.create({
card: {
name: 'Test User',
number: testCard,
expiration_month: 12,
expiration_year: 2026,
security_code: '123'
}
});

const amount = currency === 'JPY' ? 10000 : 100000;

const charge = await Omise.charges.create({
amount: amount,
currency: currency,
card: token.id,
description: `Test payment in ${currency}`
});

console.log(`${currency}: ${charge.status} - ${charge.id}`);

} catch (error) {
console.error(`${currency} failed:`, error.message);
}
}
}

testMultiCurrency();

シナリオ 2: 支払い限度額のテスト

最小および最大支払い金額をテストします:

# Python - 支払い限度額のテスト
import omise

omise.api_secret = 'skey_test_xxxxxxxxxx'

def test_payment_limits():
# さまざまなシナリオのテスト金額
test_amounts = {
'minimum': 2000, # 20.00 THB
'small': 10000, # 100.00 THB
'medium': 100000, # 1,000.00 THB
'large': 1000000, # 10,000.00 THB
'very_large': 10000000 # 100,000.00 THB
}

for test_name, amount in test_amounts.items():
try:
token = omise.Token.create(
card={
'name': 'Test User',
'number': '4242424242424242',
'expiration_month': 12,
'expiration_year': 2026,
'security_code': '123'
}
)

charge = omise.Charge.create(
amount=amount,
currency='THB',
card=token.id,
description=f'Test {test_name} amount'
)

print(f'{test_name} ({amount}): {charge.status}')

except omise.errors.BaseError as e:
print(f'{test_name} failed: {e.message}')

test_payment_limits()

シナリオ 3: 同時支払いのテスト

複数の同時支払いをテストします:

// JavaScript - 同時支払いのテスト
async function testConcurrentPayments() {
const numberOfPayments = 5;
const promises = [];

for (let i = 0; i < numberOfPayments; i++) {
const promise = (async () => {
const token = await Omise.tokens.create({
card: {
name: `Test User ${i}`,
number: '4242424242424242',
expiration_month: 12,
expiration_year: 2026,
security_code: '123'
}
});

const charge = await Omise.charges.create({
amount: 100000,
currency: 'THB',
card: token.id,
description: `Concurrent payment ${i}`
});

return { index: i, status: charge.status, id: charge.id };
})();

promises.push(promise);
}

try {
const results = await Promise.all(promises);
results.forEach(result => {
console.log(`Payment ${result.index}: ${result.status} (${result.id})`);
});
} catch (error) {
console.error('Error in concurrent payments:', error.message);
}
}

testConcurrentPayments();

シナリオ 4: 返金フローのテスト

全額および一部返金をテストします:

# Ruby - 返金フローのテスト
require 'omise'

Omise.api_key = 'skey_test_xxxxxxxxxx'

def test_refund_flow
begin
# 成功したチャージを作成
token = Omise::Token.create(
card: {
name: 'Test User',
number: '4242424242424242',
expiration_month: 12,
expiration_year: 2026,
security_code: '123'
}
)

charge = Omise::Charge.create(
amount: 100_000,
currency: 'THB',
card: token.id
)

puts "Charge created: #{charge.id} - #{charge.status}"

# 全額返金をテスト
full_refund = Omise::Refund.create(charge.id)
puts "Full refund: #{full_refund.id} - #{full_refund.amount}"

# 一部返金テスト用に別のチャージを作成
token2 = Omise::Token.create(
card: {
name: 'Test User',
number: '4242424242424242',
expiration_month: 12,
expiration_year: 2026,
security_code: '123'
}
)

charge2 = Omise::Charge.create(
amount: 100_000,
currency: 'THB',
card: token2.id
)

# 一部返金をテスト (50%)
partial_refund = Omise::Refund.create(charge2.id, amount: 50_000)
puts "Partial refund: #{partial_refund.id} - #{partial_refund.amount}"

rescue Omise::Error => e
puts "Error: #{e.message}"
end
end

test_refund_flow

テストのベストプラクティス

1. すべての支払いステータスをテスト

統合がすべての可能な支払いステータスを処理できることを確認します:

  • Successful: 支払いが正常に完了
  • Pending: 顧客のアクション待ち (3DS、リダイレクト)
  • Failed: 支払いが拒否または失敗
  • Expired: 支払いが完了せずにタイムアウト
  • Reversed: 支払いが取り消された (まれ)

2. さまざまなカードタイプをテスト

互換性を確保するため、複数のカードブランドでテストします:

const testCards = [
{ brand: 'Visa', number: '4242424242424242' },
{ brand: 'Mastercard', number: '5555555555554444' },
{ brand: 'JCB', number: '3530111333300000' },
{ brand: 'Amex', number: '378282246310005' }
];

async function testAllCardBrands() {
for (const card of testCards) {
console.log(`Testing ${card.brand}...`);
// トークンとチャージを作成
}
}

3. エッジケースをテスト

珍しいが有効なシナリオをテストします:

  • 小数精度のある金額
  • カード名義人名の国際文字
  • フィールドの最大長
  • 最小金額
  • 同じカードを複数回
  • 迅速な連続支払い

4. エラーハンドリングをテスト

アプリケーションがエラーを適切に処理できることを確認します:

# Python - 包括的なエラーハンドリング
def test_with_error_handling():
try:
token = omise.Token.create(
card={
'name': 'Test User',
'number': '4000000000000101', # Will decline
'expiration_month': 12,
'expiration_year': 2026,
'security_code': '123'
}
)

charge = omise.Charge.create(
amount=100000,
currency='THB',
card=token.id
)

if charge.status == 'failed':
# 失敗した支払いを処理
print(f'Payment failed: {charge.failure_code}')
print(f'Message: {charge.failure_message}')

except omise.errors.InvalidRequestError as e:
# 無効なリクエストを処理 (検証エラー)
print(f'Invalid request: {e.message}')
except omise.errors.AuthenticationError as e:
# 認証エラーを処理
print(f'Authentication error: {e.message}')
except omise.errors.BaseError as e:
# その他の Omise エラーを処理
print(f'Omise error: {e.message}')
except Exception as e:
# 予期しないエラーを処理
print(f'Unexpected error: {str(e)}')

5. 説明的なメタデータを使用

デバッグを容易にするため、テストチャージにメタデータを追加します:

const charge = await Omise.charges.create({
amount: 100000,
currency: 'THB',
card: token.id,
metadata: {
test_scenario: 'successful_visa_payment',
test_run_id: 'test_' + Date.now(),
environment: 'automated_testing'
}
});

6. べき等性をテスト

重複リクエストが正しく処理されることを確認します:

# Ruby - べき等性のテスト
def test_idempotency
idempotency_key = "test_#{Time.now.to_i}"

# 同じリクエストを2回実行
2.times do
charge = Omise::Charge.create(
{
amount: 100_000,
currency: 'THB',
card: token.id
},
{ 'Idempotency-Key': idempotency_key }
)
puts "Charge ID: #{charge.id}"
end
# 両方のリクエストは同じチャージ ID を返すはずです
end

トラブルシューティング

よくある問題

問題: "Card number is invalid"

原因: テストモードで本番カード番号を使用している

解決策: このドキュメントのテストカード番号を使用してください。テストカードは常に特定のプレフィックスで始まります (例: 4242、5555、3530)。

// 間違い - 実際のカード
number: '4532015112830366'

// 正しい - テストカード
number: '4242424242424242'

問題: 3D Secure リダイレクトが機能しない

原因: return_uri が欠落または無効

解決策: 3DS 支払いには常に有効な return_uri を提供してください:

const charge = await Omise.charges.create({
amount: 100000,
currency: 'THB',
card: token.id,
return_uri: 'https://example.com/complete' // 3DS に必須
});

問題: "Amount is below minimum"

原因: 通貨に対してテスト金額が低すぎる

解決策: 最小金額を尊重してください:

  • THB: 2000 (20.00 THB)
  • SGD: 100 (1.00 SGD)
  • MYR: 100 (1.00 MYR)
  • JPY: 100 (100 JPY)

問題: Token already used

原因: トークンを再利用しようとしている

解決策: 各支払いに対して新しいトークンを作成してください:

# 間違い - トークンの再利用
charge1 = omise.Charge.create(amount=100000, currency='THB', card=token.id)
charge2 = omise.Charge.create(amount=100000, currency='THB', card=token.id) # エラー!

# 正しい - 各チャージに新しいトークン
token1 = omise.Token.create(card={...})
charge1 = omise.Charge.create(amount=100000, currency='THB', card=token1.id)

token2 = omise.Token.create(card={...})
charge2 = omise.Charge.create(amount=100000, currency='THB', card=token2.id)

問題: PromptPay QR コードが生成されない

原因: ソースパラメータが正しくない

解決策: 正しいソース作成を確認してください:

const source = await Omise.sources.create({
type: 'promptpay',
amount: 100000, // 必須
currency: 'THB' // 必須
});

問題: テスト支払いが pending で停止

原因: リダイレクトベースの支払いに対するテストモードでの通常の動作

解決策:

  • テストの場合、リダイレクトが必要な支払いはタイムアウトまで pending のままです
  • ステータス変更を処理するために Webhook を使用してください
  • シミュレートされた顧客アクション後にチャージステータスを確認してください

デバッグのヒント

  1. 詳細ログを有効化:
const Omise = require('omise')({
secretKey: 'skey_test_xxxxxxxxxx',
omiseVersion: '2019-05-29'
});

// すべてのリクエストとレスポンスをログ
Omise.setDebug(true);
  1. API レスポンスの詳細を確認:
import omise
omise.api_secret = 'skey_test_xxxxxxxxxx'

# デバッグモードを有効化
import logging
logging.basicConfig(level=logging.DEBUG)
  1. テストモードを確認:
// 常にテストモードであることを確認
if (!secretKey.startsWith('skey_test_')) {
throw new Error('Not in test mode!');
}
  1. 追跡用にメタデータを使用:
charge = Omise::Charge.create(
amount: 100_000,
currency: 'THB',
card: token.id,
metadata: {
debug_info: 'test_run_123',
timestamp: Time.now.to_s
}
)

よくある質問

テストモードで実際のカード番号を使用できますか?

いいえ、テストモードはテストカード番号のみを受け付けます。実際のカード番号は「無効なカード番号」エラーで拒否されます。これは、テストモードで偶発的な実際の取引を防ぐためのセキュリティ対策です。

テスト支払いは実際の取引を作成しますか?

いいえ、テスト支払いは本番環境から完全に分離されています。実際に請求されることはなく、実際の銀行接続も行われず、テストデータが本番システムに影響を与えることはありません。

テストトークンはどのくらいの期間有効ですか?

テストトークンは、本番トークンと同様に、作成後 30 分で期限切れになります。常に使用直前にトークンを作成してください。

テストデータで Webhook をテストできますか?

はい、テストモードは本番環境と同様に、設定されたエンドポイントに Webhook を送信します。すべての Webhook イベントがテストモードで動作します。詳細については、Testing Webhooks ガイドを参照してください。

3D Secure テストカードは実際の認証が必要ですか?

いいえ、3D Secure テストカードは実際の銀行認証を必要とせずに認証フローをシミュレートします。テスト環境は自動的に 3DS プロセスを処理します。

テストモードで返金をテストできますか?

はい、すべての返金操作がテストモードで動作します。テストチャージに対して全額および一部返金を作成できます。返金はテストモードで即座に処理されます (遅延なし)。

さまざまな拒否理由をテストするにはどうすればよいですか?

拒否されたカードテスト番号セクションにリストされている特定のテストカード番号を使用してください。各カードは特定の拒否理由をトリガーします。

最小額未満の金額でテストできますか?

いいえ、最小金額はテストモードで本番動作と一致するように強制されます。最小額未満の金額でテストすることは、検証が正しく機能することを確認するのに役立ちます。

テスト支払い方法は期限切れになりますか?

はい、顧客アクションが必要なテスト支払い方法 (PromptPay、インターネットバンキングなど) は、本番環境と同じタイムアウト期間 (通常 15〜30 分) 後に期限切れになります。

テストチャージを削除できますか?

いいえ、チャージはテストモードまたは本番モードのいずれでも削除できません。ただし、テストチャージは取引量にカウントされず、必要に応じて返金できます。

国際カードをテストするにはどうすればよいですか?

異なる通貨コードで標準テストカードを使用してください。カードブランドと番号は同じで、チャージを作成するときに適切な通貨を指定してください。

継続課金をテストできますか?

はい、テストカードを使用して顧客とスケジュールを作成できます。すべての継続課金機能がテストモードで動作します。詳細については、Recurring Payments ガイドを参照してください。

関連リソース

次のステップ

  1. 成功支払いをテスト 標準テストカードで
  2. 3D Secure フローをテスト 登録済みテストカードで
  3. 拒否シナリオをテスト 特定の拒否カードで
  4. 地域支払い方法をテスト ターゲット市場向けに
  5. Webhook テストを設定 支払いイベントを処理するため
  6. エラーハンドリングを実装 すべての失敗シナリオに対して
  7. 返金フローをテスト 適切な処理を確保するため
  8. 自動テストを実行 テストスイートで

エラーシナリオをテストする準備はできましたか? Simulating Failures を確認してください。

Webhook をテストする必要がありますか? Testing Webhooks を参照してください。