PHP code example of omnipay / authorizenet

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

    

omnipay / authorizenet example snippets


// $gateway is an instantiation of the AIM driver.
// $dataDescriptor and $dataValue come from the payment form at the front end.

use Omnipay\Common\CreditCard;

$request = $gateway->purchase(
    [
        'notifyUrl' => '...',
        'amount' => $amount,
        //
        'opaqueDataDescriptor' => $dataDescriptor,
        'opaqueDataValue' => $dataValue,
        //
        'card' => new CreditCard([
            'firstName' => 'Anne',
            'lastName' => 'Payee',
            ...
        ]),
        ...
    ]
);

// $gateway is an instantiation of the CIM driver. //Omnipay::create( 'AuthorizeNet_CIM' )
// $dataDescriptor and $dataValue come from the payment form at the front end.

$request = $gateway->createCard(
    [
        'opaqueDataDescriptor' => $dataDescriptor,
        'opaqueDataValue' => $dataValue,
        'name' => $name,
        'email' => $email, //Authorize.net will use the email to identify the CustomerProfile 
        'customerType' => 'individual',
        'customerId' => $user_customer_id,//a customer ID generated by your system or send null
        'description' => 'MEMBER',//whichever description you wish to send
        'forceCardUpdate' => true
        'card' => [
            'billingFirstName' => $name,
            'billingLastName' => $last_name,
            'billingAddress1' => $address,
            'billingCity' => $city,
            'billingState' => $state,
            'billingPostcode' => $zipcode,
            'billingPhone' => '',
            //... may 

$gateway->setSignatureKey('48D2C629E4A...{100}...E7CA3C4E6CD7223D');