2013-03-07 6 views
0

https://github.com/jforrest/Chargify-PHP-Client에 설명 된 php 충전 커넥터를 사용 중이며 구독의 next_billing_at 매개 변수를 업데이트하고 싶습니다. 나는 이런 식으로 일을 시도 :php api를 사용하여 chargify next_billing_at 값을 업데이트하는 방법은 무엇입니까?

$requestArr = array('customer_id'=>"$thisCustomerID",'next_billing_at' => '2013-04-20T02:52:17-04:00'); 
try { 
    $connector->requestUpdateSubscription($thisSubscriptionID, json_encode($requestArr), $format = 'JSON'); 
} catch (ChargifyValidationException $cve) { 
    //process error handling code here. 
    echo $cve->getMessage(); 
} 

유효성 검사 예외가 없음에도 불구하고 내가 바로 이후 다음 평가 날짜를 확인할 때, 그것은 변경되지 않습니다 :

$subscriptionUpdated = $connector->getSubscriptionsByID($thisSubscriptionID); 
$newBillingDate = $subscriptionUpdated->next_assessment_at; 
echo "new next billing date is $newBillingDate<br>"; 

내가 날짜를 통과 시도처럼 ' 2013-04-20 '하지만 그 중 하나가 작동하지 않았다. API를 사용하여 청구일을 업데이트 할 수 있습니까? 당신의 배열과 같아야 제외

답변

2

당신은 오른쪽 생각이있어 :

$requestArr = array(
    'subscription' => array(
     'customer_id' => $thisCustomerID, 
     'next_billing_at' => '2013-04-20' 
    ) 
); 

그리고 당신은 잘되어야합니다 (테스트)

참조 : http://docs.chargify.com/api-subscriptions#api-usage-json-subscriptions-update

+0

야호! 제임스 감사합니다! 위의 첫 번째 줄을 $ requestArr [ 'subscription'] = array ('customer_id'=> "$ thisCustomerID", 'next_billing_at'=> '2013-04-20T02 : 52 : 17-04 : 00')로 변경했습니다. 그것은 완벽하게 작동했습니다. :) – Robert