Implementing digital goods express checkout without javascript - javascript

Is it possible to implement express checkout for digital goods without having to use javascript? I want my website not to depend on clients having javascript enabled and can live with customers being redirected to PayPal's pages to authorize payment. Can I simply redirect the user to https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout &token=APIToken instead of https://www.paypal.com/incontext?token=APIToken after the call to setexpresscheckout if I mark the transaction as a digital goods one (noshipping=1, etc.)?

The answer to your question is: yes.
Don't change anything about your initial API call
Like you mentioned, after you get your API token from paypal redirect the user to: https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=APIToken
If you are transitioning from js, remember to remove the paypal script tag and the code that converts your link into a popup:
new PAYPAL.apps.DGFlow({ trigger: "link_id" })

Related

Need PayPal PDT Sample Code in Client JavaScript

I'm new to PayPal and its PDT. I've searched through many posts but they require Node.js or PHP to implement it. I don't have both, but I just want a simple return from PayPal PDT, telling my download.html that the purchase was successful so that I can safely display the product key to my customers and allow them to download my digital product, otherwise I will do something like this in my JavaScript:
If (purchaseFailed) {
window.location.replace('/404.html');
}
The reason that I do that is to prevent direct access to my download.html and reveal the product key without making a payment through PayPal.
I've enabled my PayPal PDT and specified the return URL, but I just do not know how to write the JavaScript to get the return the status from PayPal. I do not need to display any transaction detail to my customers except a 'thank you' message, the product key, and the download link (but if you can show some sample on getting the transaction details, e.g. product code and customer email address, that would help too). Can somebody help me with some simple JavaScript that my Google Blogger HTML can execute it? Thanks a lot!
PDT is completely unreliable, because returns are never guaranteed to happen, due to browser/network crashes or the customer not waiting for the auto-return (there is a timer) or not clicking through to return (typically guests w/o an account must be shown a receipt and click to return). So PDT is suitable for informational purposes only (e.g. showing buyers a thank you message when they do return.).
Absolutely no business logic such as downloads should depend on a PDT return actually occurring.
Instead, if you need a dependable notification from PayPal of payment completion, an asynchronous IPN or one of the newer webhooks should be listened for -- or alternatively, the integration should be changed to a more robust synchronous server-side one such as this pattern: https://developer.paypal.com/demo/checkout/#/pattern/server , where there is always an immediate API response on payment capture for notification purposes.
Blogger's HTML/JS does not provide any of the necessary listening or API capabilities, of course.

stripe checkout client only integration in reactjs . how to handle the callback urls . how to subscribe for recurring payments?

I am trying to integrate stripe check out (client only integration) in my reactjs application and i see there's lots of confusion about this which are listed below
(i) : first thing is "react-stripe-checkout" , a react library to implement checkout. i could not find any example of how to pass the plan Id to this "react-stripe-checkout" . As in client only integration you create the plans on stripe dashboard and pass the plan id to checkout , but there is no example of how to pass my plan id to "react-stripe-checkout". For example without using this library this is how i use the stripe.js directly in my react app
const stripe = window.Stripe('pk_test_my tst key');
stripe.redirectToCheckout({
clientReferenceId:"abc",
items: [
{plan: 'my-plan-id', quantity: 1}
],
successUrl: '',
cancelUrl: '',
}).then((result) => {
console.log(result)
});
in above code i am passing my plan id to stripe's "redirectToCheckout" method and it redirects me to a new form hosted by stripe and customer can subscribe for the plan there. but how do we accomplish this functionality using "react-stripe-checkout".
(ii) I assume that "react-stripe-checkout" can't be used for client only integration and it just can be used for client server integration , i need a confirmation on that . moreover like "react-stripe-checkout" pops up the form for collecting user card information on the same page whereas stripe.redirectToCheckout() takes the user to a new page to enter his card info. is there a way to collect the user card info on same page in a popup like we do with "react-stripe-checkout".
(iii) Assuming that "react-stripe-checkout can't be used for client only integration" . I have decided to use stripe.redirectToCheckout() anyways. I have already posted the code above and i am confused about how to use callback urls there. I have not seen a single example all over the internet anywhere for handling these callback urls in reactjs. i wonder if anybody has implemented the client only checkout integration in reactjs until now , if so why isn't there any example available to follow.
(iv) I am following the stripe documentation for implementing webhooks on my backend (Nodejs) server.
this is the link https://stripe.com/docs/payments/checkout/fulfillment#webhooks . and there's this line there
"If Stripe does not receive successful acknowledgement after 10 seconds have passed from a successful payment, your customer will be automatically redirected to the success_url page."
what does it mean ? how do i be sure about inside "success_url page" that customer has successfully subscribed to the plan or not ?
(v) from stripe documentation i also do not understand this following line
"If you’d like to access the Checkout Session ID you can add the {CHECKOUT_SESSION_ID} template variable to the success_url (e.g. success_url=https://example.com/success?session_id={CHECKOUT_SESSION_ID}). When your customer is redirected on successful payment, the success_url will contain the Checkout Session ID in place of the {CHECKOUT_SESSION_ID} template variable."
can anyone explain what this {CHECKOUT_SESSION_ID} template variable is for , and what would i pass in it from my frontend ?
kindly help .

