The request to obtain paykey PAYPAL - php

I have my API credentials:
Api username
Api password
and the app fingerprint
I need to get the PayPal PayKey.
this is my form:
<div class="container secretPaypal">
<div class="row">
<form action="https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay" target="PPDGFrame"
class="standard">
<div class="form-group">
<label for="buy">Buy Now:</label>
<input type="image" id="submitBtn" value="Pay with PayPal"
src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif">
</div> <input id="type" type="hidden" name="expType" value="light">
<input id="paykey" type="hidden" name="paykey" value="insert_pay_key">
</form> </div> </div>
in paypal Documentation :
Step 3: Insert a Pay Key into the HTML Form
For the payKey input value, replace insert_pay_key with a payKey value that you recently obtained using a Pay call, and save the HTML file.
Documentation is confusing me and I don't know the request URL or the request params in order to obtain the needed paykey.
Any help please

You would need to run your API to request the paykey from the Pay operation, this s part of your initial call. In the document, see steps 1-5 under "Make your first call" - Adaptive Payments - Developer Guide

Related

Paypal sandbox not returning data

I implemented a paypal checkout about 3 years ago and it is currently working well. I now want to create a new checkout page for a new set of items. I copied the code from the page that I previously used and updated it for the new items. I set up the new page to use my sandbox for initial testing. The code below is cut from the actual page for display here.
<!DOCTYPE HTML >
<html>
<head>
</head>
<body>
<div>
<form id='paypal_form' action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="add" value="1" />
<input type="hidden" name="business" value="buyer#test.com" />
<input type="hidden" name="item_name" value="non-member RTV Renewal" />
<input type="hidden" name="amount" value="75.00" />
<input type="hidden" name="custom" value="Id=Joe;fixedName=Joe Smith;pw=1234;email=buyer#google.com;expdate=2024-02-14" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="lc" value="US" />
<input type="hidden" name="cancel_return" value="https://www.roundalab.org/Figures_Subscriptions_All/test_renew.htm">
<input type="hidden" name="return" value="https://www.roundalab.org/Figures_Subscriptions_All/success_test.php">
<input type="hidden" name="rm" value="2">
<center>
<div id="add-cart" style="padding:30px;">
<button onClick="document.getElementById('paypal_form').submit();">Click Here To Submit Order To Paypal</button>
</div>
</center>
</form>
</div>
</div>
</body>
</html>
The code works and creates an order in the paypal sandbox. It is then supposed to go the the url in the "return' item, which it does. The problem is that paypal is supposed to return a bunch of data in $_POST. When the return page is displayed, $_POST is empty. I also display $_GET and it contains 1 field which is the payer_id. A couple of questions...
Anyone know why no data in $_POST?
Is there a way that I can get any kind of error message that shows info on why no POST data was sent when going to the url in the return item?
I assume that this method of using paypal is deprecated. Is there a place that I can still get to the docs for using this interface?
The receiving sandbox Business account needs to enable Payment Data Transfer for any data to be returned.
With this sort of HTML-only (no API) PayPal integration that redirects away from your site, a return after a completed transaction is never guaranteed to occur. PayPal may be obligated to show the payer a receipt, or they may never click to return, or their browser may be closed or crash. Therefore, you should not depend on this returned data for absolutely anything of any importance. It is for extra informational purposes only.
If you are trying to do anything important with data returned via _GET/_POST , your integration is flawed.
With such an HTML-only <form> post integration, the only reliable way to receive data is by implementing the IPN service, which is also very old. All of these are poor choices if you need to do anything important with the data being returned.
Instead, use a current PayPal Checkout integration. Follow the Set up standard payments guide and make 2 routes on your server, one for 'Create Order' and one for 'Capture Order', documented here. Both routes should return only JSON data (no HTML or text). Inside the 2nd route, when the capture API is successful you should store its resulting payment details in your database (particularly purchase_units[0].payments.captures[0].id, which is the PayPal transaction ID) and perform any necessary business logic (such as sending confirmation emails or reserving product) immediately before forwarding your return JSON to the frontend caller.
Pair those 2 routes with the frontend approval flow: https://developer.paypal.com/demo/checkout/#/pattern/server

Paypal Payflow Transparent Redirect Error Code: PL001

