PHP code example of hongyukeji / laravel-payment

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

    

hongyukeji / laravel-payment example snippets


// config/app.php

    'providers' => [
        //...
        Hongyukeji\LaravelPayment\Providers\PaymentServiceProvider::class,
    ],
shell
$ php artisan vendor:publish --provider="Hongyukeji\\LaravelPayment\\Providers\\PaymentServiceProvider"

// config/app.php

    'aliases' => [
        'Payment' => Hongyukeji\LaravelPayment\Facades\Payment::class, // This is default in laravel 5.5
    ],

$formData = [
    'number' => '4242424242424242', 
    'expiryMonth' => '6', 
    'expiryYear' => '2030', 
    'cvv' => '123'
];

$response = Payment::purchase([
    'amount' => '10.00', 
    'currency' => 'USD', 
    'card' => $formData,
))->send();

if ($response->isRedirect()) {
    // redirect to offsite payment gateway
    $response->redirect();
} elseif ($response->isSuccessful()) {
    // payment was successful: update database
    print_r($response);
} else {
    // payment failed: display message to customer
    echo $response->getMessage();
}