free hit counter

paypal component for cakephp 2

paypal component for cakephp

Hello Friend  many time you use paypal payment using in html (form and its hidden field etc.)

But in CakePHP nothing to do . No need to create from .

so how to do it .. just follow simple step

1. save this component  in app->controller -> component  floder

Download paypal component

2. In controller  Include the Payapl component
public $components = array(‘Paypal’);

3. you need to create paypal API in paypal setting . after create API file in open paypal component and
           ‘webscr’ => ‘https://www.sandbox.paypal.com/webscr/’,
        ‘endpoint’ => ‘https://api.sandbox.paypal.com/nvp/’,
        ‘password’ => ”,
        ’email’ => ”,
        ‘signature’ => ”

fill password, email , signature .

 

4. now in controller  just use this function

      // Set the values and begin paypal process
      public function express_checkout() {
        try{
            $this->Paypal->amount = 10.00;
            $this->Paypal->currencyCode = ‘GBP’;    
            $this->Paypal->returnUrl = Router::url(array(‘action’ => ‘get_details’), true);
            $this->Paypal->cancelUrl = Router::url($this->here, true);
            $this->Paypal->orderDesc = ‘A description of the thing someone is about to buy’;
            $this->Paypal->itemName = ‘Swedish penis enlargement kit’;
            $this->Paypal->quantity = 1;
            $this->Paypal->expressCheckout();
        } catch(Exception $e) {
            $this->Session->setFlash($e->getMessage());
        }
      }

you can set parameter as up to you

when you calll this funcation , this function redirect in paypal . now make payment after payment we call this funcation

    // Use the token in the return URL to fetch details
      public function get_details() {
            try {
                $this->Paypal->token = $this->request->query[‘token’];
                $this->Paypal->payerId = $this->request->query[‘PayerID’];
            $customer_details = $this->Paypal->getExpressCheckoutDetails();
                debug($customer_details);
            } catch(Exception $e) {
            $this->Session->setFlash($e->getMessage());
        }
      }

 

this function will return us all details about payment .

its very simple to use .

direct credit card payment function also in this code . just download and use it .

 

 

2 thoughts on “paypal component for cakephp

  1. Reply Sakshi Soni Aug 11,2015 11:37 am

    The page is not redirecting anywhere. It just getting load after $response = $httpSocket->post($this->config[‘endpoint’] , $setExpressCheckoutNvp); line in PaypalComponent.php

  2. Reply Ashish Aug 8,2016 3:22 am

    Its not working for cakephp 3.x version

Leave a Reply