Introduction
Hello I'm going to sell a software using serial keys. Any person can go into my webpage and click on the paypal button to buy a serial key, they don't need to register.
What I'm trying to achieve
I need to let any person use the button and receive a serial key when the payment is done.
So the workflow would be something like:
Any person (non-registered) clicks on the button.
The paypal page shows up.
The user pays and gets redirected to a page that shows something like "Congratulations, here is your serial key: {{serialKey}}" and also receives the same serialKey via email.
What I tried
I'm trying to use Paypal's Smart Checkout but I don't understand how to implement what I need.
Right now I'm able to:
Render the button.
The button performs a request to my back to get the price (so the user can't change it and trick me).
The paypal page shows up.
On success it performs a request to my back.
On failure it restarts.
What I'm missing:
How can I check that the payment did actually succeed on the back, I mean that I received the money? Is there any way that I can post to paypal using the ID and see if I that transaction was correct?
Additional question
Is this the right approach? All I need is to let anyone click the button, pay and receive a serial key ONLY if the payment was correct. Right now it seems too complex for what I need. I don't understand everything I see on the paypal docs, if you follow it line by line the examples don't work, you have to adapt a lot of the code and I'm not sure about what I'm doing.
I also read IPN's docs but using it I won't be able to redirect the user because everything would be done in the back without the user even knowing what is happening.
Final text
Any help is appreciated. I'm asking here because I saw a lot of another questions about paypal like this one that were upvoted.
The most robust approach is to combine the PayPal Checkout front-end with a v2/orders backend for payment setup and capture.
create order
capture order
This way the capture happens from your server, so you have an immediate success/failure API response -- and can immediately do whatever you need to do to handle the business logic of the digital good purchase (serial key activation/distribution)
Once you have everything working well for the happy path, don't neglect to handle funding source failures, so that if the capture fails due to e.g. the buyer's first card being declined, this is propagated back to the UI and the buyer can select a different funding source.
Context: I work at a small MSP and I've created a bot that direct messages employees when one of their tickets goes overdue. The message has a few buttons that allow the user to request an extension on the ticket. Once a button is clicked, our ticketing system's API is used to update the ticket and the chat message updates to reflect the selected update.
What I'd like to do after one of the request extension buttons is clicked is to ask the user if they would like to add a note to the ticket. If Yes button is clicked, the bot would prompt the user to respond with a note to add.
Here's my question. Is there any way to read the next message from the user after they click yes? As in, should the user click 'Yes' to add a note, can I trigger a script to run when the next user message is posted?
For what it's worth, I'm writing this in PHP. I'm using chat.postMessage to post the message when a ticket goes overdue, and simply "replacing" the message with a new one using that message's responseURL when a button is clicked.
Any Slack API gurus out there with any ideas?
Well.. if I understand your problem correctly, there is a much easier approach:
The buttons automatically call your script and tell you what the user clicked. So you can respond appropriately. Its all part of the Interactive Message feature in the Slack api. And you can configure which url Slack should call in the Slack App config window. Check out the offical documentation for Interactive Buttons more info.
However, I guess what you really want is the ability for the user to enter some free text, like in a html form input field. That is currently not possible in Slack, but that very feature is promised on the current Slack API roadmap to be delivered in the near future. Its called "Interactive message Stage 3".
I've created a system based on cron job which generates new tasks for user. When new task is generated cron file sends a sms to user using twilio sms api. Now I want make something like when user reply to that sms with word "Done" that task associated with sms will be completed in my database.
I've set reply URL in twilio account. And everything is working fine. My point is how can I complete that task in database. Is there any feature exist in twilio that can help me to send extra parameter as task id, so that I can fetch that id from reply and update the status of task.
Twilio developer evangelist here.
There's no way in SMS to reply to a specific message (try it yourself in your SMS app on your phone), so there's no ID that you can pass around secretly within conversations.
There are a few ways you can work around this.
If the user is sent only one task at a time, then you can record what their current task is and when you receive the message saying "done" tick that one off and send them the next task.
You could send them a task ID within the message, and tell them to include that ID when they respond to say they are done. You could then parse the ID out of the message and mark it as done in your database.
Or, and this might be too far, you could use a pool of numbers to send tasks out such that each live task for a user has a unique number the user responds to. Then you can look up the task based on the user and the number they replied to. Then you can free up the number for a new task.
Let me know if this helps at all.
I'm working on a PHP website where when user selects city and submits the form, it will get the users phone numbers from the database for that particular city and sends SMS to them.
I have used cURL functions within a while loop to execute this and it is working fine.
NOTE: My sms gateway provider's API only support one number at a time per http request.
Now my question is if the number of user in the selected city is more than 10000 or 50000, then using cURL method will take much time to execute since it's in the loop? But the user wont like wait for the completion of loop. Is there any better way than doing this, like when user submits the request, something in backend (like job) will execute the function and even if the user closes the page, that job will execute till it completes the loop.
my solution was this:
--page /sendsms/?phone_nr=1122 sends one sms to phone nr 1122
--page /sendbulk has a loop which calls in php the page /sendsms/?phone_nr=1122 with file function file('http://www.domain.com//sendsms/?phone_nr=' . $phone_nr[$i]);
--the client on submit will call with ajax(no return needed) the page /sendbulk
This way even if the client closes the connection the server will continue to run /sendbulk in background and will send all messages
You can store detail of sms and city in another table, than set one Cron that take the all Number from the basis of City detail and Send To Sms Gateway , set that row as sent..
So,
I run a rental car company, and I want to integrate my service into a third party website - where people will be able to rent cars directly on the third party website. How can I integrate my service on the third party website efficiently? I am thinking that an iframe might be the best way or some sort of javascript call ... but I need the best way to integrate my service so that the third party site has to do less coding as possible.
I want people to check a box on the third party website if they want to rent a car and then a form pops up asking the customer for their payment details, then that information gets sent to my site, and my site processes that information and confirms the payment.
So basically, I was envisioning,
Person clicks a checkbox on third party site
Third party site sends information about the person to my site
I use that information to send back a payment box with price details
Person submits payment information on third party site
My site gets the payment information and processes the information
My site sends back status response to third party site.
The problem is, if the customer is a repeat customer, I would like the third party site to send me identifying information about the customer that will allow me to discern that she is a repeat- and thus charge her without her having to put her credit card details in the payment box.
In cases like this, its a lot more affordable, and sometimes more efficient to build a white label version of your product thats hosted on the same service as your primary product. This way all the functionality is essentially the same, except your slapping someone else's name on it and saying its powered by your company somewhere.
One key reason I suggest this is site to site transactions leave a lot of moving parts that can be tripped up through malicious means.
Take paypal for example, when ever you pay by paypal, what happens? You click the paypal button on the third party site, and it redirects you to the paypal site itself. You can do similar, you tell your 3rd party to submit a form like they would on any other site, and that posted data what little there will be as you want it all confirmable on your side so it leaves the door a little more closed to prevent someone from just changing the price or something. Anyway you take that posted data run it through your filters, compare it to whatever offers your allowing your 3rd party to do, and then process it all on your side. then when all is complete, you turn around and redirect back to there site and a thank you page.
Just food for thought
If you are going to implement a security so a hacker can't bog down your database with false orders use a shared secret key with which you encrypt the posted data to a hash, and then compare it on your side.
For example
$data = "color=blue|type=mazda|days=3|clientID=john#doe.com|etc=somedata";
$secretkey = "213098snxlkds_ljlsk3545";
$hash = hash('sha256',$data.$secretkey);
echo '<form target="someiframe" target="http://www.domain.com/bla/die/bla">
<input type="hidden" value="'.$data.'" name="data">
<input type="hidden" value="'.$hash.'" name="hash">
<input type="submit" value="Order the car Now!">';
Then at your side where you recieve the data you use this code
$secretkey = "213098snxlkds_ljlsk3545";
if(hash('sha256',$_POST['data'].$secretkey) === $_POST['hash'])
{
$process = explode('|',$_POST['data']);
foreach($process as $piece)
{
$vars = explode('=',$piece);
$Data[$vars[0]] = $vars[1];
}
}
This way if only you and your retailer have the hash, you can always verify that the retailer is legit and not some cheapchate trying to bog you down.
Having your service on third party sites means those sites are going to have to communicate with your app/site. On top of that, you want the users to be able to pay on the third party sites too, so you will be sending sensitive data back and forth. For that reason, I suggest you first get/integrate SSL.
Once you have that, you need to setup your own API. I know it probably sounds like a huge task, but it's actually not if you don't require much data and validation (returning loads of error codes and stuff).
So a quick example:
Let's say I have a website that people can login/register to. But I want users to be able to register to my site, on a third party site (like you want users to purchase goods from yours).
What I do here, is:
Create a basic script that will listen for any requests that third party sites will call. We shall call this one api.php:
//so we listen for POST params to be sent. These params will have users details stored in them
//so first check if all required params were sent:
if ( !isset($_POST['firstName']) || !isset($_POST['lastName']) || !isset($_POST['email']) )
{
exit();//because some/all of the required data is missing, we're going to stop right here xD
}//end of required data missing
//so if we get to this point, we know that the correct params have arrived
//so now you can do your registration stuff
//validate data (check if email is correct, if its been used before, ect ect)
//throw the data in the DB
//and if you need to, return some JSON status code
echo json_encode(array('status'=>'OK'));
That right there is an API. Very basic but still an API. So now you just tell the third party sites to post their info to "https://yousite.com/api.php" and it will return a status code, and the registration is completed.
I know that's not a very good example, but I hope you have managed to get the point.
Actually, most websites do this anyway. Even without the use of third party sites. When users register to a website, their data gets posted to some page. So I guess you could just POST data to your original signup/purchase/login page..
There are many different ways that you could approach this, but I think the simplest might be to have a simple JavaScript API that the third-party integrator can use on their website. Your JavaScript can set up the checkbox (for instance, attached to a div or form that the integrator specifies) and rig it so that when the user checks the box it opens a popup pointed at your site. You can then process your transaction from within the `popup.
This would be fairly comparable to how a basic Paypal integration works, where a user throws a Paypal button onto their site, and then when the button is clicked it opens a new window that points directly to Paypal's site (because as a general rule they cannot collect/accept payment or identity information directly from the third-party website) and passes a handful of parameters describing the transaction (payment amount, recipient, item details, etc.).
So for instance, a third-party might integrate with your service by first including your JavaScript file, like:
<script type="text/javascript" src="http://carmonkey.com/api/v1/MonkeyCar.js" />
...and then they might add some boilerplate code to hook up the API to the desired portion of their site:
<script type="text/javascript">
var options = {"container": "#someDivId", "userFirstName": "John",
"userLastName": "Smith", "rentalDate":"8/8/12", "duration":"7"};
MonkeyCar.drive(options);
</script>
Then your script needs to take those options and use them to add your checkbox to the target container element, and to configure the checkbox so that when the user click it a popup window opens to the appropriate URL on your website. So you might add something like:
<input type="checkbox" name="_monkeyCar" value="true"
onchange="if (this.checked) {MonkeyCar.open('http://carmonkey.com/reserve?fname=John&lname=smith&...');}" />
Book a Rental Car
Then once that happens the user can complete their rental car booking as normal, since the popup is just running a normal browser session with your standard website.
If you wanted to get fancy you could also add-in a feedback loop so that the JavaScript API running on the third-party page can get updates about the transaction status and detect when a transaction completes/is canceled and update the hosting page with the status.