Sandbox paypal- lightbox does not load - paypal

Beginning Wednesday, March 27th, we encountered a problem testing PAY transactions in the Sandbox Adaptive Payment (Classic API) environment. Our last successful test was on Tuesday March 26th. We made no code or environment changes that would have affected our sandbox test transactions during that timeframe.
The problem we are experiencing is that the PayPal lightbox will not load after our application contacts the sandbox Adaptive Payment environment. At the point we try to invoke the lightbox, we have obtained a paykey. You can see the URL we are contacting, and a paykey value, in the screenshots of the error consoles in Firefox and Chrome attached.
The browser error console shows "404 – not found" error when we send a request to PayPal with a paykey. There are no other javascript errors on the page other than those generated by the request to Paypal. Is the "404 – not found" error related to the PayKey value we got back from the sandbox on the initial request? If so, why are the Paykeys suddenly not valid, when they were fine before?
The App ID we are using for the Adaptive Payment sandbox is: APP-80W284485P519543T Is this the correct App ID for the "new" sandbox environment?
We are using the UserID, password and signature from a verified US Business account set up in the Classic API sandbox.
<form id="lightbox_form" action="https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay" target="PPDGFrame">
<input id="type" type="hidden" name="expType" value="lightbox">
<input id="type" name="autoredirectondone" type="hidden">
<input type="hidden" name="paykey" id="paykey" value="[paykey is inserted here]">
<input name="submit_order" id="submit_order" type="submit" class="common_input_button" value="Submit Order">
</form>
<script type="text/javascript" src="https://www.paypalobjects.com/js/external/dg.js">
</script>
<script>
var dgFlow = new PAYPAL.apps.DGFlow({ trigger: 'submit_order' });
</script>

Your form action is pointing to an old URL.
The new URL for sandbox Adaptive Payments is:
https://svcs.sandbox.paypal.com/AdaptivePayments/Pay
See: https://developer.paypal.com/webapps/developer/docs/classic/adaptive-payments/gs_AdaptivePayments/

Related

Recurly Paypal normal workflow

I'm searching for example of implementation for Recurlyjs normal Paypal checkout flow. I suppose to request Billing info from the user besides Paypal token but it's not clear how do I merge them together to use.
Here are docs mentioning normal workflow but no details: https://docs.recurly.com/docs/paypal-payments
Here is example of Paypal express flow:
https://github.com/recurly/recurly-js-examples/blob/master/public/paypal/index.html . It looks like I need to add [additional-fields] to the form and merge_token_fields, but I can not find appropriate function.
<section>
<form method="post" action="/api/subscriptions/new">
<button id="subscribe">Subscribe with PayPal</button>
<div name="recurly-[additional-fields]></div> // TODO: fix this
<input type="hidden" id="recurly-token" name="recurly-token">
</form>
<script>
var form = $('form');
recurly.configure('PUBLIC_KEY');
var paypal = recurly.PayPal({
display: { displayName: 'My product' }
});
paypal.on('token', function (token) {
$('#recurly-token').val(token.id);
merge_token_fields(); // TODO: fix this
form[0].submit();
});
form.on('submit', function (event) {
event.preventDefault();
paypal.start();
});
</script>
</section>
The steps you'd want to follow:
1) Get Paypal token
2) Collect billing address (can be done on the recurly.js form and passed to the API)
3) From API, pass the Paypal billing agreement to the account
4) A subsequent request to pass billing address to account as a billing info update

PayPal Adaptive Payments: two payments from one sender in two browser tabs

