PHP code example of ianfoxdev / decline-codes

1. Go to this page and download the library: Download ianfoxdev/decline-codes 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/ */

    

ianfoxdev / decline-codes example snippets


use IanFoxDev\DeclineCodes\{Attempt, Catalog, RetryPolicy};

$catalog = Catalog::default();

// A Stripe decline that carries the network's raw code.
$decline = $catalog->stripe()->resolve(
    'insufficient_funds',
    brand: 'visa',
    networkDeclineCode: '51',
);
$decline->reason->id;     // "insufficient_funds"
$decline->class;          // DeclineClass::Later
$decline->category;       // 2, Visa's "Issuer cannot approve at this time"

$decision = RetryPolicy::default()->decide([
    Attempt::declined(new DateTimeImmutable('2026-10-01 06:00'), $decline, 'acme', 1900),
]);
$decision->verdict;       // Verdict::RetryAt
$decision->notBefore;     // 2026-10-02 06:00
$decision->rule;          // "schedule.later"

never  mastercard.mac_03  Mastercard sent Merchant Advice Code 03 (Do not try again);
                          resubmitting is charged as an excessive retry.