Mollie integratie

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Joran

joran

12/09/2009 16:10:00
Quote Anchor link
Hallo mensjes van het goede computer leven,

Ik beheer op het moment tijdelijk een zeer groot Design forum en nu willen leden een betaal optie Ideal, SMS, bellen en vooral WallieCard. Hiervoor wil ik dus mollie gaan gebruiken :) Alleen 1 probleem. Ik zou niet weten hoe ik mollie zou kunnen integreren in IPB 2.2

In IPB maken ze gebruik van PaymentGateways. Ik heb als voorbeeld even de paymentgateway van Paypal gepakt en zoals je zult zien is die erg groot en zou niet weten hoe ik daar mollie van zou kunnen maken. Iemand een idee?


Alvast bedankt!





PayPal IPB PaymentGateway:

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
<?php

/*
+--------------------------------------------------------------------------
|   Invision Power Board
|   ========================================
|   by Matthew Mecham
|   (c) 2001 - 2005 Invision Power Services
|   Nullified by DGT
|   ========================================
|  
|  
+---------------------------------------------------------------------------
|
|   > Payment Gateway API: PAYPAL
|   > Module written by Matt Mecham
|   > Date started: 31st March 2005 (14:45)
|
|
+--------------------------------------------------------------------------
*/

        
if ( ! defined( 'GW_CORE_INIT' ) )
{

    print "You cannot access this module in this manner";
    exit();
}


//--------------------------------------------------------------------------
// DEFINITIONS EXPECTED AT THIS POINT
//--------------------------------------------------------------------------
// GW_URL_VALIDATE : The url for validating payment
// GW_URL_PAYDONE  : The url that the gatways returns the viewer to after
//                 : payment processed successfully
// GW_URL_PAYCANCEL: The url that the gatways returns the viewer to after
//                 : payment processed unsuccessfully or when cancelled
//--------------------------------------------------------------------------
// ITEM ARRAY
//--------------------------------------------------------------------------
// 'currency_code'    => Currency code,
// 'member_unique_id' => member's ID,
// 'member_name'      => member's NAME,
// 'member_email'     => member's EMAIL,
// 'package_cost'     => Requested package cost
// 'package_id'       => Requested package ID
// 'package_title'    => Requested package title
// 'duration_int'     => Requested package duration int  (ie: 12)
// 'duration_unit'    => Requested package duration unit (ie: m,d,y,w) [ month, day, year, week ]
// 'company_email'    => Company's email address
// 'ttr_int'          => Time to run (Time left on current package) integar (ie 3)
// 'ttr_unit'         => Time to run (Time left on current package) unit (ie w)
// 'ttr_balance'      => Time to run (Balance left on current package)
// 'ttr_package_id'   => Current package id (used for upgrading)
// 'vendor_id'        => The ID of the vendor (not used in all gateways)
// 'product_id'       => The gateway ID of the product (not used in all gateways)
// 'extra_1' thru 5   => Gateway extras ( from DB / tied in method_vars )
//--------------------------------------------------------------------------


class class_gw_module EXTENDS class_gateway
{

    # Global
    var $ipsclass;
    
    # Identify
    var $i_am = 'PayPal';
    
    var
$can_do_recurring_billing = 1;
    var
$can_do_upgrades          = 1;
    
