使用PHP使用Braintree API更新订阅时如何获得通知

时间:2019-05-09 06:00:09

标签: codeigniter webhooks subscription braintree

我正在设置三种类型的订阅计划,该计划是在Braintree的沙箱帐户上创建的。第一次订阅工作正常,但是一个月后,我想在数据库中更新有关该订阅的Braintree_WebhookNotification :: SUBSCRIPTION_CHARGED_SUCCESSFULLY 但是Braintree_WebhookNotification没有找到该网址,而且我无法更新有关该订阅的任何信息。

请帮助我...

我的代码是

if (isset($_POST["bt_signature"]) && isset($_POST["bt_payload"])){
    $webhookNotification = $gateway->webhookNotification()->parse(
    $_POST["bt_signature"], $_POST["bt_payload"]
    );
}
if($webhookNotification->kind == 'subscription_charged_successfully'){
    $data_saves = array(
    'kind' => $webhookNotification->kind,
    'current_billing_cycle' => $webhookNotification->subscription->currentBillingCycle,
    'billing_cycle' => $webhookNotification->subscription->numberOfBillingCycles,
    'status' => $webhookNotification->subscription->status,
    'customer_email' => $webhookNotification->subscription->transactions[0]->customer->email,
    'customer_id' => $webhookNotification->subscription->transactions[0]->customer->id,
    'subscription_id' => $webhookNotification->subscription->id,
    'currency_code' => $webhookNotification->subscription->transactions[0]->currencyIsoCode,
    'price' => $webhookNotification->subscription->price,
    'transaction_id' => $webhookNotification->subscription->transactions[0]->id,
    'paid' => $webhookNotification->subscription->transactions[0]->amount,
    'planId' => $webhookNotification->subscription->planId,
    'next_billing_cycle_date' => $webhookNotification->subscription->nextBillingDate->date,
    'billing_cycle_date' => $webhookNotification->subscription->transactions[0]->createdAt->date,
    'user_id' => 0,
    'json_data' => '',
    'type' => 'recurring'
    );

    $this->load->model('ProfileModel');

    $this->ProfileModel->createSubscription($data_saves);
    //$this->debug($webhookNotification);

}

0 个答案:

没有答案