Paypal Instigation Using 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 .

Advertisements

Software Engineer at The Jaxara IT Ltd , Dhaka , Bangladesh

Tagged with: , , ,
Posted in CakePHP
One comment on “Paypal Instigation Using CakePHP

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: