diff --git a/include/stripe.hrl b/include/stripe.hrl index 1c295a7..7de1082 100644 --- a/include/stripe.hrl +++ b/include/stripe.hrl @@ -337,3 +337,6 @@ description :: desc(), recipient :: recipient_id(), statement_descriptor :: desc()}). + +-record(stripe_delete, {id :: customer_id() | plan_id() | coupon_id() | invoice_id(), + status :: true| false}). \ No newline at end of file diff --git a/src/stripe.erl b/src/stripe.erl index 9159a9e..0b7ad0d 100644 --- a/src/stripe.erl +++ b/src/stripe.erl @@ -3,7 +3,7 @@ -module(stripe). -export([token_create/10, token_create_bank/3]). --export([customer_create/3, customer_get/1, customer_update/3]). +-export([customer_create/3, customer_get/1, customer_update/3,customer_delete/1]). -export([charge_customer/4, charge_card/4]). -export([subscription_update/3, subscription_update/5, subscription_update/6, subscription_cancel/2, subscription_cancel/3]). @@ -55,6 +55,15 @@ customer_create(Card, Email, Desc) -> {description, Desc}], request_customer_create(Fields). +%%%-------------------------------------------------------------------- +%%% Customer delete +%%%-------------------------------------------------------------------- +-spec customer_delete(customer_id()) -> result. +customer_delete(CustomerId) -> + request_customer_delete(CustomerId). + + + %%%-------------------------------------------------------------------- %%% Customer Fetching %%%-------------------------------------------------------------------- @@ -197,6 +206,9 @@ request_event(EventId) -> request_customer(CustomerId) -> request_run(gen_customer_url(CustomerId), get, []). +request_customer_delete(CustomerId) -> + request_run(gen_customer_url(CustomerId), delete, []). + request_invoiceitem(InvoiceItemId) -> request_run(gen_invoiceitem_url(InvoiceItemId), get, []). @@ -472,6 +484,11 @@ json_to_record(<<"transfer">>, DecodedResult) -> recipient = ?V(recipient), statement_descriptor = ?V(statement_descriptor)}; +json_to_record(undefined, [{<<"deleted">>, Status}, {<<"id">>, ObjectId}]) -> + #stripe_delete{id = ObjectId, + status = Status}; + + json_to_record(Type, DecodedResult) -> error_logger:error_msg({unimplemented, ?MODULE, json_to_record, Type, DecodedResult}), {not_implemented_yet, Type, DecodedResult}.