PHP
Jamm PHP SDKのインストールと利用 — 決済・返金・カスタマー・Webhook。
インストール
composer require jamm-pay/php-sdk 📋 要件: PHP 8.2以上が必要です。
ソース: github.com/jamm-pay/php-sdk
初期化
$jamm = new \Jamm\Client(
clientId: $clientId,
clientSecret: $clientSecret,
environment: "staging", // "local" | "staging" | "prod"
); On-session決済
use Jamm\Request\OnSessionInput;
$response = $jamm->payment->onSession(new OnSessionInput(
buyer: new \Jamm\Request\Buyer(["email" => "customer@example.com"]),
charge: new \Jamm\Request\InitialCharge(["price" => 4000, "description" => "Order 1234"]),
redirect: new \Jamm\Request\URL(["success_url" => "https://yoursite.com/success", "failure_url" => "https://yoursite.com/failure"]),
oneTime: true,
)); カスタマーの状態を確認
off-sessionで請求する前に、カスタマーを取得してactivatedがtrueであることを確認してください。activatedは契約状況と、該当する場合はKYC状況を反映するため、カスタマーが請求可能かどうかを判断する単一の指標です。
$customer = $jamm->customer->get("cus-...");
if ($customer === null || !$customer->getActivated()) {
// まだ請求できません — スキップするなど適切に処理してください
} Off-session決済(非同期)
請求前にカスタマーのactivatedを確認してください — 上記のカスタマーの状態を確認を参照。
use Jamm\Request\OffSessionAsyncInput;
$response = $jamm->payment->offSessionAsync(new OffSessionAsyncInput(
customer: "cus-...",
charge: new \Jamm\Request\InitialCharge(["price" => 1000, "description" => "Monthly plan"]),
idempotencyKey: "order-2026-001", // 任意。省略時は自動生成
)); 返金・キャンセル
$jamm->payment->refund("trx-..."); // 全額。当日はキャンセル、それ以降は返金
$jamm->payment->refund("trx-...", amount: 500); // 部分返金
$jamm->payment->refund("trx-...", cancelOnly: true); // キャンセルのみ(返金フォールバックなし) Webhook
\Jamm\Webhook::verify($data, $signature); // 無効な署名の場合は例外をスロー
$event = \Jamm\Webhook::parse($json); Was this page helpful?
Need help? Coming Soon
Support Center Slack community Contact usSign up for our developer newsletter: Coming Soon
You can unsubscribe at any time. Read our
privacy policy and terms and conditions.
privacy policy and terms and conditions.