Paypal SDK and IPN callback not working - paypal

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

Related

Braintree integration for PayPal payments in Flutter

I have to integrate PayPal payments in Flutter and the only plugin that seems to have this kind of functionality is flutter_braintree. But the documentation there is not so detailed, so I am kind of confused how to use this plugin to have real payments. My mission is to have this kind of flow: click on a PayPal button in the app and then proceed with PayPal paying to a predefined IBAN. I tried to examine the PayPal and Braintree documentations, but since there is nothing mentioned for Flutter, I am a little bit confused.
Please help me what's the right direction to go in order to fulfil my requirements. I have the following questions:
How to use this plugin and make real payments? What do I need - a client token as far as I see, but I am going to generate this in Flutter?
Where should I put the IBAN that I want the money to be transferred to?
Am I supposed to use some kind of webviews for the PayPal, or this plugin is enough?
Thank you in advance, I am really stuck on this topic and can't find a solution.
Generate clientToken in php | nodejs see: https://developers.braintreepayments.com/reference/request/client-token/generate/php
$clientToken = $gateway->clientToken()->generate([
"customerId" => '21534539348326'//create customer in panel
]);`
Generate paymentNonce in app flutter:
BraintreePayment braintreePayment = new BraintreePayment();
var data = await braintreePayment.showDropIn(
nonce: clientNonce,
amount: "2.0",
inSandbox: true,
);
print("Response of the payment $data");
// exe: Generate transaction in php | nodejs see: https://github.com/braintree/braintree_php
$result = $gateway->transaction()->sale([
'amount' => '1000.00',
'paymentMethodNonce' => 'nonceFromTheClient',
'options' => [ 'submitForSettlement' => true ]
]);

PayPal SDK: No Server Response when Paying with PayPal Account

I have scoured the docs and this tutorial about 100 times but can't figure out how to go through the payment process using a PayPal account as opposed to a credit card. I have gotten the credit card payment to go through just fine.
In the aforementioned tutorial, it is stated that I am supposed to expect a JSON response from the server after making an OAuth credential:
$sdkConfig = array(
"mode" => "sandbox"
);
$cred = new OAuthTokenCredential("clientID","clientSecret", $sdkConfig);
I get absolutely no server response despite geting a '200 OK' status from the server.
Initially I had my code set up like a bunch of other tutorials:
$apiContext = new ApiContext(
new OAuthTokenCredential(
'clientID', // ClientID
'clientSecret' // ClientSecret
)
);
$payer = new Payer();
$payer->setPaymentMethod('paypal');
$item1 = new Item();
$item1->setName("Donation squares.");
$item1->setCurrency('USD');
$item1->setQuantity(1);
$item1->setPrice(1);
$itemList = new ItemList();
$itemList->setItems(array($item1));
$amountDetails = new Details();
$amountDetails->setSubtotal('7.41');
$amountDetails->setTax('0.03');
$amountDetails->setShipping('0.03');
$amount = new Amount();
$amount->setCurrency('USD');
$amount->setTotal('7.47');
$amount->setDetails($amountDetails);
$transaction = new Transaction();
$transaction->setAmount($amount);
$transaction->setDescription('This is the payment transaction description.');
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl("https://devtools-paypal.com/guide/pay_paypal/php?success=true");
$redirectUrls->setCancelUrl("https://devtools-paypal.com/guide/pay_paypal/php?cancel=true");
$payment = new Payment();
$payment->setIntent('sale');
$payment->setPayer($payer);
$payment->setRedirectUrls($redirectUrls);
$payment->setTransactions(array($transaction));
try{
$payment->create($apiContext);
} catch(Exception $e){
echo $e
exit(1);
}
None of this works either - no response from the server whatsoever.
ANSWER / COMMENT
You're not supposed to be looking for a JSON response after all. If the payment is successfully created, an approval URL should be generated by running
$payment->getApprovalLink();
The user then follows this link to finalize his/her payment.
You might be interested in following a very simple instruction here at PayPal-PHP-SDK, that explains how to make calls using PayPal PHP SDK. I know you have already gone through that, and are looking for how to create a payment using PayPal.
I am not sure you are aware of this, but PayPal-PHP-SDK comes along with a lot of samples, that you could run by just one simple command (if you have PHP 5.4 or higher). One of the first sample have the instructions and code to make PayPal Call.
There are two steps involved in that.
Create a Payment. Receive a approval_url link to be used to ask the user to complete Paypal flow over any browser.
Once the user accepts the payment on paypal website, it will be redirected back to your website, where you execute the payment.
Both the code samples are provided here and here.
Let me know if this helps, and you have any more questions. I would be more than happy to help.

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 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.