I am working on integrating a php payment form with Paypal Payflow using Transparent Redirect. I am getting the secure token OK but when I post the credit card information to https://pilot-payflowlink.paypal.com my browser displays this:
Error: There was a problem processing your request. If you continue to have an issue, please contact us. Error Code: PL001.
Here are the details of the token request:
To request the secure token, I posted the following to: https://pilot-payflowpro.paypal.com.
USER=**********
&VENDOR=***********
&PARTNER=PayPalUK
&PWD=************
&TRXTYPE=S
&TENDER=C
&CURRENCY=GBP
&CREATESECURETOKEN=Y
&SECURETOKENID=7og61wr3n8wbg2j866vqfken0r3izucof5k2
&SILENTTRAN=TRUE
&BILLTOFIRSTNAME=Dave
&BILLTOLASTNAME=Testing
&BILLTOSTREET=123 Some St
&BILLTOZIP=47374
&EMAIL=test#davefeltz.com
&AMT=1.00
I get a valid response back with RESULT=0 and SECURETOKEN=9fIJH6BNI80qLIV7cWdv5VQ9p
Then I post the credit card info to https://pilot-payflowlink.paypal.com with this form:
<form id="payment_form" name="payment_form" method="post" action="https://pilot-payflowlink.paypal.com">
<input type="hidden" name="SECURETOKEN" value="9fIJH6BNI80qLIV7cWdv5VQ9p">
<input type="hidden" name="SECURETOKENID" value="7og61wr3n8wbg2j866vqfken0r3izucof5k2">
<input type="hidden" id="ACCT" name="ACCT" value="4242424242424242">
<input type="hidden" id="EXPDATE" name="EXPDATE" value="022021">
<input type="hidden" id="CSC" name="CSC" value="123">
</form>
https://pilot-payflowlink.paypal.com simply displays a page with the following:
Error: There was a problem processing your request. If you continue to have an issue, please contact us. Error Code: PL001.

Evernote Thumbnails

I am writing a simple application that lists all the Notes via the Evernote API. I have successfully authenticated and retrieved a list of Notes.
Now I am trying to get Note thumbnails via the Evernote API. I have read their [documentation here][1]. I tried a POST request, but for some reason it's not working. Obviously, I am doing something wrong. Can you please give me a quick, simple, example?
Example Code:
<form method="post" action="https://www.evernote.com/shard/s226/thm/note/64c08998-0bd3-4964-83fd-73a3baaf53cd.jpg?size=40">
<input type="submit" value="View Thumbnail">
</form>
I just set the form method to POST and action to Note Thumbnail. The note thumbnail works when you log in yourself into the Evernote website, but otherwise, it just says access denied. I am new to Evernote API, so I tried the above code just to see if that works or not.
Correct Example Code:
<form method="post" action="https://www.evernote.com/shard/s226/thm/note/64c08998-0bd3-4964-83fd-73a3baaf53cd.jpg?size=40">
<input type="hidden" name="auth" value="{authentication token}">
<input type="submit" value="View Thumbnail">
</form>
You will need to include the authentication token in the request.

Google Checkout callback issue

