Subscription - max-power/paymill-ruby GitHub Wiki
Subscriptions allow you to charge recurring payments on a client’s credit card / to a client’s direct debit. A subscription connects a client to the offers-object. A client can have several subscriptions to different offers, but only one subscription to the same offer.
This function creates a subscription between a client and an offer. A client can have several subscriptions to different offers, but only one subscription to the same offer. The clients is charged for each billing interval entered.
with_client_and_offer = {
client: 'client_88a388d9dd48f86c3136',
offer: 'offer_40237e20a7d5a231d99b'
}
Paymill::Subscription.create(with_client_and_offer)
or
client = Paymill::Client.find('client_88a388d9dd48f86c3136')
client.subscribe!('offer_40237e20a7d5a231d99b')
This function returns the detailed information of the concrete requested subscription.
Paymill::Subscription.find('sub_dc180b755d10da324864')
This function updates the subscription of a client. You can change e.g. the cancel_at_period_end attribute to terminate a subscription at a special point of time.
Paymill::Subscription.update('sub_dc180b755d10da324864', cancel_at_period_end: true)
This function removes an existing subscription. If you set the attribute cancel_at_period_end parameter to the value true, the subscription will remain active until the end of the period. The subscription will not be renewed again. If the value is set to false it is directly terminated but pending transactions will still be charged.
Paymill::Subscription.delete('sub_dc180b755d10da324864')
or
subscription = Paymill::Subscription.find('sub_dc180b755d10da324864')
subscription.canceled? # false
subscription.cancel! # this is actually this same as "subscription.delete"
Paymill::Subscription.all