本文整理汇总了PHP中Illuminate\Database\Eloquent\Model::readyForBilling方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::readyForBilling方法的具体用法?PHP Model::readyForBilling怎么用?PHP Model::readyForBilling使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Eloquent\Model
的用法示例。
在下文中一共展示了Model::readyForBilling方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
/**
* Delete this customer credit card in the billing gateway.
*
* @return Creditcard
*/
public function delete()
{
if (!$this->model->readyForBilling()) {
return $this;
}
$this->card->delete();
$cards = array();
foreach ($this->model->billing_cards as $c) {
if (Arr::get($c, 'id') != $this->id) {
$cards[] = $c;
}
}
$this->model->billing_cards = $cards;
$this->model->save();
// Refresh all subscription records that referenced this card.
if ($subscriptions = $this->model->subscriptionModelsArray()) {
foreach ($subscriptions as $subscription) {
if ($subscription->billingIsActive() && $subscription->billing_card == $this->id) {
$subscription->subscription()->refresh();
}
}
}
$this->info = array('id' => $this->id);
return $this;
}
示例2: refund
/**
* Refund this charge in the billing gateway.
*
* @param array $properties
*
* @return Charge
*/
public function refund(array $properties = array())
{
if (!$this->model->readyForBilling()) {
return $this;
}
$this->charge->refund($properties);
$this->info = $this->charge->info();
return $this;
}
示例3: create
/**
* Add a new credit card to this customer in the billing gateway.
*
* @param string $card_token
*
* @return Creditcard
*/
public function create($card_token)
{
if (!$this->model->readyForBilling()) {
return;
}
$card = new Creditcard($this->model, $this->model->gatewayCustomer()->card()->create($card_token));
$this->model->billing_cards = array_merge($this->model->billing_cards, array($card->toArray()));
$this->model->save();
return $card;
}
示例4: delete
/**
* Delete this customer in the billing gateway.
*
* @param array $properties
*
* @return Billing
*/
public function delete(array $properties = array())
{
if (!$this->model->readyForBilling()) {
return $this;
}
$this->customer->delete();
$this->refresh();
// Deactivate all customer subscriptions.
if ($subscriptions = $this->model->subscriptionModelsArray()) {
foreach ($subscriptions as $subscription) {
$subscription->billing_subscription_ends_at = $subscription->billingIsActive() ? date('Y-m-d H:i:s') : null;
$subscription->billing_active = 0;
$subscription->billing_subscription = null;
$subscription->billing_trial_ends_at = null;
$subscription->save();
}
}
return $this;
}
示例5: create
/**
* Create this charge in the billing gateway.
*
* @param int $amount
* @param array $properties
*
* @return Charge
*/
public function create($amount, array $properties = array())
{
if (!$this->model->readyForBilling()) {
if ($this->card_token) {
$this->model->billing()->withCardToken($this->card_token)->create($properties);
if (!empty($this->model->billing_cards)) {
$this->card_token = null;
}
} else {
$this->model->billing()->create($properties);
}
}
if ($this->card_token) {
$this->card = $this->model->creditcards()->create($this->card_token)->id;
$this->card_token = null;
}
$gateway_charge = \LinkThrow\Billing\Facades\Billing::charge(null, $this->model->gatewayCustomer())->create($amount, array_merge($properties, array('card_token' => $this->card_token, 'card' => $this->card)));
return new Charge($this->model, $gateway_charge);
}