I use PayPal Adaptive Payments (parallel) on my website and I've encountered a strange problem with two payments in two different browser tabs from the same sender. The similar question was asked before, but nobody answered there.
The scenario which reproduces the problem
The user opens the first browser tab of the website and starts a payment process to the first seller.
PayPal's lightbox with Login button appears.
The user opens the second browser tab of the website and starts a payment process to the second seller.
Again, PyaPal's lightbox with Login button appears.
The user returns to the first browser tab and login to PayPal.
After login to PayPal in the first browser tab the user sees payment details to the second seller.
After login to PayPal in the second browser tab the user sees payment details to the second seller.
It seems that PayPal Adaptive Payments support only one transaction from one sender.
How it works
The website works with Ruby on Rails and I use paypal_adaptive gem for payments with PayPal. The payment flow is quite simple:
The user clicks on Buy button on the website. The client makes AJAX request which handled by payment controller in Ruby on Rails.
In the controller the app makes Pay request to PayPal API using paypal_adaptive gem and receives a PayKey (see the code below).
The server responds to the client with the PayKey and the client uses it in PayPal form to start payment process through PayPal's lightbox (see the code below).
That's it. After that I do not control anything (the payment process goes through PayPal's external webpage).
Additional notes
I'm sure that the data for Pay request is different on the server side in the test scenario listed above.
I've tried different PayPal's dialog options besides PayPal's lightbox: mini-browser and popup. These options doesn't affect on this bug and it is still reproducable.
The client code
<script src="https://www.paypalobjects.com/js/external/dg.js" type="text/javascript"></script>
<form action="https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay" class="paypal-hidden-form" target="PPDGFrame">
<button id="paypal-submit"></button>
<input id="type" type="hidden" name="expType" value="light">
<!-- Insert PayKey here and click on the form's submit button using jQuery after server's response. -->
<input id="paypal-key" type="hidden" name="paykey" value="">
</form>
<!-- Paypal -->
<script type="text/javascript" charset="utf-8">
var dgFlow = new PAYPAL.apps.DGFlow({ trigger: "paypal-submit", expType: "light" });
function MyEmbeddedFlow(embeddedFlow) {
this.embeddedPPObj = embeddedFlow;
this.paymentSuccess = function(paymentStatus) {
this.embeddedPPObj.closeFlow();
// More UI code here...
};
this.paymentCanceled = function() {
this.embeddedPPObj.closeFlow();
// More UI code here...
};
}
var myEmbeddedPaymentFlow = new MyEmbeddedFlow(dgFlow);
</script>
The server code
# Make a Pay request to PayPal API.
paypal_payment_thread = Thread.new do
# Some preparation code goes here...
pay_request = PaypalAdaptive::Request.new
process_guid = SecureRandom.uuid
# Construct Pay API request data.
data = {
:returnUrl => "#{PAYPAL_RETURN_URL}?process_guid=#{process_guid}",
:cancelUrl => "#{PAYPAL_CANCEL_URL}?process_guid=#{process_guid}",
:requestEnvelope => {
:errorLanguage => "en_US"
},
:currencyCode => "USD",
:receiverList => {
:receiver => [{
# seller_paypal value is different for two payments.
# But in fact we do the last payment for both payments.
:email => seller_paypal,
:amount => ORDER_SELLER_AMOUNT,
:paymentType => "DIGITALGOODS"
}, {
:email => PAYPAL_MARKETPLACE_EMAIL,
:amount => ORDER_MARKETPLACE_AMOUNT,
:paymentType => "DIGITALGOODS"
}]
},
:actionType => "PAY",
:ipnNotificationUrl => PAYPAL_NOTIFY_URL,
:reverseAllParallelPaymentsOnError => "true",
:trackingId => process_guid
}
# Make a Pay API request.
pay_response = pay_request.pay(data)
if pay_response.success?
# Everything is ok. Update database here...
else
raise Exceptions::PaypalPaymentError
end
end
I've removed some unimportant code just to be clear, how it really works.
Thanks in advance for the help!
Looks like it is by design. I've tried the same test here on the website of one of PayPal's employees and it is reproducible there.
PayPal's support answered me that the problem in using Lightbox. However I've tried Mini-Browser and Popup options as I described in my post without no effect.
Also, PayPal's support answered me that this is by design and adviced me to contact with Technical Support. Maybe it will be useful for someone else.
Hi Michael, Thanks, yes I was able to reproduce it as well. However
it’s important to understand that PayPal is not made for handling 2
payment flows at the same time. If you want to get further on that,
you can contact our Technical Support : https://ppmts.custhelp.com/
They have other tools to debug and may be able to give you a better
understanding of the technical problem.
Finally I've blocked simultaneous payments using a special flag in HTML5 Local Storage and dgFlow.isOpen() method of PAYPAL.apps.DGFlow object to detect PayPal window. On window close I reset this flag using onunload and onbeforeunload events of window.
I close this question. Thanks.

Paypal form return value

I'm fighting against Paypal.
I'm trying to use 'return' variable but for some reason it did not work.
The documentation says:
return
The URL to which PayPal redirects buyers' browser after they complete their payments. For example, specify a URL on your site that displays a "Thank you for your payment" page.
Default – PayPal redirects the browser to a PayPal webpage.
rm
Return method. The FORM METHOD used to send data to the URL specified by the return variable.
Allowable values are:
0 – all shopping cart payments use the GET method
1 – the buyer's browser is redirected to the return URL by using the GET method, but no payment variables are included
2 – the buyer's browser is redirected to the return URL by using the POST method, and all payment variables are included
So I decide add to my form:
<input type="hidden" name="return" value="http://www.site.com/payment_confirm.php" />
<input type="hidden" name="cancel_return" value="http://www.site.com/back" />
<input type="hidden" name="rm" value="2" />
But for some reason at the end of the payment nothing happens.
So I try to search on google why this could be and some people wrote to active the automatic redirect to a page at the end of transaction from profile.
So I went in the profile page and setted up the auto return to
www.site.com/
When I tryed again after the transaction paypal return me in the profile url and not in the url written in the form AND there are some data in the URL so the form hasn't use the POST method.
My ideas is over.
How can I solve this problem?

PayPal Standard not giving option for Check out as Guest

MVC 3 VB.NET applicaiton... Using express checkout with html razor view. I have tried everything mentioned in all of the docs i could google for as well as the ones on paypal's dev network. Our Paypal account is setup to allow users to Check out as Guest without requiring paypal account creation or login. However when users are taken to the paypal site after clicking the checkout button there is no option to check out as guest. I am including my checkout view for reference. Please understand that this is a valid question and do not down vote it. If there is something not clear I will clarify it..
#modeltype xxxxxxx.orderVM
#Code
ViewData("Title") = "CheckOut"
End Code
<p style="text-align:center">Once you complete your transaction you will be redirected back to the site</p>
<p></p>
<p style="text-align:center">We will process your payment within 24 hours at which time you will recieve a confirmation email which you will need for addmission. Along with a PDF attachment in this email which is your parking permit.. Please print and follow the instructions</p>
<p></p>
<p></p>
<p></p>
<p></p>
<p style="text-align: center"> Please Click on the paypal button below to be redirected to the PayPal Site to complete the payment Transaction</p>
<form id="PayPal" name="PayPal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
#Html.Hidden("cmd", "_cart")
#Html.Hidden("upload", "1")
#Html.Hidden("business", ConfigurationManager.AppSettings("PayPalMerchantEmail"))
#Html.Hidden("page_style","primary")
#Html.Hidden("custom", Model.id.ToString)
#Html.Hidden("image_url", "http://www.xxxxxxxxxx.com/content/images/xxxxxxxxLogo.jpg")
#Html.Hidden("cpp_header_image", "http://www.xxxxxxxx.com/content/images/xxxxxxxLogo.jpg")
#Html.Hidden("cpp_logo_image", "http://www.xxxxxxxxxxe.com/content/images/xxxxxxxLogo.jpg")
#Html.Hidden("return", "http://www.xxxxxxxxxx.com/")
#Html.Hidden("cancel_return", "http://www.xxxxxxxxxx.com")
#Html.Hidden("first_name", Model.first_name)
#Html.Hidden("last_name", Model.last_name)
#Html.Hidden("address1", Model.address1)
#Html.Hidden("address2", Model.address2)
#Html.Hidden("city", Model.city)
#Html.Hidden("state", Model.state)
#Html.Hidden("zip", Model.zip)
#If Not String.IsNullOrEmpty(Model.Class1) Then
#Html.Hidden("item_name_1", Model.Class1)
#Html.Hidden("amount_1", Model.fee1)
#Html.Hidden("quantity_1", ViewBag.quan)
#Html.Hidden("shipping_1", " 0.00 ")
#Html.Hidden("handling_1", " 0.00 ")
End If
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" align="middle" style="text-align:center"/>
</form>
I do not feel the code for the controller is required here since it does pass all the values correctly into the view... The only issue is I can not get check out as guest working...
Have you turned on 'Account Optional' in your PayPal Profile?
Which country is your account located in? The guest checkout functionality is not available in all countries yet.

Paypal payment buttons and IPN: how to link users up uniquely?

Strangely the documentation on the Paypal site does not cover this very well.
We have a payment button that redirects to Paypal to process a payment.
We also have an IPN server running that catches paypal payments once they're made.
However, where can we place the "user id" of our system user in the paypal button, so that it will be forwarded to the IPN request in order to match the user up on our system that they have paid. Paypal seems to want people to do this manually, which is a real mission.
I'm currently doing some PayPal integration and I concur their documentation is a mess!
I finally found a guide somewhere that details which variables of a PayPal button form are forwarded to the IPN callback. You can use the variable item_name to forward a user id:
<input type="hidden" name="item_name" value="{user id}">
You should use:
<input type="hidden" name="item_number" value="{user id}">
and here is the documentation:
https://www.paypalobjects.com/IntegrationCenter/ic_std-variable-ref-buy-now.html
As said in the doc (https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNandPDTVariables/)
in your form :
<input type="hidden" name="custom" value="<?php echo $id ?>">
and get it with ipn :
$_POST['custom']
For anyone trying to get this working for Paypal SmartButtons, you should do something like this:
return actions.order.create({
purchase_units: [{
invoice_id: 'your_custom_stuff1',
custom_id: 'your_custom_stuff2',
amount: {
value: '100'
}
}]
});
IPN will sent it as POST data, for example in PHP:
$_POST['invoice']; // 'your_custom_stuff1'
$_POST['custom']; // 'your_custom_stuff2'