PHP code example of digistorm / omnipay-braintree

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

    

digistorm / omnipay-braintree example snippets


$clientToken = $gateway->clientToken()->send()->getToken();

$response = $gateway->purchase([
            'amount' => '10.00',
            'token' => $_POST['payment_method_nonce']
        ])->send();

$customer = $gateway->createCustomer([
    'customerData' => [
        'id' => 1,
        'firstName' => 'John',
        'lastName' => 'Doe'
    ]
])->send();

$customer = $gateway->findCustomer(1)->send();

$method = $gateway->createPaymentMethod([
    'customerId' => $user->getId(),
    'paymentMethodNonce' => 'paymentnonce',
    'options' => [
        'verifyCard' => true
    ]
]);

$method = $gateway->updatePaymentMethod([
    'paymentMethodToken' => 'token123',
    'options' => [
        'paymentMethodNonce' => 'paymentnonce'
    ]
]);

$subscription = $gateway->createSubscription([
    'subscriptionData' => [
        'paymentMethodToken' => 'payment_method_token',
        'planId' => 'weekly',
        'price' => '30.00'
    ]
])->send();

$subscription = $gateway->cancelSubscription('id')->send();

$notification = $gateway->parseNotification([
    'bt_signature' => 'signature',
    'bt_payload' => 'payload'
])->send();