0

I'm not really familiar with PHP. I've been asked to add a recurring payment option to an already existing website that charges subscriptions to a magazine. Looking at the code I found this section:

$paypal = new Paypal('en');
            $paypal->API_UserName = API_USERNAME;
            $paypal->API_Password = API_PASSWORD;
            $paypal->API_Signature = API_SIGNATURE; 
            $paypal->API_Endpoint = 'https://api-3t.paypal.com/nvp' ;
            $paypal->lang_id            = 'en';
            $paypal->country_code       = 'CA';
            $paypal->operation          = OPERATION;
            $paypal->payment_type       = PAYMENT_TYPE;
            $paypal->email              = $Subscription->email;
            $paypal->firstname          = $Subscription->first_name;
            $paypal->lastname           = $Subscription->last_name;  

            $paypal->address            = $Subscription->address;
            $paypal->city               = $Subscription->city;
            $paypal->state              = $Subscription->province;
            $paypal->zip                = $Subscription->postal_code;
            $paypal->ship_address       = $paypal-> address;       
            $paypal->ship_firstname     = $paypal-> firstname;
            $paypal->ship_lastname      = $paypal-> lastname;
            $paypal->ship_city          = $paypal-> city;
            $paypal->ship_state         = $paypal-> state;
            $paypal->ship_country_code  = $paypal-> country_code;
            $paypal->ship_zip           = $paypal-> zip;

            $paypal->credit_card_type   = POST( 'card_type' );
            $paypal->credit_card_number = POST( 'card_number' );
            $paypal->exp_month          = POST( 'card_month' );

            $paypal->exp_year           = POST( 'card_year' );
            $paypal->cvn                = POST( 'cvn' );

            $paypal->amount             = number_format((float)$Subscription->total, 2);
            //$paypal->items_amount       = number_format((float)$Subscription->price, 2);
            $paypal->shipping_amount    = 0;
            //$paypal->tax_amount         = number_format((float)$Subscription->taxes, 2);
            $paypal->currency_code      = 'CAD';

          $paypal->prepare_checkout_request();
          $paypal->process_request();
          $paypal->interpret_response();

Looking at the Paypal documentation I found these parameters that should add the recurring feature to the current payment:

PROFILESTARTDATE BILLINGPERIOD BILLINGFREQUENCY AMT

How could I fit these in the current structure to, for example, make it charge every 3 years?

Thanks for any info that could guide me!

PS, for this, do customers need a Paypal account? Or can they just put their credit card?

  • I'd be really surprised if they allowed for a frequency longer than 1 year. – Matt Mar 28 '17 at 18:33
  • interesting, my client wants the client to select auto renew after 1 year or 3 years. – user3462096 Mar 28 '17 at 19:35
  • I think I found it: https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECRecurringPayments/ "The number of billing periods that make up one billing cycle. The combination of billing frequency and billing period must be less than or equal to one year. Note: If the billing period is SemiMonth, the billing frequency must be 1." It would be too scammy to allow someone to setup extremely long recurring payments I think. Trick a user into signing up and 3 years later bill them again. The right way to do a 3 year recurring payment is to send them an email and reauthorize. – Matt Mar 28 '17 at 19:37
  • Thanks for the info. I think my client is ok with the 1 year limitation. Now do you know how to modify the button in place to pass as a recurring payment? – user3462096 Mar 29 '17 at 18:55

0 Answers0