Question

I am trying to figure out how to receive the SecureToken to be used in a Payflow Link IFrame using the PayPal Payflow Gateway SDK. I am also using Paypal's Layout C so that the user enters their credit card information in the PayPal IFrame while it is embedded in my site (thus preventing my site from ever having CC information).

The code to generate the HTML for the IFrame would ideally look something like this:

iframeHTML = "<iframe src='https://payflowlink.paypal.com?SECURETOKEN="
    + secureToken + "&SECURETOKENID=" + secureTokenID + "&MODE=" + mode
    + "' width='490' height='565' border='0' frameborder='0' scrolling='no'"
    + " allowtransparency='true'>\n</iframe>";

I have read the Developer Guide and have been unable to find what object I can do this with. I have tried creating various transactions, but they all require a tender (full credit card info) to be sent, as well. I have also looked at the questions PayPal's Payflow Gateway SDK Example not working and How to get secure token when using "Hosted Checkout Pages" and RestApiSDK - ASP.Net but was not able to find the answer I wanted.

Is there some object or function I am missing? I would prefer not to use a Name-Value Collection and manually create the request and response to retreive the SecureToken but will if it is the only way.

Was it helpful?

Solution

After digging around more, I eventually found an object in the SDK called "ExtendData" and was able to add instances of those to my transaction in order to get the needed token. It appends that information to the request string, so you can use ExtendData for anything you would create a name/value pair for that isn't already specified in the SDK.

var edCreateSecureToken = new ExtendData("CREATESECURETOKEN", "Y");
var edSecureTokenID = new ExtendData("SECURETOKENID", strRequestID);

var transaction = new SaleTransaction(payPalUser, payflowConnection, invoice, null, strRequestID);
transaction.AddToExtendData(edCreateSecureToken);
transaction.AddToExtendData(edSecureTokenID);

Response response = transaction.SubmitTransaction();

string token = string.Empty;
if (response != null && response.TransactionResponse != null && response.TransactionResponse.Result == 0)
{
    token = (from ExtendData test in response.ExtendDataList
             where test.ParamName == "SECURETOKEN"
             select test.ParamValue).FirstOrDefault();
}

paypalContent.InnerHtml = "<iframe src='https://payflowlink.paypal.com?SECURETOKEN=" + token + "&SECURETOKENID=" +
              strRequestID + "&MODE=" + Config.PayflowMode +
              "' width='490' height='565' border='0' frameborder='0' scrolling='no' allowtransparency='true'>\n</iframe>";

This seems to work correctly (Layout C shows embedded in my page with no errors) and allows me to avoid specifying a tender.

OTHER TIPS

Here is some sample code that comes directly from the PayPal Developer site it will help you create a Secure Token ID:

curl https://pilot-payflowpro.paypal.com -kd
"PARTNER=PayPal&
VENDOR=MyMerchantID&
USER=UserID&
PWD=UserPassword&
TRXTYPE=S&
AMT=40&
CREATESECURETOKEN=Y&
SECURETOKENID=12528208de1413abc3d60c86cb15"

Here is the information on setting up the Hosted Checkout Pages: Hosted Checkout Pages

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top