PHP code example of trisnawan / multi-payment-service
1. Go to this page and download the library: Download trisnawan/multi-payment-service library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
trisnawan / multi-payment-service example snippets
use Trisnawan\MultiPaymentService\RequestPayment;
use Trisnawan\MultiPaymentService\PaymentBuyer;
use Trisnawan\MultiPaymentService\PaymentCategory;
use Trisnawan\MultiPaymentService\PaymentDirect;
use Trisnawan\MultiPaymentService\PaymentInvoice;
$payment = new RequestPayment();
$buyer = new PaymentBuyer('buyer-001', 'Pembeli', '[email protected]', '081234567890');
$category = new PaymentCategory('orders', 'Orders', 'Pembelian produk');
// Direct: pembeli membayar memakai instruksi VA, QR, atau URL provider.
$transaction = $payment->createDirect(new PaymentDirect(
$buyer, $category, 'method-id', 'order-001',
'Pesanan', 'Pembelian produk', 10000, 'https://example.com/payment/return'
));
// Payment link: pembeli memilih metode pada halaman checkout.
$invoice = new PaymentInvoice(
$buyer, $category, 'order-002',
'Pesanan', 'Pembelian produk', 10000, 'https://example.com/payment/return'
);
// Opsional; tanpa nilai ini backend memakai kedaluwarsa default.
$invoice->expired_at = date('Y-m-d H:i:s', time() + 3600);
$link = $payment->createLink($invoice);
echo $link->link;