Fix redirect.php
Enable Test Mode
Fix Cancellation of pre-authorization
fix cancellation of pre-authorization
Added comments throughout the files to gain a general understanding of the process
gocardless.php
• Created function to set API account details
• Updated invoice pay link to display 'SANDBOX MODE' if test flag is on
• Updated invoice pay link to hide underline making it look more like a button
• Added placeholder for currency conversion, should this be implemented?

callback.php
• Updated references to API account details

redirect.php
• Cleaned up code and added detailed comments
• Updated preauth handling
• Added instant payment functionality for first payment only (bill or preauth)
• Added sanity checks and error handling
gocardless.php
• Created function to set API account details
• Updated invoice pay link to display 'SANDBOX MODE' if test flag is on
• Updated invoice pay link to hide underline making it look more like a button
• Added placeholder for currency conversion, should this be implemented?

callback.php
• Updated references to API account details
• Cleaned up the callback script
• Removed unnecessary code (to be decided)
• Added working support for preauth cancellations
• Added support for payment failed (still working on this feature)
• Added handlers for refunded and created callbacks (to debate refunded handling)

redirect.php
• Cleaned up code and added detailed comments
• Updated preauth handling
• Added instant payment functionality for first payment only (bill or preauth)
• Added sanity checks and error handling
• Added switch to better handle cases and perform redirects correctly.
Merge branch 'Chris_Develop' of github.com:chrispage1/gocardless-whmcs-private into Chris_Develop

Conflicts:
	GoCardless_WHMCS/gocardless.php
	GoCardless_WHMCS/gocardless/callback.php
	GoCardless_WHMCS/gocardless/redirect.php
GoCardless_WHMCS/gocardless.php

• Removed test_mode flag as this is redundant
• Added GoCardless sandbox environment variable
• Updated gocardless_createdb() method to include new table structure
• Added a status to the admin area if a payment fails. Example error message - http://www.hallwaystudios.com/ss/YKo8b1IB.png

GoCardless_WHMCS/gocardless/GoCardless/Client.php

• Removed the redundant environment parameters as referenced by Tom

GoCardless_WHMCS/gocardless/callback.php

• Updated references to $gateway['name'] as this was incorrect
• Removed bill status check where not required
• Removed check to ensure 'instantpaid' is set to on before marking the invoice back as unpaid
• Updated payment failure handler to mark the invoice as unpaid, and prepend the trans ID with 'FAIL_'
• Upon payment failure, the relevant invoice in the admin area is updated with payment failure message
• Refund status does nothing - we can mark the invoice as Refunded if necessary but I think this is an admins job, thoughts?

GoCardless_WHMCS/gocardless/redirect.php

• Updated references to $gateway['name'] as this was incorrect
• Made use of already existing objects rather than making further API calls to complete processing
GoCardless_WHMCS/gocardless.php
• Began addressing the calculation of pricing.
• From doing this I have noticed that tax and other areas will need to be addressed
• The setup_fee flag does not appear to be working and returns an error 'Setup fee must be equal to 0.0'

GoCardless_WHMCS/gocardless/callback.php
• Updated the callback function to handle renewals on domain names
• Added refunds to receive the same treatment as a failed payment. Will prepend transaction with 'REFUND_'

GoCardless_WHMCS/gocardless/redirect.php
• Updated file to support domain subscriptions (this previously was not supported)
GoCardless_WHMCS/gocardless.php

