PayPal Web Payments Pro Hosted - Credit Card payment confirmation page - paypal

I've implemented Website Payments Pro Hosted on my website. I can pay using the PayPal log in and it gives me the link to return to my store which is fine as I then display my order confirmation page to the user.
When the user decides to pay via credit card:
They are then redirected to a confirmation page I don't seem to have any control over:
What I've tried:
Setting auto return on in my preferences and setting a return url (both via the Profile and in my initial API call when generating the button.
Changing the Web Payments Pro confirmation page setting to On my sites confirmation page.
When the payment is taken via credit card, I'd like to redirect the user to my actual payment confirmation page. Is this possible?

It turns out that showHostedThankyouPage=true was causing this issue.
I am using the .NET button API to generate the request for the iFrame like so:
var service = new PayPalAPIInterfaceServiceService(GetConfig(request));
var createButtonResponse = service.BMCreateButton(new BMCreateButtonReq
{
BMCreateButtonRequest = new BMCreateButtonRequestType
{
ButtonType = ButtonTypeType.PAYMENT,
ButtonCode = ButtonCodeType.TOKEN,
ButtonCountry = countryCodeType,
ButtonVar = new List<string>
{
String.Format("subtotal={0}", _salesOrderPriceService.GetGrossTotal(request.Order)),
String.Format("notify_url={0}", request.NotifyUrl),
String.Format("return={0}", request.ReturnUrl),
String.Format("invoice={0}", request.Order.Id),
String.Format("currency_code={0}", request.Order.Currency.Code),
String.Format("cancel_return={0}", request.CancelReturnUrl),
"billing_first_name=test",
"billing_last_name=tset",
"billing_address1=test",
"billing_city=test",
"billing_state=tes",
"billing_zip=test",
"billing_country=GB",
"template=templateD",
"paymentaction=sale",
"business=tset"
}
}
});
I had showHostedThankyouPage=true included in the name value pairs which was causing the issue. Removing it sorted it out.

Related

How to get secure token when using "Hosted Checkout Pages" and RestApiSDK - ASP.Net

Is it possible to use the RestApiSDK to get a secure token when using "Hosted Checkout Pages"? If so please show example. (C# preferred.)
The secure token I am referring to is described on page 31 here:
https://www.paypalobjects.com/webstatic/en_US/developer/docs/pdf/payflowgateway_guide.pdf
Please realize that I am not using "Express Checkout". (There is a lot of confusion between the old PayPal products and the new products in the PayPal documentation.)
One example I found here on StackOverflow has the following issues:
The links to the SDK and docs are dead.
The DOSecureTokenAuth.cs file does not exist in any SDK or example that I can find.
PayPal's Payflow Gateway SDK Example not working
In this example the author was not able to copy the code from the source files.
http://forums.asp.net/t/1798900.aspx/1
Thank you,
Chuck
https://github.com/paypal/rest-api-sdk-dotnet please look into this
or you can use
payflow_dotnet.dll
Please look into this code of payflow_dotnet.dll
public void CreateAuthorization()
{
// Create the Payflow Connection data object with the required connection details.
// The PAYFLOW_HOST property is defined in the webconfig
PayflowConnectionData Connection = new PayflowConnectionData();
// Create Invoice
Invoice Inv = new Invoice();
// Set Amount
Currency Amt = new Currency(new decimal(premiumAmount), "USD");
//adding the amount to invoice
Inv.Amt = Amt;
//creating a new express check out request
ExpressCheckoutRequest currRequest = new ECSetRequest(WebConfigkeys.ReturnToApplication, WebConfigkeys.ReturnToApplication);
PayPalTender currTender = new PayPalTender(currRequest);
//creating a new transaction
SaleTransaction currTransaction = new SaleTransaction(User, Connection, Inv, currTender, PayflowUtility.RequestId);
//submitting the transaction and accepting the response message
Response Resp = currTransaction.SubmitTransaction();
if (Resp != null)
{
TransactionResponse TrxnResponse = Resp.TransactionResponse;
ExpressCheckoutResponse eResponse = Resp.ExpressCheckoutSetResponse;
if ((TrxnResponse != null) && (eResponse != null))
{
eResponse.Token;//get your token
}
}
}
Add this to Web Config
<add key="PAYFLOW_HOST" value="pilot-payflowpro.paypal.com" />
It is not currentlypossible. The REST API's do not support the Hosted Checkout payment method. The REST process allows for PayPal transactions (very similar to Express Checkout) and credit card payments (where you pass the billing information to PayPal for verification).
The post you mentioned - PayPal's Payflow Gateway SDK Example not working - is for the Payflow SDK and Payflow does not support REST.

PayPal Chained payments failing

I'm trying to get PayPal's chained payments working in their sandbox env. but whenever I click on "Pay" at the very last stage after signing in I always get redirected to a page with the generic error message "Your payment can't be completed. Please return to the participating website and try again."
I've tried doing both chained and parallel payments with the same results.
I've also followed a few suggestions from around the web which inc tweaking the merchant account settings making sure certain fields were unchecked under the "blocked" options. As well checking currency and country code. Initially country code was en_GB and currency GBP, that didn't work I tried doing en_US with USD but in all cases I get the same message.
I've also tried adding an IPN url on the off chance PayPal would post some error code/message to it but got nadda! If you click "Return to test store" it goes to the cancel URL without any POST/GET parameters.
I'm using their PHP SDK from http://paypal.github.io/#adaptive-payments-tab-php-5-3
So the question, does anyone have any suggestion as to how I can find out what exactly is going wrong or other things I can try to fix it?
I had this problem in the sandbox environment because I was not including an application ID. I used APP-80W284485P519543T which one of examples indicated as the Sandbox Application ID, and then it worked.
Mobile Payments Library Developer Guide and Reference
–
Android OS
Edition
Oct 2016
5
Preface
**Important:
The Mobile Payments Library is based on the PayPal Adaptive Payments API.
As of October 6, 2016, Adaptive Payments is now a limited releas
e product. It is restricted to
select partners for approved use cases and should not be used for new integrations without guidance from PayPal**
=============================================
first implement method
private void initLibrary() {
PayPal pp = PayPal.getInstance();
if(pp == null) {
pp = PayPal.initWithAppID(this, PAYPAL_APP_ID, PayPal.ENV_SANDBOX);
pp.setLanguage("en_US"); // Sets the language for the library.
pp.setFeesPayer(PayPal.FEEPAYER_EACHRECEIVER);
// pp.setShippingEnabled(true);
pp.setDynamicAmountCalculationEnabled(false);
}
}
**paypal button click event code**
double secondary_payment = 0;
double primary_payment = 0;
PayPalAdvancedPayment advPayment = makeChainedPayment(secondary_payment,primary_payment,"primary_email","secondary_email");
Intent checkoutIntent = PayPal.getInstance().checkout(advPayment, your_current_activity);
startActivityForResult(checkoutIntent, 1);
=============================================
private PayPalAdvancedPayment makeChainedPayment(double priceSecondary, double pricePrimary, String primary_email, String secondary_email) {
PayPalAdvancedPayment payment = new PayPalAdvancedPayment();
payment.setCurrencyType("USD");
// payment.setMerchantName("PushND");
BigDecimal bigDecimalPrimary=new BigDecimal(pricePrimary);
PayPalReceiverDetails receiverPrimary = new PayPalReceiverDetails();
receiverPrimary.setRecipient(primary_email);
//receiverPrimary.setRecipient("adaptive_receiver_1#pushnd.com");
receiverPrimary.setSubtotal(bigDecimalPrimary);
receiverPrimary.setIsPrimary(true);
payment.getReceivers().add(receiverPrimary);
PayPalReceiverDetails receiverSecondary= new PayPalReceiverDetails();
receiverSecondary.setRecipient(secondary_email);
BigDecimal bigDecimalSecond=new BigDecimal(priceSecondary);
receiverSecondary.setSubtotal(bigDecimalSecond);
payment.getReceivers().add(receiverSecondary);
return payment;
}

Paypal Adaptive payment for mobile web

Im integrating Paypal Adaptive Payment API for a mobile website.
But when Im submitting payment to
https://www.paypal.com/webscr?cmd=_ap-payment&paykey=value
( For Sandbox : https://www.sandbox.paypal.com/cgi-bin/webscr )
Its always redirecting to Paypal Main Web. Not to Paypal Mobile website.
How to redirect client to paypal mobile web?
Try redirecting your site to
https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay?paykey=AP-XYZ&expType=mini
Fill your pay key in place of AP-XYZ
Let me know if it works.
The best approach I found was mini browser experience. But I had a variety of different issues on mobile devices implementing it (which is what it was meant for in the first place). You will see many similar questions about adaptive payments and all sorts of issues with using lightbox and mini browser experience.
But FINALLY... I have figured it out after hours upon hours, days upon days! This should solve everyone's problems of all different varieties when it comes to issues with PayPal Adaptive Payments and the issues with:
The default redirected paypal page is NOT mobile responsive and looks horrible on mobile devices.
The lightbox gets "hung up" and does not close on some mobile devices.
The mini browser doesn't close after completing payment or cancelling.
The mini browser doesn't redirect to the callBackFunction from paypal apdg.js script.
Not redirecting to returnUrl and cancelUrl after payment completion (or when cancelling)
Chrome for ios (iphones) doesn't initiate the callbackfunction and therefore after payment completion or cancellation, it just keeps you at the page you launched the paypal payment page from which prevents you from validating success or failure of payment.
Drum roll please.... here it is!! This replaces any need for PayPal javascript files etc. All you need is what is below along with your own method of obtaining the PayKey to add to the redirect url. My live website, with adaptive payments working correctly using below code, is https://www.trackabill.com.
<div>
<?php $payUrl = 'https://www.paypal.com/webapps/adaptivepayment/flow/pay?expType=mini&paykey=' . $payKey ?>
<button onclick="loadPayPalPage('<?php echo $payUrl; ?>')" title="Pay online with PayPal">PayPal</button>
</div>
<script>
function loadPayPalPage(paypalURL)
{
var ua = navigator.userAgent;
var pollingInterval = 0;
var win;
// mobile device
if (ua.match(/iPhone|iPod|Android|Blackberry.*WebKit/i)) {
//VERY IMPORTANT - You must use '_blank' and NOT name the window if you want it to work with chrome ios on iphone
//See this bug report from google explaining the issue: https://code.google.com/p/chromium/issues/detail?id=136610
win = window.open(paypalURL,'_blank');
pollingInterval = setInterval(function() {
if (win && win.closed) {
clearInterval(pollingInterval);
returnFromPayPal();
}
} , 1000);
}
else
{
//Desktop device
var width = 400,
height = 550,
left,
top;
if (window.outerWidth) {
left = Math.round((window.outerWidth - width) / 2) + window.screenX;
top = Math.round((window.outerHeight - height) / 2) + window.screenY;
} else if (window.screen.width) {
left = Math.round((window.screen.width - width) / 2);
top = Math.round((window.screen.height - height) / 2);
}
//VERY IMPORTANT - You must use '_blank' and NOT name the window if you want it to work with chrome ios on iphone
//See this bug report from google explaining the issue: https://code.google.com/p/chromium/issues/detail?id=136610
win = window.open(paypalURL,'_blank','top=' + top + ', left=' + left + ', width=' + width + ', height=' + height + ', location=0, status=0, toolbar=0, menubar=0, resizable=0, scrollbars=1');
pollingInterval = setInterval(function() {
if (win && win.closed) {
clearInterval(pollingInterval);
returnFromPayPal();
}
} , 1000);
}
}
var returnFromPayPal = function()
{
location.replace("www.yourdomain.com/paypalStatusCheck.php");
// Here you would need to pass on the payKey to your server side handle (use session variable) to call the PaymentDetails API to make sure Payment has been successful
// based on the payment status- redirect to your success or cancel/failed page
}
</script>
There is actually a simple solution to this that isn't documented anywhere. We were in discussion with PayPal about adding it a while back so I am wondering if it eventually got implemented.
Anyway, simply just redirect the user to the following URL and they will be redirected back to your site on completion:
https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/preapproval?preapprovalKey=PA-XXXXX&expType=redirect
The difference here is using expType=redirect rather that expType=mini. I'm not sure when this was added but after a bit of reverse engineering and some experimenting we have a surprisingly simple solution.
that's right - the Adaptive Payments UI is not Mobile optimized. But the closest to that it offers is what we call the MiniBrowser experience. You can try and see if that serves your needs. You can find the how-to guide here on X.com: Implementing the Mini-Browser Option

Paypal Digital Goods with no floating box but redirect to paypal site

I'm using Paypal Digital Goods, it is good until now. When user click on button, it open a floating box with paypal iframe.
The problem is I don't want using floating box anymore. I stop using paypal javascript. After call a request to paypal
$nvps["METHOD"] = "SetExpressCheckout";
$nvps["RETURNURL"] = $this->configs['return_url'];
$nvps["CANCELURL"] = $this->configs['cancel_url'];
$nvps["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
$nvps["PAYMENTREQUEST_0_NOTIFYURL"] = $this->configs['listener_url'];
$nvps["PAYMENTREQUEST_0_AMT"] = $item['price'];
$nvps["PAYMENTREQUEST_0_CURRENCYCODE"] = $item['currency'];
$nvps["PAYMENTREQUEST_0_ITEMAMT"] = $item['price'];
$nvps["L_PAYMENTREQUEST_0_NAME0"] = $item['desc'];
$nvps["L_PAYMENTREQUEST_0_NUMBER0"] = $item_number;
$nvps["L_PAYMENTREQUEST_0_AMT0"] = $item['price'];
$nvps["L_PAYMENTREQUEST_0_QTY0"] = "1";
$nvps["L_PAYMENTREQUEST_0_ITEMCATEGORY0"] = "Digital";
I redirect to "https://www.sandbox.paypal.com/incontext?token=" with a token from request above. The style of page is still like a floating box. If user click on login button, it still open a mini browser (popup) and I don't want like this. Any suggestion?
Simply stop loading the dg.js fil and change the PayPal redirection URL from https://www.paypal.com/incontext?token= to https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=
This will make it the regular Express Checkout checkout experience.
I suspect you are still including the Paypal dg.js file. Remove the following line from your page and the Paypal iFrame will no longer appear.
<script src='https://www.paypalobjects.com/js/external/dg.js' type='text/javascript'></script>

Does PayPal include payment integration options that do not require showing PayPal to the user?

We are looking to replace our usage of Authorize.net. I've spent a good deal of time looking into the PayPal documentation but can't find a clear answer to my question:
Using the thousands tens of different PayPal APIs is it possible to have a checkout process that is hosted on our site, where we capture and process the credit card information from the customer without the customer ever leaving our site and without the customer ever having to see anything PayPal related (so PayPal is 100% invisible).
I'm confused by this PayPal documentation page:
"Please note: Direct Payment API is not a stand-alone product. You are required to use Direct Payment API and Express Checkout together as part of the Website Payments Pro solution." as Express Checkout requires you to show PayPal logos, etc.
And this page makes it pretty clear that you have to offer the branded Express checkout option to use the Direct Payments API.
I guess I'm just looking for confirmation that there are people on SO that use PayPal in this way and have not had problems keeping PayPal 100% invisible to the customer?
Yes you can.. We use PayPal on our website,PerqWorks and only allow payment by credit card. The PayPal product is Website Payments Pro. I did the integration, it was fairly easy, and the cost is low if your sales are under $10K a month..
EDIT:: I need to clarify this -- we received an exception from PayPal to allow us to not have the PayPal button on our site. I missed this information because someone else in my office actually made this arrangement. My advice is that you ask your PayPal Integration Account person, that is who made the exception for us..
The only way I know of to fully integrate and take the PayPal branding out of the process is to use their Payflow Pro gateway service. I've used it before and it's pretty similar to dealing with any other payment gateway (such as Authorize.net).
However, this is entirely up to you but I've found that there are still some people who prefer to use their PayPal account. They might be afraid of the potential lack of security on small-ish or unknown e-commerce sites. Or perhaps they're ordering from another country, in which case a PayPal account offers abundant funding options and automatic currency conversion. So it's nice to at least offer the option of a PayPal Standard Checkout process, or something similar.
I can't give you a definite no, but I'm fairly certain PayPal wouldn't allow it. They depend on revenue that comes from using a buyer's PayPal balance or bank account to pay for something and charging the merchant a percentage. The merchant's percentage doesn't do much more than cover the credit card issuer's charge.
Short of entering the users PayPal credentials on your site, it wouldn't be possible for them to use a funding source other than credit cards. The issue with that is that it would create a huge vulnerability to phishing attacks to have users become accustomed to entering their PayPal login information on a non-PayPal site.
You're basically talking about a standard credit card merchant account at that point.
You can definitely use Paypal as a stand alone credit card processing. The paypal account has to be set up for paypal pro.
You can download the API DLLs from the paypal dev site.
paypal_base.dll
log4net.dll
Here is an example function on how to use it for VB.NET but you can convert to C# relatively easily:
Imports com.paypal.sdk.services
Imports com.paypal.soap.api
Imports com.paypal.sdk.profiles
Private Function processCC() As Boolean
Dim caller As New CallerServices
Dim profile As IAPIProfile = ProfileFactory.createSignatureAPIProfile
profile.APIUsername = AppSettings("APIUsername")
profile.APIPassword = AppSettings("APIPassword")
profile.APISignature = AppSettings("APISignature")
profile.Environment = AppSettings("Environment")
caller.APIProfile = profile
Dim pp_Request As New DoDirectPaymentRequestType
pp_Request.Version = "51.0"
pp_Request.DoDirectPaymentRequestDetails = New DoDirectPaymentRequestDetailsType
pp_Request.DoDirectPaymentRequestDetails.IPAddress = Request.ServerVariables("REMOTE_ADDR")
pp_Request.DoDirectPaymentRequestDetails.MerchantSessionId = Session.SessionID
pp_Request.DoDirectPaymentRequestDetails.PaymentAction = PaymentActionCodeType.Sale
pp_Request.DoDirectPaymentRequestDetails.CreditCard = New CreditCardDetailsType
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardNumber = Request("ccNumber")
Select Case Request("ccType")
Case "visa"
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardType = CreditCardTypeType.Visa
Case "mastercard"
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardType = CreditCardTypeType.MasterCard
Case "amex"
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardType = CreditCardTypeType.Amex
Case "discover"
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardType = CreditCardTypeType.Discover
End Select
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CVV2 = Request("CVV2")
pp_Request.DoDirectPaymentRequestDetails.CreditCard.ExpMonth = Request("expMonth")
pp_Request.DoDirectPaymentRequestDetails.CreditCard.ExpMonthSpecified = True
pp_Request.DoDirectPaymentRequestDetails.CreditCard.ExpYear = Request("expYear")
pp_Request.DoDirectPaymentRequestDetails.CreditCard.ExpYearSpecified = True
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner = New PayerInfoType
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Payer = Request("email")
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerID = ""
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerStatus = PayPalUserStatusCodeType.unverified
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerCountry = CountryCodeType.US
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address = New AddressType()
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.Street1 = Request("address1")
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.Street2 = Request("address2")
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.CityName = Request("city")
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.StateOrProvince = Request("state")
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.PostalCode = Request("zipcode")
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.CountryName = "USA"
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.Country = CountryCodeType.US
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.Address.CountrySpecified = True
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerName = New PersonNameType()
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerName.FirstName = Request("firstname")
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CardOwner.PayerName.LastName = Request("lastname")
pp_Request.DoDirectPaymentRequestDetails.PaymentDetails = New PaymentDetailsType()
pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.OrderTotal = New BasicAmountType()
pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.OrderTotal.currencyID = CurrencyCodeType.USD
Dim myOrder As Order = CType(Session("currentOrder"), Order)
pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.OrderTotal.Value = FormatNumber(myOrder.grandTotal, 2)
'pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.ShippingTotal = New BasicAmountType()
'pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.ShippingTotal.currencyID = CurrencyCodeType.USD
'pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.ShippingTotal.Value = FormatNumber(myOrder.orderShippingTotal, 2)
pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.ItemTotal = New BasicAmountType()
pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.ItemTotal.currencyID = CurrencyCodeType.USD
pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.ItemTotal.Value = FormatNumber(myOrder.orderSubTotal, 2)
'// Execute the API operation and obtain the response.
Dim pp_response As New DoDirectPaymentResponseType()
pp_response = CType(caller.Call("DoDirectPayment", pp_Request), DoDirectPaymentResponseType)
Session("myResponse") = pp_response
Dim rtn As Boolean = False
Select Case pp_response.Ack
Case AckCodeType.Failure
rtn = False
Case AckCodeType.FailureWithWarning
rtn = False
Case AckCodeType.Success
Return True
Case AckCodeType.SuccessWithWarning
rtn = True
Case AckCodeType.Warning
rtn = False
End Select
Return rtn
End Function
At one time I used Paypal Pro for this very purpose. In looking at your link, it does seem they require you to use both paypal checkout and regular checkout.
However, you can still achieve your purpose. What happens is that they can checkout and not know anything about it going through paypal OR they can click the paypal button and leave your web site. After payment, you can set up the 'thank you' return page back to your site.
Other than that, you'd have to get them to approve an exception.
I can't tell you about the API of Paypal, but I have something burning inside me, reading your topic.
For me as a user it is highly ugly to just see a form of a random site that claims for my payment data. Having a hint on where my data is actually going is by far more better, but really positive it is only, if the site sends me to paypal, where I can let my payment data, inform me about paypal, verify that I'm sending my data to paypal, etc.
It a sort of security you take from your customers if you do it all behind the scenes - even if you write to them, that their payment data is only handled by paypal, there's no transparent way for them to check that.
I'd take the chance to make a poll under your customers for that, what they would prefer, before implementing something obscure.