1. Go to this page and download the library: Download cpierce/paypal-wpp 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/ */
cpierce / paypal-wpp example snippets
namespace App\Form;
use Cake\Form\Form;
use Cake\Form\Schema;
use Cake\Validation\Validator;
use PaypalWPP\PaypalWPP;
use Cake\Core\Configure;
/**
* Sales Form class.
*
* @extends Cake\Form\Form
*/
class SalesForm extends Form
{
/**
* Parse Data Array.
*
* @var array
*/
protected $parseData = [];
/**
* Build Schema Method.
*
* @param Schema $schema
*
* @return Schema $schema
*/
protected function _buildSchema(Schema $schema)
{
return $schema->addField('first_name', 'string')
->addField('last_email', 'string')
->addField('card_number', 'string')
->addField('amount', 'string');
}
/**
* Build Validator Method.
*
* @param Validator $validator
*
* @return Validator $validator
*/
protected function _buildValidator(Validator $validator)
{
return $validator
->notBlank('first_name', __('Your first name is return false;
}
/**
* Get Parse Data Method.
*
* @return string
*/
public function getParseData()
{
return $this->parseData;
}
}
namespace App\Controller;
use App\Form\SalesForm;
/**
* Sales Controller.
*/
class SalesController extends AppController
{
/**
* Add Method.
*/
public function add()
{
$sales = new SalesForm();
if ($this->request->is(['post', 'put'])) {
$transaction_execute = $sales->execute($this->request->data);
$transaction = $sales->getParseData();
if ($transaction_execute) {
$this->Flash->success(
__('Payment Completed Successfully: '.$transaction['transaction_id'])
);
$this->render('success');
} else {
$this->Flash->error(
__('Payment Failed: '.$transaction['failure_message'].'['.$transaction['failure_short'].']')
);
}
}
$this->set(compact('sales'));
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.