/**
  * Creates an add transaction through the HpsPayPlanScheduleService
  */
 public function execute()
 {
     parent::execute();
     $service = new HpsPayPlanScheduleService($this->service->servicesConfig());
     $obj = new HpsPayPlanSchedule();
     foreach ($this->data as $k => $v) {
         $obj->{$k} = $v;
     }
     unset($usableData, $k, $v);
     return $service->add($obj);
 }
 protected function setup()
 {
     $config = new HpsServicesConfig();
     $config->secretApiKey = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A';
     $config->developerId = '002914';
     $config->versionNumber = '1510';
     $scheduleService = new HpsPayPlanScheduleService($config);
     $results = $scheduleService->page(1, 0)->findAll(array('scheduleStatus' => HpsPayPlanScheduleStatus::ACTIVE, 'scheduleIdentifier' => 'SecureSubmit'));
     $this->schedule = isset($results->results[0]) ? $results->results[0] : null;
     if ($this->schedule == null) {
         $customerService = new HpsPayPlanCustomerService($config);
         $id = date('Ymd') . '-SecureSubmit-' . substr(str_shuffle('abcdefghijklmnopqrstuvwxyz'), 0, 10);
         $newCustomer = new HpsPayPlanCustomer();
         $newCustomer->customerIdentifier = $id;
         $newCustomer->firstName = 'Bill';
         $newCustomer->lastName = 'Johnson';
         $newCustomer->company = 'Heartland Payment Systems';
         $newCustomer->country = 'USA';
         $newCustomer->customerStatus = HpsPayPlanCustomerStatus::ACTIVE;
         $customer = $customerService->add($newCustomer);
         $paymentMethodService = new HpsPayPlanPaymentMethodService($config);
         $newPaymentMethod = new HpsPayPlanPaymentMethod();
         $newPaymentMethod->customerKey = $customer->customerKey;
         $newPaymentMethod->nameOnAccount = 'Bill Johnson';
         $newPaymentMethod->accountNumber = 4111111111111111;
         $newPaymentMethod->expirationDate = '0120';
         $newPaymentMethod->country = 'USA';
         $paymentMethod = $paymentMethodService->add($newPaymentMethod);
         $id = date('Ymd') . '-SecureSubmit-' . substr(str_shuffle('abcdefghijklmnopqrstuvwxyz'), 0, 10);
         $date = date('m30Y', strtotime(date('Y-m-d', strtotime(date('Y-m-d'))) . '+1 month'));
         $newPaymentSchedule = new HpsPayPlanSchedule();
         $newPaymentSchedule->scheduleIdentifier = $id;
         $newPaymentSchedule->customerKey = $paymentMethod->customerKey;
         $newPaymentSchedule->paymentMethodKey = $paymentMethod->paymentMethodKey;
         $newPaymentSchedule->subtotalAmount = array('value' => 100);
         $newPaymentSchedule->startDate = $date;
         $newPaymentSchedule->frequency = HpsPayPlanScheduleFrequency::WEEKLY;
         $newPaymentSchedule->duration = HpsPayPlanScheduleDuration::LIMITED_NUMBER;
         $newPaymentSchedule->numberOfPayments = 3;
         $newPaymentSchedule->reprocessingCount = 2;
         $newPaymentSchedule->emailReceipt = 'Never';
         $newPaymentSchedule->emailAdvanceNotice = 'No';
         $newPaymentSchedule->scheduleStatus = HpsPayPlanScheduleStatus::ACTIVE;
         $this->schedule = $scheduleService->add($newPaymentSchedule);
     }
     $this->service = new HpsCreditService($config);
 }