简体   繁体   中英

PayPal Custom “Buy Now” Button

I'm using the PayPal API at the moment to create a button, I'm using the API as I have numerous tiers available and it's easier for me to create them this way. The current code I have is:

$sendPayData = array(
    "METHOD" => "BMCreateButton",
    "VERSION" => "65.2",
    "USER" => "userfoo.paypal.com",
    "PWD" => "1234567890",
    "SIGNATURE" => "asf234.NotARealSignature.28rd28uhGDG09",
    "BUTTONCODE" => "ENCRYPTED",
    "BUTTONTYPE" => "BUYNOW",
    "BUTTONSUBTYPE" => "SERVICES",
    "BUTTONCOUNTRY" => "GB",
    "BUTTONIMAGE" => "reg",
    "BUYNOWTEXT" => "BUYNOW",
    "L_BUTTONVAR1" => "item_number=6500",
    "L_BUTTONVAR2" => "item_name=Up to 500 users for 6 months",
    "L_BUTTONVAR3" => "amount=60",
    "L_BUTTONVAR4" => "currency_code=GBP",
    "L_BUTTONVAR5" => "no_shipping=1",
    "L_BUTTONVAR6" => "no_note=1",
    "L_BUTTONVAR8" => "cancel_return=https://www.foo.com/Payment/Cancel",
    "L_BUTTONVAR9" => "return=https://www.foo.com/Payment/Success"
);
$payreturn=file_get_contents('https://api-3t.sandbox.paypal.com/nvp?'.http_build_query($sendPayData));
$paypalResponse = array();
parse_str($payreturn,$paypalResponse);

Where I can use echo $paypalResponse['WEBSITECODE'] to show the typical "Buy Now" button, but its not displaying at all on my iPhone. It just displays a grey box?

Anyway, I would prefer to use my own styled button, not an image as PayPal uses. I know that the form comprises of 3 fields, the hidden cmd value, the hidden encrypted value and the actual image itself to submit the form.

I can create my own button, it's just I cannot get the encrypted field value from the API to insert into my own system.

I would like to know if this is the best way to solve my issues, and how to do it, or is there an alternative

This is what PayPal uses in the button form to change the button image:

<input type="image" src="https://yourimage.jpg" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">

So if you use this basis you can change the button image. This is just the basic button, you will need to confirm that your image is mobile optimized.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM