PHP code example of ezeasorekene / credo-payments

1. Go to this page and download the library: Download ezeasorekene/credo-payments 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/ */

    

ezeasorekene / credo-payments example snippets


    $apiKeys = [
        'publicKey' => getenv("CREDO_MODE") == 'LIVE' ? getenv("CREDO_LIVE_PUBLIC_KEY") : getenv("CREDO_TEST_PUBLIC_KEY"),
        'secretKey' => getenv("CREDO_MODE") == 'LIVE' ? getenv("CREDO_LIVE_SECRET_KEY") : getenv("CREDO_TEST_SECRET_KEY"),
    ];

   $credo = new CredoPay( $apiKeys, getenv("CREDO_MODE") );

        $credodata = [
            'reference' => uniqid(),
            'amount' => 20000, //in kobo
            'bearer' => 0,
            'callbackUrl' => 'http://example.com/callback/credo',
            'currency' => 'NGN',
            'customerFirstName' => 'Credo',
            'customerLastName' => 'Package',
            'customerPhoneNumber' => '234080111111111',
            'email' => '[email protected]',
            'channels' => array('card', 'bank'),
            'serviceCode' => 'XXXXXXXXXXX',
            "metadata" => [
                "customFields" => [
                    [
                        'display_name' => 'Custom Field Display 1',
                        'variable_name' => 'Custom Field Variable 1',
                        'value' => 'Custom Field Value 1'
                    ]
                ]
            ],
        ];

    $response = json_decode($credo->initialize($credodata));

    $credo = new CredoPay( $apiKeys, getenv("CREDO_MODE") );
    $verify = json_decode($credo->verify($reference));