Dear All,
this is my first post, but I have well read all that I found.
I really appreciate this module. I have integrated it successfully in my current (and first with yii) project.
I use ‘class’=>‘payPal.components.PPDbButtonManager’, so my buttons are also stored locally in my db.
Buttons are created successfully and a basic transition with paypal sandbox is successfully completed, with PDT and IPN…
But I don’t understand some things.
My situation is that I will create (or retrieve) the button at the checkout step, so always I have "1 button for 1 sessionID".
If the web user don’t proceed with the payment and he modify the cart, at the next checkout, the button (previously created) must be updated for the price.
[Step1]: the user proceed with the checkout for a cart amount of 200.25, so the button is created and stored in my db
[Step2]: the user go back and add some items in the cart, changing the total amount to 400.50
[Step3]: the user newly proceed with the checkout. At this point the button must be updated in the price.
My log is ok, no error message, but the price is always the old one, as the updateButton have failed.
Are my logic and code wrong?
Any help is welcome! Thanks in advance.
$paypalButtonName = CHtml::encode('Cart' . $mySessionID);
$buttonManager = Yii::app()->getModule('payPal')->buttonManager;
$myPaypalButton = $buttonManager->getButton($paypalButtonName);
if(!$myPaypalButton)
{
$nvp = array(
'BUTTONTYPE'=>'BUYNOW',
'L_BUTTONVAR0'=>'currency_code=EUR',
'L_BUTTONVAR1'=>'item_name=' . CHtml::encode('Cart' . $mySessionID),
'L_BUTTONVAR2'=>'amount='.(string)(number_format(Yii::app()->shoppingCart->getCost(),2))
);
$myPaypalButton = $buttonManager->createButton($paypalButtonName, $nvp);
} else {
$myPaypalButton = $buttonManager->updateButton($paypalButtonName, array('L_BUTTONVAR0'=>'amount='.(string)(number_format(Yii::app()->shoppingCart->getCost(),2))));
}
I think that the problem can be in updateButton, where the new price is in
L_BUTTONVAR0 but in the same array the old price is in L_BUTTONVAR5. I suppose that paypal founding both prices, update the button with the second.
[font="Courier New"]
[color="#2E8B57"][Step1] 2012/08/30 09:09:32 [info] [payPal.components.PPButtonManager] Successfully created button[/color]
Request: BUTTONTYPE=BUYNOW&L_BUTTONVAR0=currency_code=EUR&L_BUTTONVAR1=item_name=Cartrb7lpfglf79qd9pe3j5t2rlbc4&L_BUTTONVAR2=amount=200.25&METHOD=BMCreateButton
in /web/htdocs/www.mydev/home/myproject/protected/modules/payPal/components/PPButtonManager.php (240)
in /web/htdocs/www.mydev/home/myproject/protected/modules/payPal/components/PPButtonManager.php (72)
in /web/htdocs/www.mydev/home/myproject/protected/controllers/CartController.php (47)
[b][color="#2E8B57"]
[Step3] 2012/08/30 09:10:51 [info] [payPal.components.PPButtonManager] Successfully fetched button details[/color][/b]
Request: METHOD=BMGetButtonDetails&HOSTEDBUTTONID=BHZA4CZMPVGAY
Response: WEBSITECODE=<form action="…webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="BHZA4CZMPVGAY">
<input type="image" src="…" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="…" width="1" height="1">
</form>
&EMAILLINK=…webscr?cmd=_s-xclick&hosted_button_id=BHZA4CZMPVGAY&HOSTEDBUTTONID=BHZA4CZMPVGAY&BUTTONCODE=HOSTED&BUTTONTYPE=BUYNOW&BUTTONSUBTYPE=PRODUCTS&L_BUTTONVAR0="bn=65SCB4HF3URR2:PP-BuyNowBF_P"&L_BUTTONVAR1="no_note=0"&L_BUTTONVAR2="business=65SCB4HF3URR2"&L_BUTTONVAR3="currency_code=EUR"&L_BUTTONVAR4="item_name=Cartrb7lpfglf79qd9pe3j5t2rlbc4"&L_BUTTONVAR5="amount=200.25"&BUTTONIMAGE=REG&BUYNOWTEXT=BUYNOW&BUTTONCOUNTRY=IT&BUTTONLANGUAGE=en&TIMESTAMP=2012-08-30T07:10:51Z&CORRELATIONID=8acf8b24a1036&ACK=Success&VERSION=63.0&BUILD=3587318
in /web/htdocs/www.mydev/home/myproject/protected/modules/payPal/components/PPButtonManager.php (240)
in /web/htdocs/www.mydev/home/myproject/protected/modules/payPal/components/PPButtonManager.php (153)
in /web/htdocs/www.mydev/home/myproject/protected/modules/payPal/components/PPButtonManager.php (88)
[color="#008000"]2012/08/30 09:10:52 [info] [payPal.components.PPButtonManager] Successfully updated button[/color]
Request: WEBSITECODE=<form action="…webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="BHZA4CZMPVGAY">
<input type="image" src="…" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="…" width="1" height="1">
</form>
&EMAILLINK=…webscr?cmd=_s-xclick&hosted_button_id=BHZA4CZMPVGAY&HOSTEDBUTTONID=BHZA4CZMPVGAY&BUTTONCODE=HOSTED&BUTTONTYPE=BUYNOW&BUTTONSUBTYPE=PRODUCTS&[color="#0000FF"]L_BUTTONVAR0=amount=400.50[/color]&L_BUTTONVAR1="no_note=0"&L_BUTTONVAR2="business=65SCB4HF3URR2"&L_BUTTONVAR3="currency_code=EUR"&L_BUTTONVAR4="item_name=Cartrb7lpfglf79qd9pe3j5t2rlbc4"&[color="#FF0000"]L_BUTTONVAR5="amount=200.25"[/color]&BUTTONIMAGE=REG&BUYNOWTEXT=BUYNOW&BUTTONCOUNTRY=IT&BUTTONLANGUAGE=en&TIMESTAMP=2012-08-30T07:10:51Z&CORRELATIONID=8acf8b24a1036&ACK=Success&VERSION=63.0&BUILD=3587318&METHOD=BMUpdateButton
in /web/htdocs/www.mydev/home/myproject/protected/modules/payPal/components/PPButtonManager.php (240)
in /web/htdocs/www.mydev/home/myproject/protected/modules/payPal/components/PPButtonManager.php (104)
in /web/htdocs/www.mydev/home/myproject/protected/controllers/CartController.php (53)[/font]