PHPackages                             asciisd/cybersource-hosted-checkout-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. asciisd/cybersource-hosted-checkout-laravel

ActiveLaravel-package[Payment Processing](/categories/payments)

asciisd/cybersource-hosted-checkout-laravel
===========================================

A Laravel package for integrating with Cybersource Secure Acceptance Hosted Checkout.

v1.1.0(9mo ago)0811MITPHPPHP ^8.2

Since Jul 17Pushed 9mo agoCompare

[ Source](https://github.com/asciisd/cybersource-hosted-checkout-laravel)[ Packagist](https://packagist.org/packages/asciisd/cybersource-hosted-checkout-laravel)[ RSS](/packages/asciisd-cybersource-hosted-checkout-laravel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (19)Used By (0)

[![Latest Version on Packagist](https://camo.githubusercontent.com/2742e0447a6d35a32abde87268c33a6c01a1ef8c1ff91a42a31c490f788e71bf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f617363696973642f6379626572736f757263652d686f737465642d636865636b6f75742d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/asciisd/cybersource-hosted-checkout-laravel)[![Total Downloads](https://camo.githubusercontent.com/2d1d16b2f6265955ebf00a5746fd947145cc36a6549e6b96ef16c9f602f1d7fe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f617363696973642f6379626572736f757263652d686f737465642d636865636b6f75742d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/asciisd/cybersource-hosted-checkout-laravel)

Laravel Package for Cybersource Secure Acceptance Hosted Checkout
=================================================================

[](#laravel-package-for-cybersource-secure-acceptance-hosted-checkout)

This package provides a simple and fluent interface to integrate Cybersource's Secure Acceptance Hosted Checkout payment gateway into your Laravel application.

Installation
------------

[](#installation)

You can install the package via Composer:

```
composer require asciisd/cybersource-hosted-checkout-laravel
```

Next, publish the configuration file using the `vendor:publish` command:

```
php artisan vendor:publish --provider="Asciisd\Cybersource\CybersourceServiceProvider" --tag="config"
```

This will create a `config/cybersource.php` file in your application's `config` directory. You should then add your Cybersource credentials to your `.env` file:

```
CYBERSOURCE_PROFILE_ID=your_profile_id
CYBERSOURCE_ACCESS_KEY=your_access_key
CYBERSOURCE_SECRET_KEY=your_secret_key

```

Usage
-----

[](#usage)

This package provides a Blade component to easily render the payment form. You can include it in your views like this:

```

```

### Vue.js Component

[](#vuejs-component)

For applications using Vue.js, a `CyberSourceCheckout.vue` component is also included. To use it, you first need to publish the package's assets:

```
php artisan vendor:publish --provider="Asciisd\Cybersource\CybersourceServiceProvider" --tag="cybersource-assets"
```

This command will place the Vue component into your `resources/js/vendor/asciisd/cybersource/js/components` directory.

Next, register the component in your main `resources/js/app.js` file:

```
import { createApp } from "vue";
import CyberSourceCheckout from "./vendor/asciisd/cybersource/js/components/CyberSourceCheckout.vue";

const app = createApp({});

app.component("CyberSourceCheckout", CyberSourceCheckout);

app.mount("#app");
```

Now you can use the `` component within your Blade views. It accepts the same properties as the standard Blade component.

```

```

### Searching Transactions

[](#searching-transactions)

This package provides a method to search for transactions using the Cybersource Transaction Search API. The method returns a `TransactionSearchResponse` object with helpful methods for working with the results.

```
use Asciisd\Cybersource\Facades\Cybersource;

// Basic search by client reference code
$searchParams = [
    'query' => 'clientReferenceInformation.code:your_order_id',
];

$response = Cybersource::searchTransactions($searchParams);

// The response is a TransactionSearchResponse object
echo "Search ID: " . $response->searchId;
echo "Total transactions found: " . $response->totalCount;
echo "Current page count: " . $response->count;

// Get transactions as a collection
$transactions = $response->getTransactions();

foreach ($transactions as $transaction) {
    echo "Transaction ID: " . $transaction->id;
    echo "Status: " . $transaction->getStatus();
    echo "Amount: " . $transaction->getTotalAmount() . " " . $transaction->getCurrency();
    echo "Card: " . $transaction->getMaskedCardNumber();
    echo "Customer: " . $transaction->getCustomerEmail();
    echo "Reference: " . $transaction->getClientReferenceCode();
}

// Check pagination
if ($response->hasMoreResults()) {
    $nextOffset = $response->getNextOffset();
    echo "More results available. Next offset: " . $nextOffset;
}

// Get pagination info
$pagination = $response->getPaginationInfo();
echo "Page {$pagination['current_page']} of {$pagination['total_pages']}";
```

**Advanced search with multiple parameters:**

```
$searchParams = [
    'query' => 'clientReferenceInformation.code:your_order_id AND submitTimeUtc:[2024-01-01T00:00:00Z TO 2024-12-31T23:59:59Z]',
    'name' => 'Order Search',
    'timezone' => 'America/Chicago',
    'offset' => 0,
    'limit' => 50,
    'sort' => 'submitTimeUtc:desc'
];

$response = Cybersource::searchTransactions($searchParams);

// Work with individual transactions
foreach ($response->getTransactions() as $transaction) {
    if ($transaction->isApproved()) {
        echo "✅ Transaction {$transaction->id} was approved";
        echo "Approval Code: " . $transaction->getApprovalCode();
    } elseif ($transaction->isDeclined()) {
        echo "❌ Transaction {$transaction->id} was declined";
        echo "Reason Code: " . $transaction->getReasonCode();
    }

    // Get transaction detail link for more information
    $detailLink = $transaction->getTransactionDetailLink();
    echo "Details: " . $detailLink;
}
```

**Response Object Methods:**

**TransactionSearchResponse:**

- `getTransactions()`: Get transactions as Laravel Collection
- `hasMoreResults()`: Check if there are more pages
- `getNextOffset()`: Get next offset for pagination
- `getPaginationInfo()`: Get detailed pagination information
- `getSelfLink()`: Get the search result URL
- `isFirstPage()` / `isLastPage()`: Check pagination status

**TransactionSummary (individual transactions):**

- `getStatus()`: Get transaction status (approved, declined, etc.)
- `isApproved()` / `isDeclined()`: Check transaction status
- `getTotalAmount()` / `getCurrency()`: Get amount information
- `getMaskedCardNumber()`: Get masked card number (e.g., "4111\*\*\*\*1111")
- `getPaymentMethod()`: Get payment method (VI, MC, etc.)
- `getCustomerEmail()`: Get customer email address
- `getClientReferenceCode()`: Get your order reference
- `getApprovalCode()`: Get processor approval code
- `getReasonCode()`: Get Cybersource reason code
- `getTransactionDetailLink()`: Get URL for detailed transaction info

The search method returns a response containing:

- `searchId`: Unique identifier for the search
- `count`: Number of transactions found in current page
- `totalCount`: Total number of transactions matching the query
- `_embedded.transactionSummaries`: Array of transaction summaries

**Available Query Parameters:**

- `query` (required): The search query using Cybersource query syntax
- `name`: A descriptive name for the search (default: "Transaction Search")
- `timezone`: Timezone for date/time fields (default: "UTC")
- `offset`: Number of records to skip (default: 0)
- `limit`: Maximum number of records to return (default: 20, max: 2500)
- `sort`: Sort order (default: "submitTimeUtc:desc")

For more information about query syntax, see the [Cybersource Transaction Search API documentation](https://developer.cybersource.com/api-reference-assets/index.html#transaction-search_search-transactions_create-a-search-request_responsefielddescription_201).

### Handling the Response

[](#handling-the-response)

When a payment is completed, Cybersource will redirect the user back to your application. This package provides a route and controller to handle this response. The package will automatically verify the signature and fire one of four events:

- `Asciisd\Cybersource\Events\CybersourceHostedCheckoutApproved` - For successful payments (ACCEPT)
- `Asciisd\Cybersource\Events\CybersourceHostedCheckoutDeclined` - For declined payments (DECLINE)
- `Asciisd\Cybersource\Events\CybersourceHostedCheckoutError` - For error responses (ERROR)
- `Asciisd\Cybersource\Events\CybersourceHostedCheckoutCancelled` - For cancelled payments (CANCEL)

You can create listeners for these events to handle the payment outcome, such as updating an order's status in your database.

### Important: Handling ERROR and CANCEL Responses

[](#important-handling-error-and-cancel-responses)

When Cybersource returns an ERROR or CANCEL decision, the `transaction_id` field may be `null` or missing from the response. Always check for its existence in your event listeners:

```
// ❌ This will cause an error for ERROR decisions
$transactionId = $event->data['transaction_id'];

// ✅ Safe way to access transaction_id
$transactionId = $event->data['transaction_id'] ?? null;

// ✅ Or use the helper methods (for CybersourceHostedCheckoutError and CybersourceHostedCheckoutCancelled events)
$transactionId = $event->getTransactionId();

// ✅ Always available: reference number
$referenceNumber = $event->data['req_reference_number'] ?? null;
// Or use the helper method
$referenceNumber = $event->getReferenceNumber();
```

### Handling Notifications (Webhooks)

[](#handling-notifications-webhooks)

Cybersource can also send server-to-server notifications (webhooks) to your application for events like successful payments or refunds. This package provides a dedicated route and controller to handle these incoming notifications. The package will automatically verify the signature and fire the `Asciisd\Cybersource\Events\CybersourceHostedCheckoutNotificationReceived` event.

Customizing Views
-----------------

[](#customizing-views)

You can publish and customize the Blade views used by the package:

```
php artisan vendor:publish --provider="Asciisd\Cybersource\CybersourceServiceProvider" --tag="cybersource-views"
```

Testing
-------

[](#testing)

This package is configured to use the Cybersource sandbox environment by default. You can change this by updating the `CYBERSOURCE_ENDPOINT` value in your `.env` file.

```

```

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance57

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

18

Last Release

288d ago

Major Versions

v0.2.6 → v1.0.02025-07-29

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/77636067?v=4)[ASCII SD](/maintainers/asciisd)[@asciisd](https://github.com/asciisd)

---

Top Contributors

[![aemaddin](https://avatars.githubusercontent.com/u/11630742?v=4)](https://github.com/aemaddin "aemaddin (29 commits)")

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/asciisd-cybersource-hosted-checkout-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/asciisd-cybersource-hosted-checkout-laravel/health.svg)](https://phpackages.com/packages/asciisd-cybersource-hosted-checkout-laravel)
```

###  Alternatives

[lemonsqueezy/laravel

A package to easily integrate your Laravel application with Lemon Squeezy.

58596.1k](/packages/lemonsqueezy-laravel)[ssheduardo/redsys-laravel

Package redsys for laravel

100129.5k1](/packages/ssheduardo-redsys-laravel)[duncanmcclean/simple-commerce

A simple, yet powerful e-commerce addon for Statamic.

16313.2k2](/packages/duncanmcclean-simple-commerce)[tsaiyihua/laravel-ecpay

ecpay library for laravel

6416.3k](/packages/tsaiyihua-laravel-ecpay)[alifaraun/laravel-moamalat-pay

Easy - Moamalat Lightbox integration for Laravel.

1914.0k](/packages/alifaraun-laravel-moamalat-pay)[duncanmcclean/statamic-cargo

Comprehensive e-commerce addon for Statamic. Build bespoke e-commerce sites without the complexity.

322.8k](/packages/duncanmcclean-statamic-cargo)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
