PHP code example of amasty / paypal-nvp-api

1. Go to this page and download the library: Download amasty/paypal-nvp-api 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/ */

    

amasty / paypal-nvp-api example snippets



// @see https://developer.paypal.com/docs/classic/api/
use PaypalNvpApi\Client;

$client = new Client(
    'paypal username',
    'paypal password',
    'paypal signature',
    true // use sandbox
);

// If something is wrong, Exception will be thrown
$client->call('ManageRecurringPaymentsProfileStatus', [
    'PROFILEID' => 'I-PB2SG17EAY4N',
    'ACTION' => 'Cancel',
]);


// @see https://developer.paypal.com/docs/classic/products/instant-payment-notification/
use PaypalNvpApi\IpnVerifier;

$ipnVerifier = new IpnVerifier($_POST);
// If something is wrong, Exception will be thrown
$ipnVerifier->validate();