I'm trying to develop an Authorize.Net payment plugin but I have a lot of questions. I feel like I'm gaining an understanding and only need a couple pushes in the right direction to figure this out. I'd like to provide this to the community as well so thanks in advance to anyone who is willing to help - you may be in turn helping everyone! Please feel free to correct me if I am wrong anywhere - I want to learn and contribute. I have tried to organize and make obvious my points that need consideration below.
I am basing this off of the paypal payment plugin and have also looked at a contributed plugin for Moneris for comparison. I'm experienced with PHP but I have not used the smarty template system and am not 100% with the MVC framework yet either. I am a fast learner though and if people here are willing to help me I'll take any and all advice.
First off, this plugin needs to give people the option to pay online using their credit card, or to pay offline. Right now I have an option via radio buttons to choose which way to pay. I figured that if they chose to pay offline I'd just handle that in the script that processes the payment to perform the same actions as if the Manual Payment plugin was chosen. Is this feasible?
Second, the online payment option needs to be hosted through this website and not lead to a hosted payment form, which is where I'm running into all of my problems. From examining the PayPal plugin it seems that their hosted form will send some type of notification based on if there is a success ('notify_url' below) or if there is a cancellation ('cancel_return' below) of payment (perhaps they are using a CURL request to send this notification). Also, they will return you to the OCS site based on the 'return' value below. I assumed this from lines 87-90 in PayPalPlugin.inc.php:
'notify_url' => Request::url(null, null, 'payment', 'plugin', array($this->getName(), 'ipn')),
'return' => $queuedPayment->getRequestUrl(),
'cancel_return' => Request::url(null, null, 'payment', 'plugin', array($this->getName(), 'cancel')),
I assume PayPal sends data back to /index.php/CONFERENCE/SCHEDULEDCONFERENCE/payment/plugin/Paypal/ipn OR /index.php/CONFERENCE/SCHEDULEDCONFERENCE/payment/plugin/Paypal/cancel depending on what the user does on the paypal payment page. Am I correct in assuming that this /ipn or /cancel parts of the path actually end up being the variable(s) passed to the handle($args) method as $args?
If that is the case, then I don't understand what line 132 in PayPalPlugin.inc.php is
curl_setopt($ch, CURLOPT_URL, $this->getSetting($schedConf->getConferenceId(), $schedConf->getId(), 'paypalurl'));
It looks to me like it's sending the payment and all of the post fields to the paypal URL defined in the settings. But I was under the impression that since it brought you to the paypal site it wouldn't need to do that.
If what I am trying to do is a possibility and if my understanding above is correct, I feel like I can make this work by making a CURL request to the authorize.net system and based on that make another CURL request to the plugin in the form (/index.php/CONFERENCE/SCHEDULEDCONFERENCE/payment/plugin/Authorize.Net/xxx) and that will allow the handle($args) function to process the payment according to the plugin rules. However, I would also need a confirmation page after people submit their payment, and from what I have come to understand the paymethod plugins only have the ability to display one page through the displayPaymentForm method, is this true?
I have posted my files as I have them so far. The only part that I still need help with is the handle($args) function which at this point remains much the same as the one in the PayPal Plugin.