Jump to content

API: Capture Payment


Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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 by thedangler
Link to comment
Share on other sites

  • 3 weeks later...

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

Link to comment
Share on other sites

  • 9 months later...

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?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated