2017 © Pedro Peláez
 

cakephp-plugin cakephp-paypalwpp

CakePHP plugin to handle paypal web payments pro

image

cpierce/cakephp-paypalwpp

CakePHP plugin to handle paypal web payments pro

  • Thursday, October 20, 2016
  • by cpierce
  • Repository
  • 1 Watchers
  • 4 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

PayPal WebPaymentsPro (WPP) Component for CakePHP 2.x

CakePHP 2.x Component for interfacing with Paypal WPP, (*1)

Usage:

Load plugin in your APP and enable it by using the following bootstrap.php config:, (*2)

    CakePlugin::load('PaypalWPP');

Configure your account by opening the Config/paypal.php file as follows, (*3)

    $config = [
        'paypal' => [
            'username'  => 'username_api1.domain.com',
            'password'  => 'THGSWS658IKUN79S',
            'signature' => 'AFYn4irhcVyzOOiJkc.H2zPIuztlArzO7mr5uXMO6DLICAE85JF.H5PPp',
            'endpoint'  => 'https://api-3t.paypal.com/nvp',
            'version'   => '53.0',
        ],
    ];

Load the Component into the controller of your choice., (*4)

    public $components = [
        'PaypalWPP.PaypalWPP',
    ];

Next urlencode your data and send it to the component using a method and an nvp. For doing payments using DoDirectPayment (https://developer.paypal.com/webapps/developer/docs/classic/api/merchant/DoDirectPayment_API_Operation_NVP/) the following example would work:, (*5)

    /**
     * Add Method.
     */
    public function add()
    {
        if ($this->request->is('post') || $this->request->is('put')) {
            $firstName        = urlencode($this->request->data['Sale']['first_name']);
            $lastName         = urlencode($this->request->data['Sale']['last_name']);
            $creditCardType   = $this->request->data['Sale']['card_type'];
            $creditCardNumber = $this->request->data['Sale']['card_number'];
            $expDateMonth     = $this->request->data['Sale']['exp']['month'];
            $padDateMonth     = str_pad($expDateMonth, 2, '0', STR_PAD_LEFT);
            $expDateYear      = $this->request->data['Sale']['exp']['year'];
            $cvv2Number       = $this->request->data['Sale']['cvv2'];
            $amount           = $this->request->data['Sale']['amount'];
            $nvp              = '&PAYMENTACTION=Sale';
            $nvp             .= '&AMT=' . $amount;
            $nvp             .= '&CREDITCARDTYPE=' . $creditCardType;
            $nvp             .= '&ACCT=' . $creditCardNumber;
            $nvp             .= '&CVV2=' . $cvv2Number;
            $nvp             .= '&EXPDATE=' . $padDateMonth.$expDateYear;
            $nvp             .= '&FIRSTNAME=' . $firstName;
            $nvp             .= '&LASTNAME=' . $lastName;
            $nvp             .= '&COUNTRYCODE=US&CURRENCYCODE=USD';

            $response = $this->PaypalWPP->wpp_hash('DoDirectPayment', $nvp);
            if ($response['ACK'] == 'Success') {
                $this->Session->setFlash('Payment Successful');
            } else {
                $this->Session->setFlash('Payment Failed');
            }
            debug($response);
        }
    }

Other Methods can be found at https://devtools-paypal.com/apiexplorer/PayPalAPIs, (*6)

The Versions

20/10 2016

dev-master

9999999-dev http://github.com/cpierce/paypalwpp-plugin-for-cakephp-2.x

CakePHP plugin to handle paypal web payments pro

  Sources   Download

MIT

The Requires

 

cakephp paypal webpaymentspro wpp