Raised This Month: $128 Target: $400
 32% 

[INC] PayPal


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Upplands Väsby, Sweden
Old 09-21-2013 , 23:18   [INC] PayPal
Reply With Quote #1

PayPal
Enables transactions through MOTD.

I am not responsible for errors or failed transactions!
Use this at your own risk.


Credits:
xPaw for SourceQuery.
bboygrun for the tutorial on how to use SourceQuery.
Exolent[jNr] for the stock str_explode() that I stole from his String Stocks library.

Requirements:
* A PayPal account that has the following enabled under "Website Payment Preferences":
- Auto Return.
- Payment Data Transfer.
- An Identity Token, found on the same page after PDT is enabled.

* SourceQuery.
- Place the files from SourceQuery in a folder named "SourceQuery".
- Place that folder in the same folder as the PHP file.

* HTTP2 v2.21(or higher) for payment verification.

* A webserver to host the PayPal.php.

How it works:
As promised, I will explain.

You start a session using PayPal_Start().
This will format the PayPal link and open a MOTD that will redirect the user to the PayPal link.

When the user completes the payment he/she will be redirected to the PayPal.php that you host and specified earlier.
The .php utilizes SourceQuery to execute a command on your server, passing the Transaction ID to the server.

The server receives the command and verify the payment using HTTP2.
HTTP2 will pass the Transaction ID and the Identity Token as POST variables directly to a PayPal verification link. This prevents tampering.
This will result in a text-based page that gives specifics about the payment and if it was successful.
HTTP2 will download that like any file and then the PayPal.inc will parse the information calling the PayPal_Complete() forward on success.

If a user leaves the server before the process is completed the SteamID will be saved in a que file, so when the person reconnects PayPal_Complete() will be called.

Once a transaction is verified it will blacklist that Transaction ID in a file so people won't be able to receive whatever "benefits" by refreshing the page over and over.

If the transaction fails or gets aborted nothing will be called.

Functions:
Code:
/* To customize your PayPal session further, a full list of GET variables can be found here: <a href="https://developer.paypal.com/webapps/developer/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/#id08A6HI0709B" target="_blank" rel="nofollow noopener">https://developer.paypal.com/webapps...#id08A6HI0709B</a> */ #define TRANSACTION_FILENAME "PayPalTransactions.dat" #define QUE_FILENAME "PayPalQue.dat" /* PayPal_setAccount(const Account[]) * Defines your PayPal Account to receive the payment. */ stock PayPal_setAccount(const Account[]) /* PayPal_setIdentityToken(const IDToken[]) * * Defines PayPal Identity Token which is used to verify the payment. * * More information can be found here: * <a href="https://developer.paypal.com/webapps/developer/docs/classic/paypal-payments-standard/integration-guide/paymentdatatransfer/" target="_blank" rel="nofollow noopener">https://developer.paypal.com/webapps...tdatatransfer/</a> */ stock PayPal_setIdentityToken(const IDToken[]) /* PayPal_setReturnURL(const ReturnURL[]) * * Defines the URL to PayPal.php. * * (Optional. If not set the default in PayPal account will be used.) */ stock PayPal_setReturnURL(const ReturnURL[]) /* PayPal_setCurrency(const Currency[]) * * 3-digit currency code. * * (Optional. If not set USD will be assumed.) * * A list of valid currencies can be found here: * <a href="https://developer.paypal.com/webapps/developer/docs/classic/api/currency_codes/" target="_blank" rel="nofollow noopener">https://developer.paypal.com/webapps...urrency_codes/</a> */ stock PayPal_setCurrency(const Currency[]) /* PayPal_setLogo(const Logo[]) * * Link to a logo image to display at top-left corner instead of your account name. * Max: 150x50px according to PayPal, does however fit larger images without problems. * In the example picture the 350x100 is cut off at the bottom. * * (Optional.) */ stock PayPal_setLogo(const Logo[]) /* PayPal_setHTMLBody(const HTMLBody[]) * * What to display in the _PayPal_MOTD while loading the PayPal website. * More or less just to clear the server _PayPal_MOTD. * * (Optional. If not set a general "Loading..." will be used.) */ stock PayPal_setHTMLBody(const HTMLBody[]) /* PayPal_Start(id, const ItemName[], const ItemNumber[], Float:Amount = 0.0) * * Formats and displays a MOTD with PayPal. * * id is the person to show the MOTD to. * * ItemName[] and ItemNumber[] could be used however you want. Both are visible on payment screen. * I suggest using ItemName as an actual name to display to the person paying. For example "1 month of VIP". * ItemNumber should be used like any article number. This way you'll be able to keep track which payment has reached the forward. * * Amount is of course the amount of money in previously selected currency that you want to charge. * If left at 0, the user can input any number him-/herself. It will also open the "donation" design instead of the "pay" design. */ stock bool:PayPal_Start(id, const ItemName[], const ItemNumber[], Float:Amount = 0.0) /* PayPal_Complete(id, ItemName[], ItemNumber[], Float:Amount, Currency[]) * * This forward will be called when the payment is done and verified. * Keep in mind that floats in PAWN are not 100% accurate. So compare the Amount with a margin of error. */ forward PayPal_Complete(id, ItemName[], ItemNumber[], Float:Amount, Currency[]);

