Jump to content

PayPal Integration UDF


Recommended Posts

I needed to integrate Paypal "Buy Now" buttons into my applications, in order to give my customer opportunity to directly purchase them without sending them to a merchant website.

So, and thanks to @mistersquirrle and @TheXman I developed a .au3 that includes most important API calls to Paypal in order to 

  • Request Token 
  • Create a "buy now" direct link 
  • Monitor order until processed and payed
  • Capture money and release funds to own PayPal account

Surely this .au3 could be improved but it can be a good starting point to integrate PayPal in your own applications.

I'm including also json.au3  and BinaryCall.au3 needed to decode Json data.

How it works:

Example.au3, included, gives you an overview of functionality.

Basically you need: 

  1. To Identify yourself with Paypal and receive a Token to use on further calls
    $sToken = _PayPalGetToken($sURL, $EndPoint_GetToken, $ClientId, $SecretId)
  2. To create a Pay Now link, containing details on your product (name, price, currency) and landing pages after payment is complete or canceled (you can also avoid these pages but it will show a bad 404 error to customer after he finished the purchase or cancel it)
    $aReturn = _PaypalCreateOrder($sURL, $sToken, $EndPoint_Orders, $Currency, $Price, $product, "en-US", $URL_Complete, $URL_Cancel)

    $aReturn returns a link to shellexecute() in order to bring customer to paying page

    This is an example of product
    Global $Currency = "EUR"
    Global $Price = "0.5"
    Global $product = "Test Product"
    Global $URL_Complete = "https://example.com/complete.php"
    Global $URL_Cancel = "https://example.com/cancel.php"

  3. To wait customer to pay. This is achieved by polling Paypal every 10 seconds for 5 minutes (or until "Abort" is pressed") to verify if customer payed
    $sOrderStatus = _PaypalOrderDetails($sToken, $EndPoint_Orders, $sOrderId)

  4. To free on-hold payment and release it to your Paypal account
    $FinalAnswer = _PaypalOrderCapture($sURL, $sToken, $EndPoint_Orders, $sOrderId, $ReqId)

Then you will have money in your wallet and decide what else to do (personally I grant access to customer after payment).

Feel free to integrate, update, comment it, it's a pleasure to share with the community.





BinaryCall.au3 Example.au3 JSON.au3 PayPal.au3

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...