PayPal pre-approved payment button

I'm trying to implement the paypal pre-approve functionality (obtained through the Adaptive Payment API) in our crowdfundig platform. At the click of the paypal pay buton button my back-end generates the pre-approve key and SHOULD redirect the user to the appropriate PayPal link:
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_ap-preapproval&preapprovalkey=GENERATED_PRE_APPROVE_KEY
I am currently using the classic checkout button (checkout.js) which does not seem configurable to be redirected to another type of PayPal address (it just redirect to the standard payment url and not the pre-approve). What should I do? Create a custom button? Or can I change the behavior of a classic PayPal button?
I will answer to my own question. After the generation of the pre-approval key, what I did was redirecting the user from the current page to a new one to this link :
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_ap-preapproval&preapprovalkey=GENERATED_PRE_APPROVE_KEY
In order to redirect the user to a new window I used the standard :
window.open(linkWithPreApprovalKey);
It seems that ther's no specific pre-approval or adaptive payment button made by PayPal (such as checkout.js for a normal checkout)

Twitter JS API, update status

I'm at a total loss here. I believe I'm right in thinking there is no longer any JS API for twitter which just sucks hugely.
However I realise looking at this I could just use ajax and react to the responses from this:
https://dev.twitter.com/rest/reference/post/statuses/update
OAuth Signature Generator
Example Request POST
https://api.twitter.com/1.1/statuses/update.json?status=Maybe%20he%27ll%20finally%20find%20his%20keys.%20%23peterfalk
However when I post to that url I get the following:
{"errors":[{"code":215,"message":"Bad Authentication data."}]}
Bad Authentication data -> this is very self explanatory: Your Authentication is Bad; in other word, you are not authorized to use that API method.
Since you use POST method, make sure you set your APP access level to Read & Write.
Sign in to apps.twitter.com, and in the Applications Management page for your app, click the Permissions tab. There you can change your access level.
For further reading, please see this answer.

Is it possible to use an existing Facebook Connect session with Facebooker?

Update: Working as designed once I cleared my cookies. Doh!
I'm working on an app that for various reasons uses the Facebook
Javascript API to initiate a Facebook connect session. I'd like to be
able to use that session in a few rails methods using Facebooker.
The basic workflow is like this:
User goes to non-rails page and logs in to FB Connect via JS
User goes to another non-rails page and can view FB data such as
name, profile pic
User goes to a rails based page - rails uses session created in
step 1 to do some processing
My problem is in step 3. Facebooker detects the session fine, but when
I try to call a method like facebook_session.user.name I get: Session
key invalid or no longer valid
If I go back to the url in step two, my session still works fine.
So is this a fundamental incompatibility, or is there some data I can
send to facebooker so that I can hook into the correct session? Maybe
my facebooker.yml needs tweaking?
Any thoughts are appreciated.
My facebooker.yml
development:
api_key: redacted
secret_key: redacted
canvas_page_name: blah_blah
callback_url: http://test.domain:3000
pretty_errors: true
set_asset_host_to_callback_url: true
tunnel:
public_host_username:
public_host:
public_port: 4007
local_port: 3000
server_alive_interval: 0
Gah! Always clear your cookies before posting on the interweb people.
The problem was with an existing facebooker-based session that was still around in my browser.
All working now.

Categories

Resources