    /*-------------------------------------------------------------------------*/
    // INIT
    /*-------------------------------------------------------------------------*/

    
    function main_init()
    {
    }

    
    /*-------------------------------------------------------------------------*/
    // Generate hidden fields [ Recurring, normal screen ]
    /*-------------------------------------------------------------------------*/

    
    function gw_generate_hidden_fields_normal_recurring( $items=array() )
    {

        $this->core_add_hidden_field( "cmd"          , "_xclick-subscriptions" );
        $this->core_add_hidden_field( "currency_code", $items['currency_code'] );
        $this->core_add_hidden_field( "custom"       , $items['member_unique_id'] );
        $this->core_add_hidden_field( "item_number"  , $items['package_id'] );
        $this->core_add_hidden_field( "t3"           , strtoupper($items['duration_unit'] ));
        $this->core_add_hidden_field( "p3"           , $items['duration_int'] );
        $this->core_add_hidden_field( "a3"           , $items['package_cost'] );
        $this->core_add_hidden_field( "business"     , $items['company_email'] );
        $this->core_add_hidden_field( "item_name"    , $items['package_title'] );
        $this->core_add_hidden_field( "no_shipping"  , 1 );
        $this->core_add_hidden_field( "src"          , 1 );
        $this->core_add_hidden_field( "rm"           , 2 );
        $this->core_add_hidden_field( "no_note"      , 1 );
        $this->core_add_hidden_field( "notify_url"   , GW_URL_VALIDATE  );
        $this->core_add_hidden_field( "return"       , GW_URL_PAYDONE   );
        $this->core_add_hidden_field( "cancel_return", GW_URL_PAYCANCEL );
        
        return $this->core_compile_hidden_fields();
    }

    
    /*-------------------------------------------------------------------------*/
    // Generate hidden fields [ Recurring, upgrade screen ]
    /*-------------------------------------------------------------------------*/

    
    function gw_generate_hidden_fields_upgrade_recurring( $items=array() )
    {

        $this->core_add_hidden_field( "cmd"          , "_xclick-subscriptions" );
        $this->core_add_hidden_field( "currency_code", $items['currency_code'] );
        $this->core_add_hidden_field( "custom"       , $items['member_unique_id'] );
        $this->core_add_hidden_field( "item_number"  , $items['package_id'] );
        $this->core_add_hidden_field( "t3"           , strtoupper($items['duration_unit']) );
        $this->core_add_hidden_field( "p3"           , $items['duration_int'] );
        $this->core_add_hidden_field( "a3"           , $items['package_cost'] );
        $this->core_add_hidden_field( "a1"           , $items['ttr_balance'] );
        $this->core_add_hidden_field( "p1"           , $items['ttr_int'] );
        $this->core_add_hidden_field( "t1"           , strtoupper($items['ttr_unit'] ));
        $this->core_add_hidden_field( "memo"         , "upgrade" );
        $this->core_add_hidden_field( "invoice"      , $items['ttr_package_id'].'x'.$items['package_id'].'x'.$items['member_unique_id'] );
        $this->core_add_hidden_field( "business"     , $items['company_email'] );
        $this->core_add_hidden_field( "item_name"    , $items['package_title'] );
        $this->core_add_hidden_field( "no_shipping"  , 1 );
        $this->core_add_hidden_field( "src"          , 1 );
        $this->core_add_hidden_field( "no_note"      , 1 );
        $this->core_add_hidden_field( "rm"           , 2 );
        $this->core_add_hidden_field( "notify_url"   , GW_URL_VALIDATE  );
        $this->core_add_hidden_field( "return"       , GW_URL_PAYDONE   );
        $this->core_add_hidden_field( "cancel_return", GW_URL_PAYCANCEL );
        
        return $this->core_compile_hidden_fields();
    }

    
    /*-------------------------------------------------------------------------*/
    // Generate hidden fields [ normal screen ]
    /*-------------------------------------------------------------------------*/

    
    function gw_generate_hidden_fields_normal( $items=array() )
    {

        $this->core_add_hidden_field( "cmd"          , "_xclick" );
        $this->core_add_hidden_field( "currency_code", $items['currency_code'] );
        $this->core_add_hidden_field( "custom"       , $items['member_unique_id'] );
        $this->core_add_hidden_field( "item_number"  , $items['package_id'] );
        $this->core_add_hidden_field( "item_name"    , $items['package_title'] );
        $this->core_add_hidden_field( "amount"       , $items['package_cost'] );
        $this->core_add_hidden_field( "business"     , $items['company_email'] );
        $this->core_add_hidden_field( "no_shipping"  , 1 );
        $this->core_add_hidden_field( "src"          , 1 );
        $this->core_add_hidden_field( "notify_url"   , GW_URL_VALIDATE  );
        $this->core_add_hidden_field( "return"       , GW_URL_PAYDONE   );
        $this->core_add_hidden_field( "cancel_return", GW_URL_PAYCANCEL );
        
        return $this->core_compile_hidden_fields();
    }

    
    /*-------------------------------------------------------------------------*/
    // Generate hidden fields [ upgrade screen ]
    /*-------------------------------------------------------------------------*/

    
    function gw_generate_hidden_fields_upgrade( $items=array() )
    {

        $this->core_add_hidden_field( "cmd"          , "_xclick" );
        $this->core_add_hidden_field( "currency_code", $items['currency_code'] );
        $this->core_add_hidden_field( "custom"       , $items['member_unique_id'] );
        $this->core_add_hidden_field( "item_number"  , $items['package_id'] );
        $this->core_add_hidden_field( "business"     , $items['company_email'] );
        $this->core_add_hidden_field( "item_name"    , $items['package_title'] );
        $this->core_add_hidden_field( "invoice"      , $items['ttr_package_id'].'x'.$items['package_id'].'x'.$items['member_unique_id'] );
        $this->core_add_hidden_field( "amount"       , $items['ttr_balance'] );
        $this->core_add_hidden_field( "no_shipping"  , 1 );
        $this->core_add_hidden_field( "src"          , 1 );
        $this->core_add_hidden_field( "notify_url"   , GW_URL_VALIDATE  );
        $this->core_add_hidden_field( "return"       , GW_URL_PAYDONE   );
        $this->core_add_hidden_field( "cancel_return", GW_URL_PAYCANCEL );
        
        return $this->core_compile_hidden_fields();
    }

    
    /*-------------------------------------------------------------------------*/
    // Generate Purchase button
    /*-------------------------------------------------------------------------*/

    
    function gw_generate_purchase_button()
    {

        return '<input type="image" src="https://www.paypal.com/images/x-click-but6.gif" name="submit" alt="'.$this->ipsclass->lang['paywith_paypal'].'" />';
    }

    
    /*-------------------------------------------------------------------------*/
    // Generate Form action [normal]
    /*-------------------------------------------------------------------------*/

    
    function gw_generate_normal_form_action()
    {

        return "https://www.paypal.com/cgi-bin/webscr";
    }

    
    /*-------------------------------------------------------------------------*/
    // Generate Form action [upgrade]
    /*-------------------------------------------------------------------------*/

    
    function gw_generate_upgrade_form_action()
    {

        return $this->gw_generate_normal_form_action();
    }

    
    /*-------------------------------------------------------------------------*/
    // Generate Form action [normal, recurring]
    /*-------------------------------------------------------------------------*/

    
    function gw_generate_normal_recurring_form_action()
    {

        return $this->gw_generate_normal_form_action();
    }

    
    /*-------------------------------------------------------------------------*/
    // Generate Form action [upgrade, recurring]
    /*-------------------------------------------------------------------------*/

    
    function gw_generate_upgrade_recurring_form_action()
    {

        return $this->gw_generate_normal_form_action();
    }

    
    /*-------------------------------------------------------------------------*/
    // Validate Payment
    // What we need to return:
    // 'currency_code'      => Currency code,
    // 'payment_amount'     => Amount paid,
    // 'payment_status'     => REFUND, ONEOFF, RECURRING
    // 'member_unique_id'   => member's ID,
    // 'purchase_package_id'=> Purchased package ID
    // 'current_package_id' => Current package ID (used for upgrading)
    // 'verified'           => TRUE , FALSE (Gateway verifies info as correct)
    // 'subscription_id'    => (Used for recurring payments)
    // 'transaction_id'     => Gateway transaction ID
    /*-------------------------------------------------------------------------*/

    
    function gw_validate_payment()
    {

        //--------------------------------------
        // INIT
        //--------------------------------------
        
        //--------------------------------------
        // Debug...
        //--------------------------------------

        
        if ( GW_TEST_MODE_ON )
        {

            if ( ! is_array( $_POST ) or ! count( $_POST ) )
            {

                $_POST = $_GET;
            }
        }

        
        $post_back[] = 'cmd=_notify-validate';
        
        foreach ($_POST as $key => $val)
        {

            $post_back[] = $key . '=' . urlencode (stripslashes($val));
        }

        
        $post_back_str = implode('&', $post_back);
        
        //--------------------------------------
        // URLS
        //--------------------------------------

        
        $urls = array( 'curl_full' => 'http://www.paypal.com/cgi-bin/webscr',
                       'sock_url'  => 'www.paypal.com',
                       'sock_path' => '/cgi-bin/webscr' );
                      
        //--------------------------------------
        // Throw back to PayPal to verify
        //--------------------------------------

        
        $state = $this->core_post_back( $urls, $post_back_str, 80 );
        
        //--------------------------------------
        // Check...
        //--------------------------------------

        
        $state = ( stristr($state, 'VERIFIED') ) ? 'VERIFIED' : 'INVALID';
        
        if ( $state != 'VERIFIED' )
        {

            if ( ! GW_TEST_MODE_ON )
            {

                $this->error = 'not_valid';
                return array( 'verified' => FALSE );
            }
        }

        
        //--------------------------------------
        // Fix ticket: #56264 Second POST - we can ignore
        //--------------------------------------

        
        if ( ! $_POST['txn_id'] and $_POST['txn_type'] == 'subscr_signup' )
        {

            exit();
        }

        
        //--------------------------------------
        // Populate return array
        //--------------------------------------

        
        list( $cur_sub_id, ) = explode( 'x', trim($_POST['invoice']) );
        
        $return = array( 'currency_code'      => $_POST['mc_currency'],
                         'payment_amount'     => $_POST['mc_gross'],
                         'member_unique_id'   => intval($_POST['custom']),
                         'purchase_package_id'=> intval($_POST['item_number']),
                         'current_package_id' => intval($cur_sub_id),
                         'verified'           => TRUE,
                         'subscription_id'    => $_POST['subscr_id'],
                         'transaction_id'     => $_POST['txn_id'] );
        
        //--------------------------------------
        // Sort out payment status
        //--------------------------------------

        
        if ( $_POST['payment_status'] == 'Refunded' )
        {

            $return['payment_status'] = 'REFUND';
        }

        else if( $_POST['txn_type'] == 'subscr_cancel' )
        {

            $return['payment_status'] = 'CANCEL';
        }

        else if ( strstr( $_POST['txn_type'], 'subscr_' ) )
        {

            $return['payment_status'] = 'RECURRING';
        }

        else if ( $_POST['txn_type'] == 'web_accept' )
        {

            $return['payment_status'] = 'ONEOFF';
        }

        else
        {
            $return['payment_status'] = '';
        }

        
        //--------------------------------------
        // Pass back to handler
        //--------------------------------------

        
        return $return;
    }

    
    /*-------------------------------------------------------------------------*/
    // Process recurring payment check
    // Return: array( 'amount_paid', 'state' [ PAID, DEAD, FAILED, PENDING ]
    /*-------------------------------------------------------------------------*/

    
    function gw_do_normal_payment_check( $balance_to_pay=0, $total_package_cost=0, $upgrade=0 )
    {

        $this->gateway->error = "";
        
        //--------------------------------------
        // INIT
        //--------------------------------------

        
        $return = array();
        
        //--------------------------------------
        // Completed
        //--------------------------------------

    
        if ( $_POST['payment_status'] == 'Completed' )
        {

            //--------------------------------------
            // Check amount..
            //--------------------------------------

            
            if ( $_POST['mc_gross'] == $total_package_cost )
            {

                //--------------------------------------
                // Paid correct amount
                //--------------------------------------

                
                $return['amount_paid'] = $_POST['mc_gross'];
                $return['state']       = 'PAID';
            }

            else
            {
                if ( $upgrade )
                {
    
                    //--------------------------------------
                    // Upgrading....
                    //--------------------------------------

                    
                    if ( $_POST['mc_gross'] == $balance_to_pay )
                    {

                        $return['amount_paid'] = $_POST['mc_gross'];
                        $return['state']       = 'PAID';
                    }
                    
                }

                else
                {
                    //--------------------------------------
                    // Incorrect amount
                    //--------------------------------------

                    
                    $this->error = "Wrong payment amount. Looking for {$total_package_cost}, got {$_POST['mc_gross']}";
                    return;
                }
            }
            
        }

        else if ( $_POST['payment_status'] == 'Pending' )
        {

            //-----------------------
            // Failed...
            //-----------------------

            
            $return['state'] = 'PENDING';
        }

        else
        {
            //-----------------------
            // End of subscription
            //-----------------------

            
            $return['state'] = 'FAILED';
        }

        
        return $return;
    }

    
    /*-------------------------------------------------------------------------*/
    // Process recurring payment check
    // Return: array( 'amount_paid', 'state' [ PAID, DEAD, FAILED, PENDING ]
    /*-------------------------------------------------------------------------*/

    
    function gw_do_recurring_payment_check( $balance_to_pay=0, $total_package_cost=0 )
    {

        $this->gateway->error = "";
        
        //--------------------------------------
        // INIT
        //--------------------------------------

        
        $return = array();
        
        //--------------------------------------
        // Sign up
        //--------------------------------------

        
        if ( $_POST['txn_type'] == 'subscr_signup' OR $_POST['txn_type'] == 'subscr_payment' )
        {

            //--------------------------------------
            // Check amount..
            //--------------------------------------

            
            if ( $_POST['amount1'] )
            {

                //--------------------------------------
                // First period, get amount.
                //--------------------------------------

                
                if ( $balance_to_pay != $_POST['amount1'] )
                {

                    $this->error = "Wrong upgrade subs amount. Looking for $balance_to_pay, got {$_POST['amount1']}";
                    return;
                }

                
                $return['amount_paid']  = $_POST['amount1'];
                $return['state']        = 'PAID';
            }

            else if ( $_POST['amount3'] )
            {

                //--------------------------------------
                // Real subscription
                //--------------------------------------

                
                if ( $total_package_cost != $_POST['amount3'] )
                {

                    $this->error = "Wrong upgrade subs amount. Looking for {$total_package_cost}, got {$_POST['amount3']}";
                    return;
                }

                
                $return['amount_paid']  = $total_package_cost;
                $return['state']        = 'PAID';
            }

            else
            {
                //--------------------------------------
                // If all else fails..
                //--------------------------------------

                
                if ( $total_package_cost != $_POST['mc_gross'] AND $_POST['mc_gross'] != $balance_to_pay )
                {

                    $this->error = "Wrong upgrade subs amount. Looking for {$total_package_cost}, got {$_POST['mc_gross']}";
                    return;
                }

                
                $return['amount_paid']  = $_POST['mc_gross'];
                $return['state']        = 'PAID';
            }
            
        }

        else if ( $_POST['txn_type'] == 'subscr_failed' )
        {

            //--------------------------------------
            // Failed...
            //--------------------------------------

            
            $return['state'] = 'FAILED';
        }

        else if ( $_POST['txn_type'] == 'subscr_cancel' )
        {

            //--------------------------------------
            // Dead...
            //--------------------------------------

            
            $return['state'] = 'DEAD';
        }

        else if ( $_POST['txn_type'] == 'subscr_eot' )
        {

            //--------------------------------------
            // End of subscription
            //--------------------------------------

            
            $return['state'] = 'DEAD';
        }

        
        return $return;
    }

    
    
