Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set number of payments or end date for Schedule #121

Open
alecogt opened this issue Oct 30, 2023 · 0 comments
Open

How to set number of payments or end date for Schedule #121

alecogt opened this issue Oct 30, 2023 · 0 comments

Comments

@alecogt
Copy link

alecogt commented Oct 30, 2023

I have been trying to setup a Schedule based on https://developer.heartlandpaymentsystems.com/Ecommerce/Recurring using a a tokenized credit card. I have managed to create a Schedule, but it never has an end date, nor a number of payments. I am using version 8.0.2.

What is the right way to set it up?

Here is the code I am using (I am changing the Schedule id on each request):

$schedule->id = 'S-20231030';
$schedule->customerKey = $customerKey;
$schedule->paymentKey = $paymentMethodKey;
$schedule->amount = 100;
$schedule->currency = 'USD';
$schedule->startDate = Carbon::tomorrow();
$schedule->paymentSchedule = PaymentSchedule::DYNAMIC;
//$schedule->endDate = $end_date;
$schedule->numberOfPaymentsRemaining = 4;
$schedule->frequency = ScheduleFrequency::WEEKLY;
$schedule->reprocessingCount = 1;
$schedule->emailReceipt = 'Never';
$schedule->status = 'Active';

$response = $schedule->create();

I haven't found a way for making $schedule->numberOfPaymentsRemaining nor $schedule->endDate = $end_date work.

Sometimes I get schedules created, like the following:

GlobalPayments\Api\Entities\Schedule {#2246 ▼
  +amount: 100
  +cancellationDate: ""
  +currency: "USD"
  +customerKey: 165162
  +description: null
  +deviceId: 6392739
  +emailNotification: false
  +emailReceipt: "Never"
  +endDate: ""
  +frequency: "Weekly"
  +hasStarted: true
  +invoiceNumber: null
  +name: null
  +nextProcessingDate: DateTime @1699194998 {#2247 ▼
    date: 2023-11-05 14:36:38.0 UTC (+00:00)
  }
  +numberOfPaymentsRemaining: null
  +poNumber: null
  +orderPrefix: null
  +paymentKey: "d97b570e-4c5b-4c41-a80b-6a493341feca"
  +paymentSchedule: "Dynamic"
  +reprocessingCount: 1
  +startDate: "10292023"
  +status: "Active"
  +taxAmount: 0
  +productId: null
  +customerNumber: null
  +scheduletext: null
  +id: "2023-10-28T20:58:40-abeeworks-S-1-5156"
  +key: 51532
}

Many other times I get errors like

GlobalPayments\Api\Entities\Exceptions\GatewayException {#2188 ▼
  +responseCode: null
  +responseMessage: null
  #message: "Status Code: 400 - Unable to add payment method: Host Unavailable "
  #code: 0
  #file: ".../vendor/globalpayments/php-sdk/src/Gateways/RestGateway.php"
  #line: 107
  trace: {▼
    .../vendor/globalpayments/php-sdk/src/Gateways/RestGateway.php:107 {▶}
    .../vendor/globalpayments/php-sdk/src/Gateways/PayPlanConnector.php:176 {▼
      GlobalPayments\Api\Gateways\PayPlanConnector->processRecurring(RecurringBuilder $builder) …
      ›     $this->mapUrl($builder),
      ›     $request === [] ? '{}' : json_encode($request)
      › );
    }
    .../vendor/globalpayments/php-sdk/src/Builders/RecurringBuilder.php:75 {▼
      GlobalPayments\Api\Builders\RecurringBuilder->execute($configName = 'default') …
      ›     $client = ServicesContainer::instance()->getRecurringClient($configName);
      ›     return $client->processRecurring($this);
      › }
    }
    .../vendor/globalpayments/php-sdk/src/Services/RecurringService.php:14 {▼
      GlobalPayments\Api\Services\RecurringService::create(RecurringEntity $entity) …
      › $response = (new RecurringBuilder(TransactionType::CREATE, $entity))
      ›     ->execute();
      › return $response;
    }
    .../vendor/globalpayments/php-sdk/src/Entities/RecurringEntity.php:36 {▼
      GlobalPayments\Api\Entities\RecurringEntity->create() …
      › {
      ›     return RecurringService::create($this);
      › }
    }
  }
}

Here are my questions about the integration:

  1. How am I supposed to set either the number of payments or the end date?
  2. Why is the "Host Unavailable" error thrown? Is there a rate limit? Is there something else to consider?
  3. What timezone are the start date and end date supposed to use?
  4. Once a schedule gets created, is there a way to process the first payment right away? Or will the first payment be processed the next day the sooner?
  5. Once a schedule gets created, is there a way to access information about the last payment processed? I see a paymentKey in the response. Is there an endpoint that can be used to get more information about the payment?
  6. How are we supponsed to acknowledge that a payment was processed? Should we constantly query Schedule::findAll() or Schedule::find()?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant