PHP code example of a17mad / laravel-cybersource

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

    

a17mad / laravel-cybersource example snippets


php artisan vendor:publish --tag=cybersource

- cd into your app 
- php artisan serve
- Visit (http://127.0.0.1:8000/cybersource/payment/form)


$response = Cybersource::createSubscription(
    $paymentToken,
    $productId,
    $productTotal,
    $frequency
);

if($response->isValid()) {
    $responseDetails = $response->getDetails();
    echo $responseDetails['paySubscriptionCreateReply']['subscriptionID'];
} else {
    echo $response->error();
}

$response = Cybersource::getSubscriptionStatus(
    $subscriptionID
);

if($response->isValid()) {
    $responseDetails = $response->getDetails();
    echo $responseDetails['message'];
} else {
    echo $response->error();
}