Gossamer Forum
Home : Products : Gossamer Mail : Discussion :

Custom Payment Module

Quote Reply
Custom Payment Module
Hi

Here in Norway, we seldom use the large international payment processors, and therefore, need our own. I am trying to make my custom payment module and have come so far:

I have managed to collect all info (I have changed the worldPay template and renamed it in Globals) and sent the user to the payment gateway, so far so good.

But when the payment is sent back, I need some code change in postback-module (since I used the WorldPay-module, I assume Payment->Remote->WorldPay.pm is the correct file to change this in).

I do my own payment check in php and sends the data back to postback.cgi. Therefore, I only need the pay code and do not need any error checking at all. So bacically, I want a "dummy" function in the perl code to log the payment as paid. I do not need recuring payments, only one time payments (and manual renewals, itīs the same, I assume).

I have tried to remove some of the code I do not need and changed it sligthly. But I only get Internal Server Error on whatever I do with this.

Suggestion to later: A custom payment module would have been nice.. Where you spesify the returned values and different required params like gateway url etc.

If anyone would help me in the rigth direction, I would appriciate it ! If not in perl, the sql-codes executed would also be helpfull.


# Glue between GMail and WorldPay payment interface
package GMail::Payment::Remote::WorldPay;
use strict;
# Make sure the payment module is available
use GT::Payment::Remote::WorldPay;
use GMail qw/$IN $CFG $DB $USER/;
use GMail::Payment qw/:status :log/;
use vars qw/%INVALID %EMPTY/;

sub postback {
# -----------------------------------------------------------------------------
my $pay = $DB->table('payments');
my $log = $DB->table('payment_logs');


my $unique = $IN->param('cartId');
my $payment = $pay->select({ payments_id => $unique })->fetchrow_hashref
or return; # Whatever it is, we didn't create it.
my $end = 0; # Returned after processing - if true, a blank page will be displayed,
# if false, a worldpay receipt page.
GT::Payment::Remote::WorldPay::process(
param => $IN,
on_valid => sub {
# A one-time payment (or the initial payment, in the case of recurring payments)
return unless $IN->param('amount') == $payment->{payments_amount};
return if $payment->{payments_status} == COMPLETED;
$pay->update(
{ payments_status => COMPLETED, payments_last => time },
{ payments_id => $payment->{payments_id} }
);
$log->insert({
paylogs_payments_id => $payment->{payments_id},
paylogs_type => LOG_ACCEPTED,
paylogs_time => time,
paylogs_text => (
sprintf($CFG->{language}->{PAYMENT_REMOTE_APPROVED} => 'WorldPay') . "\n" .
"Transaction ID: " . $IN->param('transId') . "\n" .
"Amount: " . $IN->param('amountString') . " (" . $IN->param('authAmountString') . ")\n" .
($IN->param('futurePayId') ? "FuturePay ID: " . $IN->param('futurePayId') . "\n" : "") .
"Authorization Message: " . $IN->param('rawAuthMessage') . "\n"
)
});
GMail::Payment::process_payment($payment->{payments_userid}, $payment->{payments_term}, $payment->{payments_level});
$end = 0;
},

if ($end) {
print $IN->header;
}
else {
$USER->load_user_by_id($payment->{payments_userid});
GMail->print_page($CFG->{states}->{'GMail::Payment'}->{confirm}->[0]->[0]);
}
}
1;
Subject Author Views Date
Thread Custom Payment Module areh 2683 Nov 14, 2004, 8:34 AM
Thread Re: [areh] Custom Payment Module
areh 2617 Nov 14, 2004, 9:48 AM
Post Re: [areh] Custom Payment Module
areh 2621 Nov 14, 2004, 10:16 AM
Post Re: [areh] Custom Payment Module
webmaster33 2393 Jan 29, 2006, 12:09 PM