Skip to main content

PHP SDK

🎯 What is Prism?

Today, integrating multiple payment processors either makes developers running in circles with AI agents to recreate integrations from specs, or developers spending months of engineering effort.

Because every payment processor has diverse APIs, error codes, authentication methods, pdf documents to read, and above all - different behaviour in the actual environment when compared to documented specs. All this rests as tribal or undocumented knowledge making it harder AI agents which are very good at implementing clearly documented specification.

Prism is a stateless, unified connector library for AI agents and Developers to connect with any payment processor

Prism offers hardened transformation through testing on payment processor environment & iterative bug fixing

Prism can be embedded in you server application with its wide range of multi-language SDKs, or run as a rRPC microservice

❌ Without Prism✅ With Prism
🗂️ 100+ different API schemas📋 Single unified schema
⏳ Never ending agent loops/ months of integration work⚡ Hours to integrate, Agent driven
🔗 Brittle, provider-specific code🔓 Portable, provider-agnostic code
🚫 Hard to switch providers🔄 Change providers in 1 line

Installation

composer require hyperswitch/prism

Quick Start

<?php
require_once 'vendor/autoload.php';

use OrchestratorXPrism\PaymentClient;

$paymentClient = new PaymentClient([
'connector' => 'stripe',
'apiKey' => 'YOUR_API_KEY',
'environment' => 'SANDBOX'
]);

// Authorize a payment
$response = $paymentClient->authorize([
'merchantTransactionId' => 'txn_order_001',
'amount' => [
'minorAmount' => 1000,
'currency' => 'USD'
],
'paymentMethod' => [
'card' => [
'cardNumber' => ['value' => '4242424242424242'],
'cardExpMonth' => ['value' => '12'],
'cardExpYear' => ['value' => '2027'],
'cardCvc' => ['value' => '123'],
'cardHolderName' => ['value' => 'John Doe']
]
],
'authType' => 'NO_THREE_DS'
]);

echo $response['status']; // AUTHORIZED

Services

ServiceDescription
Payment ServiceProcess payments from authorization to settlement
Recurring Payment ServiceManage subscriptions and recurring billing
Refund ServiceRetrieve and track refund statuses
Dispute ServiceHandle chargebacks and disputes
Event ServiceProcess webhook notifications
Payment Method ServiceStore and manage payment methods
Customer ServiceManage customer profiles
Merchant Authentication ServiceGenerate access tokens
Payment Method Authentication Service3D Secure authentication
Payout ServiceSend funds to recipients

Configuration

OptionTypeRequiredDescription
connectorstringYesPayment connector name (stripe, adyen, etc.)
apiKeystringYesYour API key
environmentstringYesSANDBOX or PRODUCTION
timeoutintNoRequest timeout in seconds (default: 30)

Error Handling

try {
$response = $paymentClient->authorize($request);
} catch (PaymentDeclinedException $e) {
// Handle declined payment
echo $e->getMessage();
} catch (ValidationException $e) {
// Handle validation error
echo $e->getErrors();
} catch (OrchestratorXException $e) {
// Handle other errors
echo $e->getMessage();
}

Support

For support and documentation, visit https://docs.orchestratorx.com