what's wrong with this code to update a paypal button? I get "buttontype invalid error"
Asked Answered
O

1

6

I'm trying to dynamically update a PayPal hosted button but getting an error that

The button type specified is invalid.

I used the PPHttpPost function (which is probably fine), taken from here: https://www.x.com/paypal-apis-dodirectpayment-php-5.3/nvp, I just removed all the nvp variables except API signature, password etc.

This is my code to use the ButtonManager:

// Set request-specific fields.

 $nvpStr =  "&HOSTEDBUTTONID=buynow&BUTTONCODE=HOSTED&AMT=330.66&BUTTONTYPE=BUYNOW";

// Execute the API operation; see the PPHttpPost function above.
$httpParsedResponseAr = PPHttpPost('BMUpdateButton', $nvpStr);

var_dump($httpParsedResponseAr);

?>

What am I doing wrong?

Edit

When I remove HOSTEDBUTTONID from the request string and output the full NVP string, I get this (replaced some characters with underscore for privacy):

METHOD=BMUpdateButton&VERSION=98.0&PWD=1362320204&USER=___._1362320167_biz_api1.gmail.com&SIGNATURE=________________&BUTTONCODE=HOSTED&AMT=330.66
Obfuscate answered 9/3, 2013 at 7:29 Comment(2)
Remove HOSTEDBUTTONID - this is part of the response, but shouldn't be included in your request. Can you also print $nvpStr?Greylag
I've edited the question to add the full printed out NVP string at the end.Obfuscate
D
6

After running into the same issue, I have figured the issue out.

Along with:

"BUTTONTYPE" => "BUYNOW"

You need:

"BUTTONSUBTYPE" => "PRODUCTS"

I know it says optional in the API docs, but it's really required.

The sub type will either be PRODUCTS or SERVICES.

Darkness answered 3/1, 2014 at 8:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.