PHP code example of hostbox / nette-paypal-payment-buttons

1. Go to this page and download the library: Download hostbox/nette-paypal-payment-buttons 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/ */

    

hostbox / nette-paypal-payment-buttons example snippets


use HostBox\Components\PayPal\PaymentButtons\ButtonFactory;
use HostBox\Components\PayPal\PaymentButtons\Subscribe;
use Nette\Application\UI\Presenter;

class PaypalPaymentPresenter extends Presenter {

    /** @var ButtonFactory */
    protected $buttonFactory;


    public function __construct(ButtonFactory $buttonFactory) {
        parent::__construct();
        $this->buttonFactory = $buttonFactory;
    }

    // component create by Factory
    public function createComponentBuyNow() {
        return $this->buttonFactory->createBuyNow();
    }

    // default settings by factory function parameter
    public function createComponentDonate() {
        return $this->buttonFactory->createDonate(array(
            'quantity' => 10,
            'tax' => 10.5
        ));
    }

    // by component function parameter
    public function createComponentQRCodes() {
        $component = $this->buttonFactory->createQRCodes();
        $component->assign(array(
            'quantity' => 10,
            'tax' => 10.5
        ));

        return $component;
    }

    // by component variable
    public function createComponentSubscribe() {
        $component = $this->buttonFactory->createSubscribe();
        $component->period = Subscribe::PERIOD_YEARS

        return $component;
    }

}