1. Go to this page and download the library: Download asciisd/cashier-core 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/ */
asciisd / cashier-core example snippets
// config/cashier-core.php
'default_connection' => env('CASHIER_DEFAULT_CONNECTION', 'manual'),
'connections' => [
'aps' => [
'driver' => 'aps',
'base_url' => env('APS_BASE_URL'),
'merchant_guid' => env('APS_MERCHANT_GUID'),
'app_token' => env('APS_APP_TOKEN'),
'app_secret' => env('APS_APP_SECRET'),
'callback_secret' => env('APS_CALLBACK_SECRET'), // signs callbacks; not the app secret
'deposit_method' => env('APS_DEPOSIT_METHOD'), // charge() throws without it
// Optional: default to the `payment.success` / `webhooks.aps` routes.
'redirect_url' => env('APS_REDIRECT_URL'),
'webhook_url' => env('APS_WEBHOOK_URL'),
// Optional: APS returns card checkout URLs on its JSON API host.
'checkout_host_map' => ['api.pci-gw.com' => 'form.pci-gw.com'],
],
'aps_apple_pay' => [
'driver' => 'aps', // same driver, different account
'base_url' => env('APS_APPLEPAY_BASE_URL'),
'merchant_guid' => env('APS_APPLEPAY_MERCHANT_GUID'),
'app_token' => env('APS_APPLEPAY_APP_TOKEN'),
'app_secret' => env('APS_APPLEPAY_APP_SECRET'),
'callback_secret' => env('APS_APPLEPAY_CALLBACK_SECRET'),
'deposit_method' => env('APS_APPLEPAY_DEPOSIT_METHOD'),
// Opt in to the customer/billing block (default false).
'send_billing_details' => true,
],
],
// 1. Your user model
class User extends Authenticatable implements \Asciisd\CashierCore\Contracts\CustomerContract
{
public function cashierId(): int|string { return $this->id; }
public function cashierEmail(): string { return $this->email; }
public function cashierName(): string { return $this->name; }
public function cashierLocale(): string { return $this->locale ?? 'en'; }
}
// 2. Your funds system — without this binding, the default NullLedger
// refuses every movement loudly instead of pretending funds moved.
$this->app->singleton(FundsLedger::class, Mt5FundsLedger::class);
// 3. Optional: resolve which account a deposit funds (by reference, etc.).
$this->app->singleton(ResolvesFundingAccount::class, TradingAccountResolver::class);
// 4. Optional: your own transaction model extending the package base model.
'models' => [
'transaction' => \App\Models\Transaction::class,
'customer' => \App\Models\User::class,
],
use Asciisd\CashierCore\Services\PaymentService;
$result = app(PaymentService::class)->processPayment(
customer: $user,
paymentData: ['amount' => 100, 'trading_account_login' => 555555],
connection: 'aps',
feeConfiguration: $paymentMethod, // implements FeeConfigurationContract, or null
);
if ($result->
// Fake connections: charges record in-process, nothing reaches a PSP.
$fake = Cashier::fake(['aps']);
$fake->whenCharging('aps', $declinedResult); // queue outcomes
$fake->assertChargedOn('aps', fn ($data) => $data['amount'] === 100);
// Real drivers without sandbox secrets: driver-appropriate test credentials.
Cashier::fakeConnection('aps_binance', ['callback_secret' => 'other']);
// Webhooks signed exactly as the PSP would sign them.
$delivery = WebhookSimulator::make('aps', $payload, connection: 'aps_binance');
$this->postJson($delivery->uri, $delivery->payload, $delivery->headers)->assertOk();
// Ledger assertions without an MT5 server.
app()->instance(FundsLedger::class, $ledger = new FakeLedger);
$ledger->assertMoved('credit', fn ($m) => $m['amount'] === 100.0);
$ledger->refuseAll(); // simulate a refusing ledger