    //---------------------------------------
    // Return ACP Package  Variables
    //
    // Returns names for the package custom
    // fields, etc
    //---------------------------------------

    
    function acp_return_package_variables()
    {

    
        $return = array(
                          'subextra_custom_1' => array( 'used' => 0, 'varname' => '' ),
                          'subextra_custom_2' => array( 'used' => 0, 'varname' => '' ),
                          'subextra_custom_3' => array( 'used' => 0, 'varname' => '' ),
                          'subextra_custom_4' => array( 'used' => 0, 'varname' => '' ),
                          'subextra_custom_5' => array( 'used' => 0, 'varname' => '' ),
                       );

                      
        return $return;
    
    }

    
    //---------------------------------------
    // Return ACP Method Variables
    //
    // Returns names for the package custom
    // fields, etc
    //---------------------------------------

    
    function acp_return_method_variables()
    {

    
        $return = array(
                          'submethod_custom_1' => array( 'used' => 0, 'varname' => '' ),
                          'submethod_custom_2' => array( 'used' => 0, 'varname' => '' ),
                          'submethod_custom_3' => array( 'used' => 0, 'varname' => '' ),
                          'submethod_custom_4' => array( 'used' => 0, 'varname' => '' ),
                          'submethod_custom_5' => array( 'used' => 0, 'varname' => '' ),
                       );

                      
        return $return;
    
    }
    
    
}


 
?>
 
PHP hulp

PHP hulp

30/11/2024 10:54:34
 
Quote Anchor link
Als je op de mollie site kijkt zie je dat ze een API hebben. Hiermee moet 't wel lukken als je een beetje php ervaring hebt. Als je dat niet hebt zal denk ik niet snel iemand het gratis voor je maken
 
Joran

joran

27/09/2009 16:15:00
Quote Anchor link
Ik heb nog nooit iets gedaan met API's... Iemand die zou kunnen helpen?
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.