Examples:
Code:
#include <amxmodx> #include <PayPal> public plugin_init() {     register_plugin("PayPalExample", "1.0", "[ --{[email protected] ]");         PayPal_setAccount("MyPayPalAccount");     PayPal_setIdentityToken("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");     PayPal_setReturnURL("http://mywebsite/PayPal.php");     PayPal_setCurrency("SEK");     PayPal_setLogo("http://mywebsite/mybanner.png");     PayPal_setHTMLBody("<font color=red>Where are we going?</font>");         register_clcmd("test", "testcmd"); } public testcmd(id)     PayPal_Start(id, "This is ItemName", "This is ItemNumber", 15.0); public PayPal_Complete(id, ItemName[], ItemNumber[], Float:Amount, Currency[]) {     new name[32];     get_user_name(id, name, charsmax(name));     server_print("%s completed payment for ^"%s^"(%s), with %.2f %s.", name, ItemName, ItemNumber, Amount, Currency); }

Code:
Inc logging:
L 09/24/2013 - 01:31:54: [test1.amxx] [PayPal] Black Rose(STEAM_0:1:*snip*) completed payment for "This is ItemName"(This is ItemNumber), with 15.00 SEK. (*snip*)
Example Plugin:
Black Rose completed payment for "This is ItemName"(This is ItemNumber), with 15.00 SEK.
Payment design (Predetermined amount):


Donation design (Amount = 0.0):


Additional notes:
As always, you're not forced to use this as an include. You can use this in any way you want to.
You can, if you want, copy the whole thing into your .sma without even crediting me. My goal is not credit, It's to help.

I'm always open to suggestions, feedback and criticism. I aim to add as much support as possible. Please share your thoughts.
Attached Files
File Type: inc PayPal.inc (13.7 KB, 423 views)
File Type: txt PayPal.php.txt (1.0 KB, 325 views)
__________________

Last edited by Black Rose; 07-09-2017 at 16:23.
Black Rose is offline
bat
Veteran Member
Join Date: Jul 2012
Old 09-22-2013 , 02:59   Re: [Example] PayPal transactions from MOTD
Reply With Quote #2

Good job
__________________
bat is offline
Send a message via Skype™ to bat
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Location: Portugal
Old 09-22-2013 , 07:58   Re: [Example] PayPal transactions from MOTD
Reply With Quote #3

Great! Thanks for share
__________________
Jhob94 is offline
Rirre
Veteran Member
Join Date: Nov 2006
Old 09-22-2013 , 08:23   Re: [Example] PayPal transactions from MOTD
Reply With Quote #4

I don't think this is related to this plugin, but I can't make dots in the "Email" field at the step when you have to login to donate for the item.
But all other symbols is working.
, and - works fine which is the keys beside of the dot key on the keyboard, so what the hell do not dot key work?
Rirre is offline
red_bull2oo6
Senior Member
Join Date: Mar 2012
Location: Braila, Romania
Old 09-22-2013 , 14:08   Re: [Example] PayPal transactions from MOTD
Reply With Quote #5

wow, that`s awesome :O
great job! it seems that http2 is really 'powerfull'
__________________

My PC Themes . .
red_bull2oo6 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Upplands Väsby, Sweden
Old 09-22-2013 , 16:15   [INC] PayPal
Reply With Quote #6

Quote:
Originally Posted by red_bull2oo6 View Post
wow, that`s awesome :O
great job! it seems that http2 is really 'powerfull'
The power is all AMXX. HTTP2 just makes it easier to create these kind of functions.

Quote:
Originally Posted by Rirre View Post
I don't think this is related to this plugin, but I can't make dots in the "Email" field at the step when you have to login to donate for the item.
But all other symbols is working.
, and - works fine which is the keys beside of the dot key on the keyboard, so what the hell do not dot key work?
I don't know why the dot doesn't work. You also cannot do _ because that will paste (normally ctrl+v). It seems to be since an update of the client from May. It may be localized to some keyboard layouts. I have not yet found any solution or workaround.

You can still paste strings from console or even copy the URL to make the transaction from your browser as long as you are online at the server during the transaction.

It's not hard to add a buffer system aswell. Writing the SteamID to a file along with the arguments so when the person joins he will be given whatever was bought. But that kind of defeats the purpose of the payment being done withtin the MOTD.
__________________

Last edited by Black Rose; 09-25-2013 at 14:56.
Black Rose is offline
sami_spt
Veteran Member
Join Date: Sep 2012
Location: I<3 pussy cats
Old 09-23-2013 , 15:39   Re: [Example] PayPal transactions from MOTD
Reply With Quote #7




GREAT WORK
sami_spt is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Location: Portugal
Old 09-24-2013 , 12:09   Re: [INC] PayPal
Reply With Quote #8

Hey i need something like this, but it isnt with paypal.
Can i pm you about it? Because if i give the link here, it is publicity of my server host at same time. (Is page for donations via allopass, but is a page from my host and the money is redirected to my account)
__________________
Jhob94 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Upplands Väsby, Sweden
Old 09-24-2013 , 12:46   Re: [INC] PayPal
Reply With Quote #9

I'm very bad at French.
But yes, PM away and we'll see what we can do.
EDIT: Now I found the way to switch language.
__________________

Last edited by Black Rose; 09-24-2013 at 12:50.
Black Rose is offline
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 09-25-2013 , 06:44   Re: [INC] PayPal
Reply With Quote #10

Great work.
Will definitely make use of it.
__________________
Kia is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:50.


Powered by vBulletin®
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Theme made by Freecode