benyoungenterprises Posted March 12, 2013 Share Posted March 12, 2013 Hey Guys, I've searched the forum and can't seem to see much on this topic. Basically I'm building a custom client area whilst keeping whmcs alive in the background (and communicating with it via the API) now I'm up the ordering section of the client area and I'm wondering whether anyone could give me a hand with this. I've looked over http://docs.whmcs.com/API:Capture_Payment but it doesn't really give me much of an example. At the moment the only payment methods are Paypal & Bank Deposit so I'm hoping that will make things a little easier, obviously I'll only be wanting to capture Paypal payments. Would someone be able to give me a simple explanation and even a simple php example of how it works? Thanks in advance Ben 0 Quote Link to comment Share on other sites More sharing options...
jclarke Posted March 12, 2013 Share Posted March 12, 2013 Hi Ben, The capture payment api method is used when a client has a credit card on file to capture a payment and will not do anything with a linked gateway such as PayPal. 0 Quote Link to comment Share on other sites More sharing options...
benyoungenterprises Posted March 12, 2013 Author Share Posted March 12, 2013 Thanks Joe, I obviously have mis-read and misinterpreted the capture payment article. Would you be able to give me some direction as to how I would get a paypal payment made and applied to an order/invoice generated via the API? I've read the "Add Invoice Payment" article and understand that but that's not going to direct the user to paypal to make the payment and then back to the website to add the payment to that particular invoice. Any help/suggestions would be greatly appreciated. Kind Regards, Ben 0 Quote Link to comment Share on other sites More sharing options...
jclarke Posted March 12, 2013 Share Posted March 12, 2013 There isn't really an easy way to do what you are wanting unless you redirect the user to the whmcs invoice in the client area. Otherwise you will need to look at the link that WHMCS generates inside of an invoice and generate the same link programmatically in your custom portal. 0 Quote Link to comment Share on other sites More sharing options...
benyoungenterprises Posted March 12, 2013 Author Share Posted March 12, 2013 Thanks Joe, I'll check that out. 0 Quote Link to comment Share on other sites More sharing options...
benyoungenterprises Posted March 12, 2013 Author Share Posted March 12, 2013 Dont know why I didn't think of that, pretty much got it all working. Thanks so much for that Joe, much appreciated. 0 Quote Link to comment Share on other sites More sharing options...
thedangler Posted March 14, 2013 Share Posted March 14, 2013 Did you end up generating the link? If so can you show me? 0 Quote Link to comment Share on other sites More sharing options...
benyoungenterprises Posted March 14, 2013 Author Share Posted March 14, 2013 Did you end up generating the link? If so can you show me? Hi thedangler, Sure, WHMCS basically submits a form to paypal with hidden fields that contain the invoice information and then has a return url which tells the paypal module in whmcs whether its paid or not... The form is on this page: http://www.yourdomain.com/urltoyourwhmcsinstallation/viewinvoice.php?id=yourinvoicenumber Here's an example of the form (with generic details obviously) <form method="post" action="https://www.paypal.com/cgi-bin/webscr"> <input type="hidden" value="_xclick" name="cmd"> <input type="hidden" value="yourpaypalemailaddresshere" name="business"> <input type="hidden" value="Your Company Name - Invoice #1234" name="item_name"> <input type="hidden" value="100.00" name="amount"> <input type="hidden" value="0.00" name="tax"> <input type="hidden" value="1" name="no_note"> <input type="hidden" value="1" name="no_shipping"> <input type="hidden" value="0" name="address_override"> <input type="hidden" value="Test" name="first_name"> <input type="hidden" value="Client" name="last_name"> <input type="hidden" value="" name="address1"> <input type="hidden" value="Adelaide" name="city"> <input type="hidden" value="South Australia" name="state"> <input type="hidden" value="5000" name="zip"> <input type="hidden" value="AU" name="country"> <input type="hidden" value="61" name="night_phone_a"> <input type="hidden" value="" name="night_phone_b"> <input type="hidden" value="utf-8" name="charset"> <input type="hidden" value="AUD" name="currency_code"> <input type="hidden" value="1234" name="custom"> <input type="hidden" value="https://yourdomain.com/urltoyourwhmcsinstallation/viewinvoice.php?id=1234&paymentsuccess=true" name="return"> <input type="hidden" value="https://https://yourdomain.com/urltoyourwhmcsinstallation/viewinvoice.php?id=1234&paymentfailed=true" name="cancel_return"> <input type="hidden" value="https://https://yourdomain.com/urltoyourwhmcsinstallation/modules/gateways/callback/paypal.php" name="notify_url"> <input type="hidden" value="WHMCS_ST" name="bn"> <input type="hidden" value="2" name="rm"> <input name="submit" type="submit" value="submit"> </form> Let me know if you need any help. the return & cancel_return can go to your custom application (instead of whmcs if you want), or you can probably do away with them all together. Let me know if you need any more help 0 Quote Link to comment Share on other sites More sharing options...
thedangler Posted March 20, 2013 Share Posted March 20, 2013 (edited) hello, I found this in the invoice as well, what I am wondering is what is the token name value used for? I see it is not in the example you've provided. When I look at the paypal button inputs there is a token. is that mandatory? What is it for and how do I generate it if it is? Thank you for the response. So I have it working but the IPN seems to not be working. the logs say invalid handshake. maybe this has to do with the Token? Edited March 21, 2013 by thedangler 0 Quote Link to comment Share on other sites More sharing options...
traveller7 Posted April 9, 2013 Share Posted April 9, 2013 Hi, We are currently develop a custom order form which need paypal payment. Has anyone managed to integrate successfull payment via PayPal by whmcs api? Can you show some successfull integration with PayPal payment? And how add recurring payment via api? Or Website Payment Pro integration? It's much interesting. Thanks! Gabor 0 Quote Link to comment Share on other sites More sharing options...
niels Posted January 20, 2014 Share Posted January 20, 2014 Did anyone get this working? I'm looking at doing the same thing. Creating the client, the order and the invoice through the API is simple, but redirecting to the gateway seems undocumented. I'm pretty sure we should be able to redirect the user to viewinvoice.php or cart.php and have that redirect the user to the gateway automatically, just like WHMCS' own ordering process does. Is there any way to pass cart.php an existing order or tell viewinvoice.php to redirect to the gateway immediately? 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.