• Cleaned up the plugin configuration to make it easier to read
• Added Usage notes that display in the following format - (You must set your Webhook URI within the 'Developer' > 'App Settings' tab to http://test.hostmetrics.net/modules/gateways/gocardless/callback.php)
• Completely rewritten method for determining invoice costs
• When 'Convert for Processing' flag is set to GBP, it converts any foreign currency into the correct currency
• Added 'start_at' flag to the preauth URL construct to address a potential issue with late payers
• When creating a bill, it will handle the possibility of an exception and log it should bill creation fail
• Updated database construct with UNIQUE keys to ensure database integrity (invoiceid and bill ID should only occur once)

GoCardless_WHMCS/gocardless/callback.php

• Removed tbldomains subscriptions as this was noted that WHMCS doesn't actually support this by default (although the field is there for some strange reason)
• Updated Preauth cancellation message
• Currency conversion is now handled incase the users default currency is not GBP
• Modified payment success transaction log message
• Modified how refunded/failed bill payments are handled and recorded
• When a bill is created, it is now recorded in the transaction log

GoCardless_WHMCS/gocardless/redirect.php
• Addressed referenced param coding error
• Updated bill creation to log error message if an error occurs
• Removed setting subscription ID/pre-auth for domain names
GoCardless_WHMCS/gocardless.php

• Cleaned up the plugin configuration to make it easier to read
• Added Usage notes that display in the following format - (You must set your Webhook URI within the 'Developer' > 'App Settings' tab to http://test.hostmetrics.net/modules/gateways/gocardless/callback.php)
• Completely rewritten method for determining invoice costs
• When 'Convert for Processing' flag is set to GBP, it converts any foreign currency into the correct currency
• Added 'start_at' flag to the preauth URL construct to address a potential issue with late payers
• When creating a bill, it will handle the possibility of an exception and log it should bill creation fail
• Updated database construct with UNIQUE keys to ensure database integrity (invoiceid and bill ID should only occur once)

GoCardless_WHMCS/gocardless/callback.php

• Removed tbldomains subscriptions as this was noted that WHMCS doesn't actually support this by default (although the field is there for some strange reason)
• Updated Preauth cancellation message
• Currency conversion is now handled incase the users default currency is not GBP
• Modified payment success transaction log message
• Modified how refunded/failed bill payments are handled and recorded
• When a bill is created, it is now recorded in the transaction log

GoCardless_WHMCS/gocardless/redirect.php
• Addressed referenced param coding error
• Updated bill creation to log error message if an error occurs
• Removed setting subscription ID/pre-auth for domain names
Merge branch 'Chris_Develop' of github.com:chrispage1/gocardless-whmcs-private into Chris_Develop

Conflicts:
	GoCardless_WHMCS/gocardless/callback.php

• Noticed a minor issue and produced a fix for this - As I had already pushed the changes Git saw this as a conflict
Numerous updates and bug fixes

GoCardless_WHMCS/gocardless.php
• Updated client side invoices to display error message if a GoCardless payment fails 'One or more payment attempts have failed against this invoice. Please contact our support department.'
• Modified start_at flag to address bug
• Modified state flag to address bug
• Updated database to include setup_id field

GoCardless_WHMCS/gocardless/callback.php

• Various modifications and bugfixes, making code lighter and ensuring everything works as expected
• New fee calculation saving the need for an uneccessary API call
• Currency conversion
• 400 Bad Request headers for invalid requests (shouldnt occur in normal practise)

GoCardless_WHMCS/gocardless/redirect.php
• Updated code in order to make it more lightweight
• Added preauth setup fee handling
• Updated currency conversion
• Added currency conversion for setup_fee bill and ensured setup_fee bill works correctly
• Added support for setup_fee bill within instant payment mode
GoCardless_WHMCS/gocardless/callback.php

• Addressed bug with currency conversion

GoCardless_WHMCS/gocardless/redirect.php

• Addressed bug with currency conversion
GoCardless_WHMCS/gocardless.php

• Addressed setup fee bug
Attempt to address indentation issues
Addressed environment bug (production URL was not automatically detected)
Added better exception handling and message reports
Added better exception handling and message reports
Merge branch 'Chris_Develop' of github.com:chrispage1/gocardless-whmcs-private into Chris_Develop

Conflicts:
	GoCardless_WHMCS/gocardless/redirect.php