PayPal Chained payments failing - paypal

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;
}

Related

PayPal Web Payments Pro Hosted - Credit Card payment confirmation page

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.

Paypal SDK and IPN callback not working

I'm developing an affiliate script with the Paypal Adaptive Payments SDK. I have the following code:
$payRequest = new PayRequest(new RequestEnvelope("en_US"), 'PAY',$arrPaypal ['paypal_return'] , 'USD', $receiverList, $arrPaypal['paypal_return']);
$payRequest->IpnNotificationUrl = $arrPaypal['paypal_callback'];
$payRequest->memo = 'Payment for ' . $arrUserInfo['plan_title'];
$payRequest->trackingId = $intID;
However it is not firing the callback script. The url is my http:// ipaddress /script.php. If I set it in the paypal sandbox I get a hit but it's not an adaptive payments response as detailed in the sdk. Could someone please explain how to enable it?
You may have gotten the case of the IPN setter wrong. Try ipnNotificationUrl instead of IpnNotificationUrl

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 Sandbox suddenly outputting proxy error for adaptive payments

Edit: For some reason it's working again. I did not need to log in to developer.paypal.com either. If anyone knows why, that would be useful. Thanks!
For the past few months I have been developing a site using PayPal's adaptive payments, specifically the chained payments method. I am using the embedded payment method from a site that uses SSL. The integration had been working perfectly for months until a day or two ago. It was even still working right after I imported my old sandbox accounts to the new developer.paypal.com sandbox.
After submitting the payment from the site's form, the browser spins for a minute or two. The error generated after a few minutes is the following:
The proxy server could not handle the request GET
/webapps/adaptivepayment/flow/corepay Reason: Error during SSL
Handshake with remote server
$API_UserName = "us business account from developer.paypal.com sandbox";
$API_Password = "password from developer.paypal.com sandbox";
$API_Signature = "singature from developer.paypal.com sandbox";
// AppID is preset for sandbox use
// If your application goes live, you will be assigned a value for the live environment by PayPal as part of the live onboarding process
$API_AppID = "APP-80W284485P519543T";
$API_Endpoint = "";
if ($Env == "sandbox")
{
$API_Endpoint = "https://svcs.sandbox.paypal.com/AdaptivePayments";
}
else
{
$API_Endpoint = "https://svcs.paypal.com/AdaptivePayments";
}
If I am not mistaken, I believe the error is being generated when the redirect happens from this function here:
function RedirectToPayPal ( $cmd )
{
// Redirect to paypal.com here
global $Env;
$payPalURL = "";
if ($Env == "sandbox")
{
$payPalURL = 'https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay?expType='.$_POST['expType'].$cmd;
}
else
{
$payPalURL = "https://www.paypal.com/webscr?" . $cmd;
}
header("Location: ".$payPalURL);
exit;
}
Edit: I changed the $payPalURL to "https://developer.paypal.com..." as suggested and got the following:
Service Temporarily Unavailable
The server is temporarily unable to service your request due to
maintenance downtime or capacity problems. Please try again later.
After the recent code change this flow now requires you to log in to https://developer.paypal.com first. I am checking to see if this was intentional or is a code bug.
There appears to have been an issue with the sandbox.paypal.com server that disabled adaptive payments for a couple days. Everything seems to be functioning as it had been previously. Thank you to Dennis for his input.
Edit:
This appears to be ongoing and intermittent

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.