The code above will create a hosted button stored at PayPal, it is also stored locally in your database (or a php file, if you’re using PPPhpButtonManager). To view the button you need to fetch the HTML code using
$buttonManager->getButton('My button');
.
The button should be created only once, if you do it multiple times, you will create a bunch of new buttons stored at PayPal.
Not that I know of. There are some examples in the extension page. You can also find some information in this thread (a very simple store sample, etc.).
I would recommend looking at PayPal’s documentation. The extension will take care of sending/receiving data, but you need to validate and process events (e.g. payments) as documented by PayPal.
Read about instant payment notificatoin
Read about the button manager if you’d like to use hosted buttons (take not of the NVP examples, that’s what you will be using in PPButtonManager)
thank you for your valuable work. I made it running thanks to this thread I’ve a site where the button is used only once, since it is used for pay per use services, so amount will change each time.
However my buttons in the "My saved buttons" page in PayPal sandbox account are all in the form
My button (ID: NLJ23RALHGAW2) Created 7/28/2011
The ID is not the one I’ve created before.
How can I force the ID of the button, so I can later on delete the button (after receiving the IPN)?
Does the extension provide a quick way to delete a button?
Finally, since I also have products with fixed prices, I would like to implement "add cart" and "view cart" buttons. Is it possible to do that with PPExt?
Yes, PPExt let’s you use all possible options from PayPal’s button manager API. The following link includes an “Add to cart” example: Button manager examples.
I have been directly requesting the controller via a browser and it does trigger the actions, I see the built-in log entries and others that I’ve added to trace it. Every time I send a test IPN or resend an actual one, no action is called, I don’t even trigger log entries at the top of the ActionIpn method. It seems like the URL is not resolving correctly actually since nothing in the actionIpn method works. The IPN URL I have at PayPal is … [mysite]/payment/ipn/. I see the POST requests “POST /reservation/payment/ipn/ HTTP/1.0” 200 181 “-” “-”
Unable to resolve the request "payPal/PPDefaultController".
Just FYI… this is a controller based on Legacy (PHP <5.3) code.
I think you’re right. Not sure what could cause the problem though.
Probably need to use payPal/pPdefaultController to resolve the request (yes I know, it’s a horrible controller name…), but since you were able to resolve payments/ipn there is no need to test PPDefaultController (or PPLegacyController).
I think I have some POST conflict somewhere as I have this as part of a subsystem underneath an ExpressionEngine site. I really don’t know. I’ll keep trying some things.
Actually I am breaking down my controller and see that the POST is failing due to various issues in the functions. I now have a simple controller that has two methods. The IPN path calls actionIpn successfully now and the log entries fire. The ipnRequest() function fails in the Failure($event) call that I’ve commented out. For some reason if this method fails, so does actionIpn. In other words, I get no logging if the ipnRequest method fails.
I do notice that the !isset($event->details["txn_id"] evaluates as TRUE even though the POST does have that parameter. That be the root of the issue here. Not sure.
<?php
Yii::import('payPal.models.*');
Yii::import('payPal.controllers.ipn.*');
Yii::import('payPal.components.*');
class ApiController extends Controller {
public function actionIpn() {
Yii::log('API:IPN:PAYPALREQUEST','info','application.controllers.api');
$ipn = new PPIpnAction($this,"ipn");
$ipn->onRequest = array($this, "ipnRequest");
$ipn->onFailure = array($this, "ipnFailure");
$ipn->onSuccess = array($this, "ipnSuccess");
$ipn->run();
}
public function ipnRequest() {
Yii::log("API:IPN:READTOPROCESS","info","application.controllers.api");
if (!isset($event->details["txn_id"])) {
$event->msg = "Missing txn_id";
Yii::log($event->msg,"warning","application.controllers.PaymentController");
//$event->sender->onFailure($event);
return;
}
}
}
I seemed to have solved this by passing $event through to the ipnRequest method. It wasn’t there in the DefaultLegacyController. Just need to get the transaction saving to my DB now…
Yes, I simply was missing the $event parameter. The sample controller is right. I was wrong.
public function ipnRequest($event) {
Yii::log("API:IPN:READY_TO_PROCESS","info","application.controllers.api");
//Check transaction ID
if (!isset($event->details["txn_id"])) {
$event->msg = "API:IPN:HAS_NO_TX";
Yii::log($event->msg,"warning","application.controllers.api");
$event->sender->onFailure($event);
return;
} else {
$event->msg = "API:IPN:CONFIRMED_TXN_ID";
Yii::log($event->msg,"info","application.controllers.api");
}
..
}.
I’ll definitely post the full code I’m using in the next few days. I created a custom controller for API listeners based on the legacy default controller that I’ll use for all inbound 3rd party services. ppext is a great extension that everyone should check out if needed. It certainly takes full advantage of the Yii conventions and doesn’t just place the IPN sample procedural code in a controller.