Skip to content

Commit

Permalink
Update coupon code
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaslorentsen committed Sep 17, 2019
1 parent de5c7db commit dada5a0
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/Stripe.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,33 @@ public function updateCustomerEmail($id, $email)
return json_decode($response->getBody());
}

/**
* @param string $id
* @param string $coupon
*
* @return object
*
* @throws CardException
*/
public function updateCustomerCoupon($id, $coupon)
{
try {
$response = $this->client->put('/customer/' . $id . '/discount/' . $coupon, [
]);
} catch (ClientException $exception) {
$response = $exception->getResponse();
$json = json_decode($response->getBody());
if (402 === $json->error->status) {
throw new CardException($json->error->message, $json->error->status, $exception);
}
throw $exception;
}
if (200 !== $response->getStatusCode()) {
return false;
}
return json_decode($response->getBody());
}

/**
* @param string $account
* @param string $user
Expand Down

0 comments on commit dada5a0

Please sign in to comment.