aliziodev/payid-midtrans 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aliziodev/payid-midtrans

最新稳定版本:v0.1.0

Composer 安装命令:

composer require aliziodev/payid-midtrans

包简介

Midtrans driver for PayID — Laravel Payment Orchestrator

README 文档

README

Driver Midtrans untuk aliziodev/payid.

Package ini menyediakan integrasi Midtrans dengan API PayID yang konsisten untuk flow:

  • Snap charge
  • Core API direct charge
  • status / cancel / expire / refund / approve / deny
  • subscription lifecycle
  • webhook verification + parsing
  • GoPay account linking

Requirements

  • PHP 8.2+
  • Laravel 11 / 12 / 13
  • aliziodev/payid ^0.1

Instalasi

composer require aliziodev/payid
composer require aliziodev/payid-midtrans

Konfigurasi

Tambahkan kredensial Midtrans pada konfigurasi driver payid.

Contoh di config/payid.php:

'drivers' => [
    'midtrans' => [
        'driver' => 'midtrans',
        'environment' => env('MIDTRANS_ENV', 'sandbox'),
        'server_key' => env('MIDTRANS_SERVER_KEY'),
        'client_key' => env('MIDTRANS_CLIENT_KEY'),
        'merchant_id' => env('MIDTRANS_MERCHANT_ID'),

        'timeout' => 30,
        'retry_times' => 1,

        'endpoints' => [
            // Optional override
            'snap_base_url' => env('MIDTRANS_SNAP_BASE_URL'),
            'core_base_url' => env('MIDTRANS_CORE_BASE_URL'),
            'subscription_base_url' => env('MIDTRANS_SUBSCRIPTION_BASE_URL'),
        ],

        'webhook' => [
            'replay_protection' => true,
            'replay_ttl_seconds' => 3600,
            'cache_store' => null,
        ],
    ],
],

Contoh .env:

PAYID_DEFAULT_DRIVER=midtrans

MIDTRANS_ENV=sandbox
MIDTRANS_SERVER_KEY=SB-Mid-server-xxxx
MIDTRANS_CLIENT_KEY=SB-Mid-client-xxxx
MIDTRANS_MERCHANT_ID=Gxxxxxxxx

Endpoint Mapping

  • Snap API
    • POST /snap/v1/transactions
  • Core API v2
    • POST /v2/charge
    • GET /v2/{id}/status
    • POST /v2/{id}/cancel
    • POST /v2/{id}/expire
    • POST /v2/{id}/refund
    • POST /v2/{id}/approve
    • POST /v2/{id}/deny
    • POST /v2/pay/account
    • GET /v2/pay/account/{account_id}
    • POST /v2/pay/account/{account_id}/unbind
  • Subscription API v1
    • POST /v1/subscriptions
    • GET /v1/subscriptions/{subscription_id}
    • PATCH /v1/subscriptions/{subscription_id}
    • POST /v1/subscriptions/{subscription_id}/disable
    • POST /v1/subscriptions/{subscription_id}/enable
    • POST /v1/subscriptions/{subscription_id}/cancel

Penggunaan

Charge (Snap)

use Aliziodev\PayId\DTO\ChargeRequest;
use Aliziodev\PayId\Enums\PaymentChannel;
use Illuminate\Support\Facades\PayId;

$response = PayId::charge(ChargeRequest::make([
    'merchant_order_id' => 'ORDER-1001',
    'amount' => 150000,
    'currency' => 'IDR',
    'channel' => PaymentChannel::Qris,
]));

Direct Charge (Core API)

$response = PayId::directCharge(ChargeRequest::make([
    'merchant_order_id' => 'ORDER-1002',
    'amount' => 200000,
    'currency' => 'IDR',
    'channel' => PaymentChannel::VaBca,
]));

Status / Refund

$status = PayId::status('ORDER-1001');

$refund = PayId::refund(\Aliziodev\PayId\DTO\RefundRequest::make([
    'merchant_order_id' => 'ORDER-1001',
    'amount' => 50000,
    'reason' => 'Customer request',
]));

Subscription

$created = PayId::createSubscription(\Aliziodev\PayId\DTO\SubscriptionRequest::make([
    'subscription_id' => 'SUB-1001',
    'name' => 'MONTHLY_PLAN',
    'amount' => 99000,
    'token' => 'saved_token_id_or_gopay_token',
    'interval' => 'month',
    'interval_count' => 1,
]));

$paused = PayId::pauseSubscription($created->providerSubscriptionId);
$resumed = PayId::resumeSubscription($created->providerSubscriptionId);
$canceled = PayId::cancelSubscription($created->providerSubscriptionId);

Webhook

  • Signature diverifikasi dengan formula resmi Midtrans:
    • SHA512(order_id + status_code + gross_amount + server_key)
  • Replay protection tersedia via cache fingerprint.

Dokumen operasional:

  • docs/webhook-replay-protection.md
  • docs/webhook-incident-runbook.md

Kesiapan Saat Ini

Audit sinkronisasi API Midtrans terbaru sudah dilakukan per 2026-04-13.

Lihat detail:

  • docs/api-compatibility-audit-2026-04-13.md
  • docs/release-readiness-checklist.md

Quality Gates

composer test
composer analyse
composer lint-check

Lisensi

MIT

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固