Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

PHP 

Paypal auto-purchase example using the paypal IPN

Deleted not usefull. Deleted not usefull. Deleted not usefull.

[warn]
From a functional standpoint I strongly discourage using this library. There are many better systems already built. Reinventing the wheel for an extremely simple PayPal IPN that doesn't even support payment management (token -> API), etc.
Furthermore, I don't see any easy flexibility with your library, which could be a huge point for using it.

Here's the recommendation:
  • If you're going to release a library for an API, don't "hardcode" the results. An "event" closure based system should work much better,
    for the release, your system is based on providing easy-to-use automatic product payment, and management; a whole register/login system isn't required.
Good luck in the future though, good start overall.

Here's an example usage of a library I've made in the past:
PHP Code

<?php 
    
/**
     * Manage PayPal IPN requests.
     *
     * @return \Illuminate\Http\Response 
     */
    
public function ipn(Request $request) {
        
$IPN = new PayPalIPN();
        
$listener = &$IPN->setListener(file_get_contents('php://input'));

        
$listener->onVerified(function (Event $event) {
            
//Request has been verified by PayPal.
            
$data = $event->getData();
        });

        
$listener->onInvalid(function (Event $event) {
            
//Request was invalid or forged.
        
});

        
//Trigger verification.
        
$verified = $IPN->verify();

        return 
response('', 200);
    } 

Edit: looking through some more of the code I'd like to add that your styling is horrible; learn the language.
(Sep 14, 2017 03:18 PM)Ceanko Wrote:  From a functional standpoint I strongly discourage using this library. There are many better systems already built. Reinventing the wheel for an extremely simple PayPal IPN that doesn't even support payment management (token -> API), etc.
Furthermore, I don't see any easy flexibility with your library, which could be a huge point for using it.

Here's the recommendation:
  • If you're going to release a library for an API, don't "hardcode" the results. An "event" closure based system should work much better,
    for the release, your system is based on providing easy-to-use automatic product payment, and management; a whole register/login system isn't required.
Good luck in the future though, good start overall.

Here's an example usage of a library I've made in the past:
PHP Code

<?php 
    
/**
     * Manage PayPal IPN requests.
     *
     * @return \Illuminate\Http\Response 
     */
    
public function ipn(Request $request) {
        
$IPN = new PayPalIPN();
        
$listener = &$IPN->setListener(file_get_contents('php://input'));

        
$listener->onVerified(function (Event $event) {
            
//Request has been verified by PayPal.
            
$data = $event->getData();
        });

        
$listener->onInvalid(function (Event $event) {
            
//Request was invalid or forged.
        
});

        
//Trigger verification.
        
$verified = $IPN->verify();

        return 
response('', 200);
    } 

Edit: looking through some more of the code I'd like to add that your styling is horrible; learn the language.

No I won't release anything. It's a simple example which was coded in an hour to show people a example since it was posted often here lately.
Why don't you use the proper paypal lib to create payments instead of doing what you're doing with the html buttons. Also you're not checking if the payment value is even correct in the IPN. People can edit the price with f12 and pay 1 cents and still receive the product.
Do not edit out the content of your threads.

Warned and post suspended for a week.
Staff member 10th Jan 2017 - 30th May 2020.
HF Administrator 30th May 2020 - 14th July 2022.

It was a blast being on staff. I stepped down as it's time for me to move on. I wish you all the best and if you were hit by my warnings and/or bans, it was nothing personal.

Peace out!


Possibly Related Threads...
Thread / Author Replies Views Last Post
[PHP] by citsejaMFeb 4, 2020 02:58 PM 6 286 Feb 4, 2020 02:58 PM
Last Post: citsejaM
[PHP] by тнe randoм dυтcн gυyJul 5, 2017 01:24 PM 3 779 Jul 5, 2017 01:24 PM
Last Post: тнe randoм dυтcн gυy
[PHP] by Rolex™Feb 27, 2017 10:49 AM 7 250 Feb 27, 2017 10:49 AM
Last Post: Rolex™