Skip to content

Commit

Permalink
Merge 6d44d06 into b9807a0
Browse files Browse the repository at this point in the history
  • Loading branch information
rayzor65 committed Feb 23, 2017
2 parents b9807a0 + 6d44d06 commit f32ae74
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Zuora.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ public function subscribe(
$paymentMethod && $data['PaymentMethod'] = $paymentMethod->toArray();
$contact && $data['BillToContact'] = $contact->toArray();
$subscribeOptions && $data['SubscribeOptions'] = $subscribeOptions->toArray();
$subscriptionData = $subscription->toArray();

$ratePlanData = [];
array_push($ratePlanData, [
Expand All @@ -313,15 +314,21 @@ public function subscribe(
}

$data['SubscriptionData'] = [
'Subscription' => $subscription->toArray(),
'Subscription' => $subscriptionData,
'RatePlanData' => $ratePlanData,
];

if ($preview) {
$data['PreviewOptions'] = [
'EnablePreviewMode' => true,
'NumberOfPeriods' => 1
];

if ($subscriptionData['Type'] == Subscription::TERM_TYPE_TERMED) {
$data['PreviewOptions']['PreviewThroughTermEnd'] = true;
} else {
// Subscription::TERM_TYPE_EVERGREEN
$data['PreviewOptions']['NumberOfPeriods'] = 1;
}
}

return $this->api->subscribe($data);
Expand Down

0 comments on commit f32ae74

Please sign in to comment.