Reputation: 121
I am using nodejs and expressjs and using "paypal-ec" node package to do incontext paypal integration. This is invoked with the following piece of code:
<script src='https://www.paypalobjects.com/js/external/dg.js' type='text/javascript'></script>
<script>
var dg = new PAYPAL.apps.DGFlow(
{
trigger: 'paypal_submit',
expType: 'instant'
});
</script>
What I have achieved with this I am able to make payment in the Paypal Sandbox environment but it shows me older payment screen where in user needs to fill in the details of address etc (I am not able to attach screenshot because of credits)
What I want to achieve I am trying to make payment with the screens where in user doesn't need to prefill any data also it gives better UI. Some experience like provided in this plukr link http://plnkr.co/edit/3vfNSVRyq86pDR5mH4HH?p=preview The problem with the given piece of code in plunk is that it doesn't expose what is there in the action method and how can I provide amount to it (or any other details if any).
Any kind of help is appreciated.
Upvotes: 0
Views: 241
Reputation: 12371
I get it but don't claim to be a node
dev - yet :) so this is "conceptual":
At the end of the day, the server-side call (SetExpressCheckout
) where you send your trnx details (items, price, return/cancel urls, etc.) to Paypal and obtain a token
is unchanged (with the documented limitations and ignored params that is).
The change is in the front-end where:
<script async src="//www.paypalobjects.com/api/checkout.js"></script>
https://www.paypal.com/checkoutnow?token=[the token you obtained]
are in play
The linked sample's server-side SetExpressCheckout
process is the:
http://166.78.8.98/cgi-bin/aries.cgi?sandbox=1&direct=1&returnurl=http://166.78.8.98/cgi-bin/return.htm&cancelurl=http://166.78.8.98/cgi-bin/cancel.htm
You can see the returnurl
and cancelurl
set (but it could have been done server side as well). This will obtain the token
which is needed for the subsequent steps.
If you can inspect the traffic, you'll see the response where the redirect
(that is "caught" in the front end and displayed "in-context"):
HTTP/1.1 302 Found
Date: Sun, 05 Jul 2015 16:00:48 GMT
Server: Apache/2.4.7 (Ubuntu)
Access-Control-Allow-Origin: *
Location: https://www.sandbox.paypal.com/checkoutnow?useraction=commit&token=EC-94X58918K2362702E&ul=0
This sample is probably more detailed and "less magical" (shows more of what's going on) and is what helped me implement:
http://plnkr.co/edit/UhNka4VaaRRGY1TK32LE?p=preview
Hth.
Upvotes: 2