I am trying to (using a sandbox account) sell items using google checkout. I am displaying a form to the user which results in a buy now button
<form method="POST" action="https://sandbox.google.com/checkout/api/checkout/v2/checkoutForm/Merchant/..." accept-charset="utf-8">
<input type="hidden" name="item_name_1" value="Test"/>
<input type="hidden" name="item_description_1" value="An item "/>
<input type="hidden" name="item_quantity_1" value="1"/>
<input type="hidden" name="item_price_1" value="1.50"/>
<input type="hidden" name="item_currency_1" value="GBP"/>
<input type="hidden" name="_charset_"/>
<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.continue-shopping-url" value="redirect to this url"/>
<input type="image" name="Google Checkout" alt="Fast checkout through Google" src="http://sandbox.google.com/checkout/buttons/checkout.gif?merchant_id=....&w=180&h=46&style=white&variant=text&loc=en_US" height="46" width="180"/>
</form>
On the google seller account i am setting the url to be called back too. In this instance i am using the php file from the google docs example
// Include Google Checkout PHP Client Library
include ("GlobalAPIFunctions.php");
// Include Response Message Processor
include ("ResponseHandlerAPIFunctions.php");
// Retrieve the XML sent in the HTTP POST request to the ResponseHandler
$xml_response = $HTTP_RAW_POST_DATA;
// Get rid of PHP's magical escaping of quotes
if (get_magic_quotes_gpc()) {
$xml_response = stripslashes($xml_response);
}
// Log the XML received in the HTTP POST request
LogMessage($GLOBALS["logfile"], $xml_response);
/*
* Call the ProcessXmlData function, which is defined in
* ResponseHandlerAPIFunctions.php. The ProcessXmlData will route
* the XML data to the function that handles the particular type
* of XML message contained in the POST request.
*/
ProcessXmlData($xml_response);
The issue is, as soon as i buy an item i get no call back whatsoever. No error message, no nothing so how can i see what is going on? Hopefully someone could help me out
Thanks
Check your Sandbox Integration Console for errors (if any) - just making sure that you are referring to your sandbox account (sandbox and production accounts are distinct)
On the google seller account i am setting the url to be called back too
"too" - just making sure. There is only one place where you set the API Callback URL - and that is in your Account Integration Settings (so there is no "too").
<input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.continue-shopping-url" value="redirect to this url"/>
Again, just clarifying that you are not referring to the above as the callback api url. The above is the link presented to a buyer after purchase (it's just a link back to your web site). It is not the callback api url.

How to redirect to paypal with Soap instead of Simple Form

I have my own shopping cart.
When the client click on Submit Order, I Redirect the user to paypal page where the client will be able to pay the order.
Here is my form
<form name="paypalform" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="invoice" value="<? echo $idInvoice; ?>">
<input type="hidden" name="business" value="aa_aaa_biz#hotmail.com">
<input type="hidden" name="notify_url" value="http://domaine.com/catalog/IPNReceip">
<?
$cpt = 1;
foreach($ordering as $k => $v)
{
?>
<input type="hidden" name="item_number_<? echo $cpt?>" value="<? echo$v->Product->id; ?>">
<input type="hidden" name="item_name_<? echo $cpt?>" value="<? echo$v->Product->ProductNumber; ?>">
<input type="hidden" name="quantity_<? echo $cpt?>" value="<? echo $v->Qty; ?>">
<input type="hidden" name="amount_<? echo $cpt?>" value="<? echo $v->Price ?>">
<?
$cpt++;
}
?>
<input type="hidden" name="currency_code" value="CAD">
<input type="hidden" name="tax_cart" value="<? echo $taxes;?>">
<input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
I would like to do the samething but within the code behind.
Somebody have an idea.
I don't want to use form anymore to redirect to paypal.
Thanks
The first thing you'll want to decide is decide which products suits you best.
What you describe, would be easiest to accomplish with Express Checkout.
Express Checkout consists of three API calls: SetExpressCheckout, GetExpressCheckoutDetails and DoExpressCheckoutPayment.
SetExpressCheckout prepares the transaction and returns a token. You must take this token from the API response and append it to a url to which you'll redirect the buyer.
Once the buyer has agreed to the purchase on the PayPal page, he/she is redirected back to the URL you specified in the RETURNURL parameter of the SetExpressCheckout API call.
On this return page, you need to call GetExpressCheckoutDetails or (optionally) look at 'PayerID' in the $_GET array for the return URL.
Once you have the token and the PayerID; either through GetExpressCheckoutDetails or as part of the GET data, call DoExpressCheckoutPayment to finalize the payment. This can be accomplished on the same return page, or can be actioned after the buyer clicks a 'Buy now' button on your return page.
See also the general Express Checkout page on X.com, Getting Started with Express Checkout and the Express Checkout Integration Guide (PDF).
Some sample code for SetExpressCheckout, GetExpressCheckoutDetails and DoExpressCheckoutPayment is available on https://www.x.com/developers/PayPal/documentation-tools/code-sample/78 as well.
Hope this helps! Let me know if anything is unclear.
Robert's answer is a great option - Express Checkout cannot be altered because its server to server and users need your API credentials - but if you want to stick with Website Payments Standard (WPS) see below:
Your concern is that your button can be tampered with. Yes this is possible if the buttons on your website are unhosted/unencrypted buttons. There are tools (like tamper data) that edit HTTP POST's before they are sent to the receiving address, or users can download the HTML form and alter it, then click the button (the referring URL would be different, but could be spoofed); unencrypted buttons are vunerable.
I would advise either using one of the options below to prevent this from occurring in the future:
The button manager API to create dynamic hosted buttons for payments
Create and use hosted buttons
Create and use encrypted website payment buttons

Categories