1

I have following code:

PaypalRecurringPaymentProfile.php file

public function createProfile(array $data)
{
if (array_key_exists('SUBSCRIBERNAME', $data))
  $nvp_params['SUBSCRIBERNAME'] = urlencode($data['SUBSCRIBERNAME']);
if (array_key_exists('PROFILESTARTDATE', $data)) {
  $nvp_params['PROFILESTARTDATE'] = urlencode($data['PROFILESTARTDATE']);
}
else {
  $_errors[] = 'PROFILESTARTDATE is required parameter';
}

}

Now my index.php from where i called above class

$data = array();
$data['AMT']                = '9.99';
$data['ACCT']               = completed_number('4556', 16);
$data['CREDITCARDTYPE']     = PaypalRecurringPaymentProfile::cc_Visa;
$data['EXPDATE']            = '082014';
$data['CVV2']               = '086';
$data['FIRSTNAME']          = 'John';
$data['LASTNAME']           = 'Joe';
$data['STREET']             = '101 West 1th street apt 1';
$data['CITY']               = 'Brooklyn';
$data['STATE']              = 'NY';
$data['ZIP']                = '11201';
$data['PROFILESTARTDATE']   = '2012-10-01T00:00:00Z';
$data['DESC']               = 'Test of paypal recurring profile';
$data['BILLINGPERIOD']      = 'Month';
$data['BILLINGFREQUENCY']   = '1';
$data['TOTALBILLINGCYCLES'] = '12';
$data['TAXAMOUNT']          = '0.00';
$data['CURRENCYCODE']       = 'AUD';
$pp_profile                 = new PaypalRecurringPaymentProfile($api_username, $api_pasword, $api_signature, $api_version, $api_env);
$pp_create_profile          = $pp_profile->createProfile($data);
   print_r($pp_create_profile); exit;

I am creating object called $pp_profile and invoke method createProfile.

But when print $pp_create_profile it was blank

can anybody help me

5
  • did you run print_r($data); Commented Aug 12, 2015 at 6:06
  • your create profile function code in blank? Commented Aug 12, 2015 at 6:06
  • @Deena i run print_r($data) Commented Aug 12, 2015 at 6:07
  • Is createProfile method really empty? Because then you get for sure no value, because there is no return Commented Aug 12, 2015 at 6:08
  • Still no return in the method.. Commented Aug 12, 2015 at 6:47

2 Answers 2

1

You need to return array values.

    public function createProfile(array $data){

            $flag  =0;

            if (array_key_exists('SUBSCRIBERNAME', $data)){
              $nvp_params['SUBSCRIBERNAME'] = urlencode($data['SUBSCRIBERNAME']);
                $flag =1;
            }
            if (array_key_exists('PROFILESTARTDATE', $data)) {
              $nvp_params['PROFILESTARTDATE'] = urlencode($data['PROFILESTARTDATE']);
                 $flag =1;
            }
            else {
              $_errors[] = 'PROFILESTARTDATE is required parameter';

            }

            if($flag)
             return $nvp_params;
            else
             return $_errors;

  }
Sign up to request clarification or add additional context in comments.

Comments

0

hi can you please check this, I hope this will helps you

 $object = new stdClass();
 foreach ($array as $key => $value)
{
$object->$key = $value;
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.