PayPal: Recurring Payments Profile not being created in Live

I am working with PayPal NVP to create a subscription-based service on my website, where I will be accepting payments via PayPal and the type of payment is going to be Recurring Payments.

Code snippet from my signup.php file:

//SetExpressCheckout
$sec_data = array(
        'USER'                           => PAYPAL_API_USERNAME,
        'PWD'                            => PAYPAL_API_PASSWORD,
        'SIGNATURE'                      => PAYPAL_API_SIGNATURE,
        'VERSION'                        => "95.0",
        'METHOD'                         => "SetExpressCheckout",
        'PAYMENTREQUEST_0_AMT'           => $total_amt,
        'RETURNURL'                      => "<url_structure>",
        'CANCELURL'                      => "<url_structure>",
        'NOSHIPPING'                     => "1",
        'SOLUTIONTYPE'                   => "Sole",
        'LOGOIMG'                        => "<url_structure>",
        'BRANDNAME'                      => "My Website",
        'PAYMENTREQUEST_0_CURRENCYCODE'  => "USD",
        'PAYMENTREQUEST_0_ITEMAMT'       => $current_plan_price,
        'PAYMENTREQUEST_0_PAYMENTACTION' => "Sale",
        'L_PAYMENTREQUEST_0_AMT0'        => $current_plan_price,
        'L_BILLINGTYPE0'                 => "RecurringPayments",
        'L_BILLINGAGREEMENTDESCRIPTION0' => "You'll be billed USD ".$total_amt.".",
        'PAYMENTREQUEST_0_DESC'          => "You'll be billed USD ".$total_amt.".",
        'PAYMENTREQUEST_0_CUSTOM'        => "Thank you for your payment!",
        'PAYMENTREQUEST_0_INVNUM'        => "INV-".$invoice_num,
        'NOTETOBUYER'                    => $current_plan_name,
        'PAYMENTREQUEST_0_PAYMENTREASON' => "None",
        'EMAIL'                          => $email,
        'LANDINGPAGE'                    => "Billing",
        'PAYMENTREQUEST_0_TAXAMT'        => $tax_amt,
        'L_PAYMENTTYPE0'                 => "InstantOnly"
    );

Code from my payment-success.php file:

//GetExpressCheckoutDetails
$get_ec_data = array(
        'USER'      => PAYPAL_API_USERNAME,
        'PWD'       => PAYPAL_API_PASSWORD,
        'SIGNATURE' => PAYPAL_API_SIGNATURE,
        'TOKEN'     => $ec_token,
        'METHOD'    => "GetExpressCheckoutDetails",
        'VERSION'   => "95.0"
    );

//DoExpressCheckoutPayment
$decp_data = array(
                'USER'                          => PAYPAL_API_USERNAME,
                'PWD'                           => PAYPAL_API_PASSWORD,
                'SIGNATURE'                     => PAYPAL_API_SIGNATURE,
                'METHOD'                        => "DoExpressCheckoutPayment",
                'TOKEN'                         => $ec_token,
                'PAYERID'                       => $ec_response['PAYERID'],
                'PAYMENTREQUEST_0_AMT'          => $total_amt,
                'PAYMENTREQUEST_0_CURRENCYCODE' => "USD",
                'PAYMENTREQUEST_0_ITEMAMT'      => $total_amt,
                'VERSION'                       => "95.0"
            );

//CreateRecurringPaymentsProfile
$crpp_array = array(
                'USER'               => PAYPAL_API_USERNAME,
                'PWD'                => PAYPAL_API_PASSWORD,
                'SIGNATURE'          => PAYPAL_API_SIGNATURE,
                'VERSION'            => "95.0",
                'METHOD'             => "CreateRecurringPaymentsProfile",
                'TOKEN'              => $ec_token,
                'PROFILESTARTDATE'   => $last_payment_date,
                'DESC'               => "You'll be billed USD ".$total_amt.".",
                'BILLINGPERIOD'      => "Month",
                'BILLINGFREQUENCY'   => "12",
                'TOTALBILLINGCYCLES' => '0',
                'AMT'                => $total_amt,
                'CURRENCYCODE'       => "USD",
                'EMAIL'              => $get_cx_data['cx_email'],
                'STREET'             => "Bedford Ave",
                'CITY'               => "Brooklyn",
                'STATE'              => "New York",
                'COUNTRYCODE'        => "US",
                'ZIP'                => "11211"
            );

//GetRecurringPaymentsProfileDetails
$grppd_array = array(
                    'USER'      => PAYPAL_API_USERNAME,
                    'PWD'       => PAYPAL_API_PASSWORD,
                    'SIGNATURE' => PAYPAL_API_SIGNATURE,
                    'VERSION'   => "95.0",
                    'METHOD'    => 'GetRecurringPaymentsProfileDetails',
                    'PROFILEID' => $get_crpp_response['PROFILEID']
                );

And I am sending the NVP data to PayPal like this:

toPayPal($nvp_data, "https://api-3t." .(PAYPAL_MODE == 'TEST' ? 'sandbox.paypal' : 'paypal'). ".com/nvp");

Here are my PayPal functions:

function toPayPal($inputArray, $PayPalURL) {
        $nvp_post_data_str   = '';

        foreach($inputArray as $key => $value) {
            $nvp_post_data_str .= $key.'='.urlencode($value).'&';
        }

        $nvp_post_data_str = substr($nvp_post_data_str, 0, strlen($nvp_post_data_str) - 1);
        $ch = curl_init();
        
        curl_setopt($ch, CURLOPT_URL, $PayPalURL);
        curl_setopt($ch, CURLOPT_VERBOSE, 1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $nvp_post_data_str);
        $httpResponse = curl_exec($ch);
        
        //$httpResponse;
        
        $httpResponse = explode('&', $httpResponse);
        
        for($i = 0; $i < count($httpResponse); $i++) {
            $temp_array = explode('=', $httpResponse[$i]);
            $httpResponseArray[$temp_array[0]] = urldecode($temp_array[1]);
        }
        
        return $httpResponseArray;
    }

Now the issue is that everything seems to be working on Sandbox but when it comes to Live, the Recurring Account is not being created on my main PayPal account.

Is there anything that I am missing? Also, do I need to install NVP SDK or something, I have no idea about it.

Also, in the sandbox, when I am running print_r() on the response of GetRecurringPaymentsProfileDetails the PROFILESTARTDATE and NEXTPAYMENTDATE are the same. Is that the issue?

Thank you all for taking the time.

Sponsor our Newsletter | Privacy Policy | Terms of Service