Subscriptions allow you to charge recurring payments on a client's credit card / direct debit account. 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.
Subscription
object
Example
{
"id" : "sub_09a1944830b7e37e2005",
"offer" : "<Object>",
"livemode" : false,
"amount" : 299,
"temp_amount" : null,
"currency" : "USD",
"name" : "Testing",
"interval" : "1 DAY",
"trial_start" : 1400555454,
"trial_end" : null,
"period_of_validity" : null,
"end_of_period" : null,
"next_capture_at" : 1400642826,
"created_at" : 1400555454,
"updated_at" : 1400556426,
"canceled_at" : null,
"payment" : "<Object>",
"app_id" : null,
"is_canceled" : false,
"is_deleted" : false,
"status" : "failed",
"mandate_reference" : null,
"client" : "<Object>"
}
Sub objects
subscription.offer returns an offer object
subscription.payment returns a payment object for credit card or a payment object for direct debit
Attributes
id: string
Unique identifier of this subscription
livemode: boolean
Whether this subscription was issued while being in live mode or not
offer: offer object
amount: integer
the amount of the subscription in cents
temp_amount: integer / null
a one-time amount in cents, will charge once only
currency: _string
ISO 4217 formatted currency code
interval: string
Defining how often the client should be charged. Format: number DAY | WEEK | MONTH | YEAR [, WEEKDAY] Example: 2 DAYS, MONDAY
name: string / null
name of the subscription
trial_start: integer / null
Unix-Timestamp for the trial period start
trial_end: integer / null
Unix-Timestamp for the trial period end
period_of_validity: string / null
limit the validity of the subscription, format: integer MONTH | YEAR | WEEK | DAY
end_of_period: Unix-Timestamp / null
expiring date of the subscription
next_capture_at: integer
Unix-Timestamp for the next charge
created_at: integer
Unix-Timestamp for the creation Date
updated_at: integer
Unix-Timestamp for the last update
canceled_at: integer / null
Unix-Timestamp for the cancel date
payment: _payment object for credit card / payment object for direct debit
payment object for credit card or direct debit
mandate_reference: string or null
SEPA mandate reference, can be optionally specified for direct debit transactions (necessary for recurring direct debit transactions). If specified for other payment methods, it has no effect but must still be valid. If specified, the string must not be empty, can be up to 35 characters long and may contain digits 0-9, letters a-z A-Z, allowed special characters: ‘ , . : + - / ( ) ?
client: _client object _
client object
app_id: string / null
App (ID) that created this subscription or null if created by yourself
is_canceled: boolean
subscription is marked as canceled or not
is_deleted: boolean
subscription is marked as deleted or not
status: string
shows, if subscription is "active", "inactive", "expired" or "failed"
Create new Subscription
Without an offer
Request
curl https://api.paymill.com/v2.1/subscriptions \
-u <YOUR_PRIVATE_KEY>: \
-d "client=client_81c8ab98a8ac5d69f749" \
-d "payment=pay_5e078197cde8a39e4908f8aa" \
-d "amount=3000" \
-d "currency=EUR" \
-d "interval=1 week,monday" \
-d "name=Example Subscription" \
-d "period_of_validity=2 YEAR" \
-d "start_at=1400575533"
client = Paymill::Client.create(email: 'client@example.com')
payment = Paymill::Payment.create(token: '098f6bcd4621d373cade4e832627b4f6', client: client)
Paymill::Subscription.create(
payment: payment,
client: client,
name: 'Example Subscription',
amount: 3000,
currency: 'EUR',
interval: '1 week,monday',
period_of_validity: '2 YEAR',
start_at: 2.days.from_now
)
SubscriptionService subscriptionService = paymillContext.getSubscriptionService();
subscriptionService.create( Subscription.create(
"pay_5e078197cde8a39e4908f8aa",
3000,
"EUR",
Interval.periodWithChargeDay( 1, Unit.WEEK, Weekday.MONDAY )
)
.withName( "Example Subscription" )
.withPeriodOfValidity( Interval.period( 2, Unit.YEAR ) )
.withStartDate( new Date( 1400575533 ) )
);
pm.subscriptions.fromParams("pay_5e078197cde8a39e4908f8aa",3000,"EUR","1 week,monday")
.withClient( "client_81c8ab98a8ac5d69f749" )
.withName( "Example Subscription" )
.withPeriodOfValidity( "2 YEAR" )
.withStartDate( new Date(1400575533))
.create().then( function(subscription) {
console.log("created subscription:" + subscription.id);
}, function(error) {
console.log("couldnt create subscription:" + error);
});
subscription_service = paymill_context.get_subscription_service()
subscription_without_offer = subscription_service.create_with_amount(
payment_id='pay_5e078197cde8a39e4908f8aa',
amount=3OOO,
currency='EUR',
interval='1 WEEK,MONDAY'
)
$subscription = new Paymill\Models\Request\Subscription();
$subscription->setClient('client_81c8ab98a8ac5d69f749')
->setAmount(3000);
->setPayment('pay_5e078197cde8a39e4908f8aa');
->setCurrency('EUR');
->setInterval('1 week,monday');
->setName('Example Subscription');
->setPeriodOfValidity('2 YEAR');
->setStartAt('1400575533');
$response = $request->create($subscription);
SubscriptionService subscriptionService = paymillContext.SubscriptionService;
subscriptionService.CreateAsync( Subscription.Create(
"pay_5e078197cde8a39e4908f8aa",
3000,
"EUR",
Interval.periodWithChargeDay( 1, Interval.TypeUnit.WEEK, Interval.Weekday.MONDAY ) )
.WithName( "Example Subscription" )
.WithPeriodOfValidity( Interval.period( 2, Interval.TypeUnit.YEAR ) )
.WithStartDate(DateTime.Now.AddDays(5)
);
Response
{
"data":{
"id":"sub_dea86e5c65b2087202e3",
"offer":{<Object>},
"livemode":false,
"amount":3000,
"temp_amount":null,
"currency":"EUR",
"name":"Example Subscription",
"interval":"1 WEEK,MONDAY",
"trial_start":1399908040,
"trial_end":1400575532,
"period_of_validity":"2 YEAR",
"end_of_period":1461429607,
"next_capture_at":1400575532,
"created_at":1398271207,
"updated_at":1398271207,
"canceled_at":null,
"payment":{<Object>},
"app_id":null,
"is_canceled":false,
"is_deleted":false,
"status":"active",
"client":{<Object>}
},
"mode":"test"
}
With an offer
Request
curl https://api.paymill.com/v2.1/subscriptions \
-u <YOUR_PRIVATE_KEY>: \
-d "client=client_64b025ee5955abd5af66" \
-d "offer=offer_40237e20a7d5a231d99b" \
-d "payment=pay_95ba26ba2c613ebb0ca8" \
-d "period_of_validity=2 YEAR" \
-d "start_at=1400575533"
payment = Paymill::Payment.create(token: '098f6bcd4621d373cade4e832627b4f6')
offer = Paymill::Offer.create(
amount: 3333,
currency: 'EUR',
interval: '1 WEEK',
name: 'Nerd Special',
trial_period_days: 30
)
Paymill::Subscription.create(
payment: payment,
offer: offer,
period_of_validity: '2 YEAR',
start_at: 2.days.from_now
)
SubscriptionService subscriptionService = paymillContext.getSubscriptionService();
subscriptionService.create( Subscription.create(
"pay_95ba26ba2c613ebb0ca8",
"offer_40237e20a7d5a231d99b"
).withPeriodOfValidity( Interval.period( 2, Unit.YEAR ) )
.withStartDate( new Date(1400575533) )
);
pm.subscriptions.fromOffer("pay_95ba26ba2c613ebb0ca8","offer_40237e20a7d5a231d99b")
.withClient( "client_64b025ee5955abd5af66" )
.withName( "Example Subscription" )
.withPeriodOfValidity( "2 YEAR" )
.withStartDate( new Date(1400575533)).create().then( function(subscription) {
console.log("created subscription:" + subscription.id);
}, function(error) {
console.log("couldnt create subscription:" + error);
});
subscription_service = paymill_context.get_subscription_service()
subscription_with_an_offer = subscription_service.create_with_offer_id(
payment_id='pay_3af44644dd6d25c820a9',
offer_id='offer_bb33ea77b942f570997b'
)
$subscription = new Paymill\Models\Request\Subscription();
$subscription->setClient('client_81c8ab98a8ac5d69f749')
->setOffer('offer_40237e20a7d5a231d99b');
->setPayment('pay_5e078197cde8a39e4908f8aa');
->setPeriodOfValidity('2 YEAR');
->setStartAt(1400575533);
$response = $request->create($subscription);
SubscriptionService subscriptionService = paymillContext.SubscriptionService;
subscriptionService.CreateAsync( Subscription.Create(
"pay_95ba26ba2c613ebb0ca8",
"offer_40237e20a7d5a231d99b" )
.WithPeriodOfValidity( Interval.period( 2, Interval.TypeUnit.YEAR ) )
.WithStartDate( DateTime.Now.AddDays(5) )
);
Response
{
"data":{
"id":"sub_dea86e5c65b2087202e3",
"offer":{<Object>},
"livemode":false,
"amount":3333,
"temp_amount":null,
"currency":"USD",
"name":"Offer Name",
"interval":"2 WEEK",
"trial_start":1399908040,
"trial_end":1400575532,
"period_of_validity":"2 YEAR",
"end_of_period":1461429607,
"next_capture_at":1400575532,
"created_at":1398271207,
"updated_at":1398271207,
"canceled_at":null,
"payment":{<Object>},
"app_id":null,
"is_canceled":false,
"is_deleted":false,
"status":"active",
"client":{<Object>}
},
"mode":"test"
}
With offer and different values
Request
curl https://api.paymill.com/v2.1/subscriptions \
-u <YOUR_PRIVATE_KEY>: \
-d "client=client_81c8ab98a8ac5d69f749" \
-d "payment=pay_5e078197cde8a39e4908f8aa" \
-d "offer=offer_b33253c73ae0dae84ff4" \
-d "amount=3000" \
-d "currency=EUR" \
-d "interval=1 week,monday" \
-d "name=Example Subscription" \
-d "period_of_validity=2 YEAR" \
-d "start_at=1400575533"
payment = Paymill::Payment.create(token: '098f6bcd4621d373cade4e832627b4f6')
offer = Paymill::Offer.create(
amount: 4200,
currency: 'EUR',
interval: '1 MONTH',
name: 'Nerd Special',
trial_period_days: 30
)
Paymill::Subscription.create(
payment: payment,
offer: offer,
amount: 3000,
currency: 'EUR',
interval: '1 week, monday',
name: 'Example Subscription',
period_of_validity: '2 YEAR',
start_at: 2.days.from_now
)
SubscriptionService subscriptionService = paymillContext.getSubscriptionService();
subscriptionService.create( Subscription.create(
"pay_95ba26ba2c613ebb0ca8",
"offer_40237e20a7d5a231d99b"
).withAmount( 3000 )
.withCurrency( "EUR" )
.withInterval( Interval.periodWithChargeDay( 1, Unit.WEEK, Weekday.MONDAY ) )
.withPeriodOfValidity( Interval.period( 2, Unit.YEAR ) )
.withStartDate( new Date( 1400575533 ) )
);
pm.subscriptions.fromOffer("pay_5e078197cde8a39e4908f8aa","offer_b33253c73ae0dae84ff4")
.withClient( "client_81c8ab98a8ac5d69f749" )
.withAmount( 3000 )
.withCurrency( "EUR")
.withInterval("1 week,monday")
.withName( "Example Subscription" )
.withPeriodOfValidity( "2 YEAR" )
.withStartDate( new Date(1400575533))
.create().then( function(subscription) {
console.log("created subscription:" + subscription.id);
}, function(error) {
console.log("couldnt create subscription:" + error);
});
subscription_service = paymill_context.get_subscription_service()
subscription_with_offer_and_different_values = subscription_service.create_with_offer_id(
payment_id='pay_5e078197cde8a39e4908f8aa',
offer_id='offer_b33253c73ae0dae84ff4',
name='Example Subscription',
period_of_validity='2 YEAR',
start_at=1400575533
)
$subscription = new Paymill\Models\Request\Subscription();
$subscription->setClient('client_81c8ab98a8ac5d69f749')
->setOffer('offer_40237e20a7d5a231d99b');
->setAmount(3000);
->setPayment('pay_5e078197cde8a39e4908f8aa');
->setCurrency('EUR');
->setInterval('1 week,monday');
->setName('Example Subscription');
->setPeriodOfValidity('2 YEAR');
->setStartAt('1400575533');
$response = $request->create($subscription);
SubscriptionService subscriptionService = paymillContext.SubscriptionService;
subscriptionService.CreateAsync( Subscription.Create(
"pay_95ba26ba2c613ebb0ca8",
"offer_40237e20a7d5a231d99b" )
.WithAmount( 3000 )
.WithCurrency( "EUR" )
.WithInterval( Interval.periodWithChargeDay( 1, Interval.TypeUnit.WEEK, Interval.Weekday.MONDAY ) )
.WithPeriodOfValidity( Interval.period( 2, Interval.TypeUnit.YEAR ) )
.withStartDate( DateTime.Now.AddDays(5) )
);
Response
{
"data":{
"id":"sub_dea86e5c65b2087202e3",
"offer":{<Object>},
"livemode":false,
"amount":3000,
"temp_amount":null,
"currency":"EUR",
"name":"Example Subscription",
"interval":"1 WEEK,MONDAY",
"trial_start":1399908040,
"trial_end":1400575532,
"period_of_validity":"2 YEAR",
"end_of_period":1461429607,
"next_capture_at":1400575532,
"created_at":1398271207,
"updated_at":1398271207,
"canceled_at":null,
"payment":{<Object>},
"app_id":null,
"is_canceled":false,
"is_deleted":false,
"status":"active",
"client":{<Object>}
},
"mode":"test"
}
Sub Objects
- subscription.offer returns an offer object
- subscription.payment returns a payment object for credit card or a payment object for direct debit
- subscription.client returns a client object
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.
Attributes
offer: _string
Unique offer identifier (if no offer is given, amount, currency and interval are required)
payment: string
Unique payment identifier
client: string
Unique client identifier. If not provided the client from the payment is being used
amount: integer (>0)
the amount of the subscription in cents (is required if no offer id is given)
currency: string
ISO 4217 formatted currency code (is required if no offer id is given)
interval: string
charged. Format: number DAY | WEEK | MONTH | YEAR [, WEEKDAY] Example: 2 DAYS, MONDAY ( is required if no offer id is given)
name: string / null
name of the subscription (optional)
period_of_validity: string / null
limit the validity of the subscription, format: integer MONTH | YEAR | WEEK | DAY (optional)
Example: To create a subscription for 6 months, set value "5 MONTH"
Note: The last payment attempt will be done at the end of the period of validity. Example: If you want to make a subscription of 6 months, then you have to set "period_of_validity=5 MONTH".
Note: The supported value range for period_of_validity is from 1 to 99
start_at: integer / null
Unix-Timestamp for the subscription start date, if trial_end > start_at, the trial_end will be set to start_at (optional)
Subscription
details
Request
curl https://api.paymill.com/v2.1/subscriptions/sub_dc180b755d10da324864 \
-u <YOUR_PRIVATE_KEY>:
Paymill::Subscription.find("sub_dc180b755d10da324864")
SubscriptionService subscriptionService = paymillContext.getSubscriptionService();
Subscription subscription = subscriptionService.get("sub_dc180b755d10da324864");
pm.subscriptions.detail("sub_dc180b755d10da324864").then(function(subscription) {
console.log("subscription:" + subscription.id);
}, function(error) {
console.log("couldnt get subscription:" + error);
});
subscription_service = paymill_context.get_subscription_service()
subscription_details = subscription_service.detail(subscription_without_offer)
$subscription = new Paymill\Models\Request\Subscription();
$subscription->setId('sub_dc180b755d10da324864');
$response = $request->getOne($subscription);
SubscriptionService subscriptionService = paymillContext.SubscriptionService;
Subscription subscription = subscriptionService.GetAsync("sub_dc180b755d10da324864").Result;
Response
{
"data" :{
"id":"sub_dc180b755d10da324864",
"offer":{<Object>},
"livemode":false,
"amount":3000,
"temp_amount":null,
"currency":"EUR",
"name":"Example Subscription",
"interval":"1 WEEK,MONDAY",
"trial_start":1399908040,
"trial_end":1400575532,
"period_of_validity":"2 YEAR",
"end_of_period":1461429607,
"next_capture_at":1400575532,
"created_at":1398271207,
"updated_at":1398271207,
"canceled_at":null,
"payment":{<Object>},
"app_id":null,
"is_canceled":false,
"is_deleted":false,
"status":"active",
"client":{<Object>}
},
"mode" : "test"
}
Sub objects
- subscription.offer returns an offer object
- subscription.payment returns a payment object for credit card or a payment object for direct debit
- subscription.client returns a client object
This function returns the detailed information of the concrete requested subscription.
Attributes
id: string
Unique identifier for the subscription
Update Subscription
General
Request
curl https://api.paymill.com/v2.1/subscriptions/sub_dea86e5c65b2087202e3 \
-u <YOUR_PRIVATE_KEY>: \
-d "payment=pay_95ba26ba2c613ebb0ca8" \
-d "currency=USD" \
-d "interval=1 month,friday" \
-d "name=Changed Subscription" \
-d "period_of_validity=14 MONTH" \
-d "trial_end=false" \
-X PUT
subscription = Paymill::Subscription.find('sub_dea86e5c65b2087202e3')
subscription.payment = 'pay_95ba26ba2c613ebb0ca8'
subscription.currency = 'USD'
subscription.interval = '1 month,friday'
subscription.name = 'Changed Subscription'
subscription.trial_end = false
subscription.update
# for limit / unlimit use
subscription = Paymill::Subscription.find('sub_dea86e5c65b2087202e3')
subscription.unlimit
subscription.limit('12 MONTH')
SubscriptionService subscriptionService = paymillContext.getSubscriptionService();
Subscription subscription = subscriptionService.get( "sub_dea86e5c65b2087202e3" );
subscription.setName( "Changed Subscription" );
subscriptionService.update( subscription );
pm.subscriptions.detail("sub_dea86e5c65b2087202e3").then(function(subscription) {
subscription.name = "Changed Subscription";
return pm.transactions.update(subscription);
}).then(function(updatedSubscription) {
console.log("updated subscription name:" + updatedSubscription.name);
}, function(error) {
console.log("couldnt update the subscription:" + error);
});
subscription_service = paymill_context.get_subscription_service()
subscription_without_offer.name = 'Updated Subscription'
subscription_service.update(subscription_without_offer)
$subscription = new Paymill\Models\Request\Subscription();
$subscription->setId('sub_dea86e5c65b2087202e3');
->setClient('client_81c8ab98a8ac5d69f749')
->setOffer('offer_40237e20a7d5a231d99b');
->setAmount(3000);
->setPayment('pay_95ba26ba2c613ebb0ca8');
->setCurrency('USD');
->setInterval('1 month,friday');
->setName('Changed Subscription');
->setPeriodOfValidity('14 MONTH');
->setTrialEnd(false);
$response = $request->update($subscription);
SubscriptionService subscriptionService = paymillContext.SubscriptionService;
Subscription subscription = subscriptionService.GetAsync( "sub_dea86e5c65b2087202e3" ).Result;
subscription.Name = "Changed Subscription" ;
subscription.Offer = null; // Do not update Offer
subscription.Currency = null;// Do not update Currency
subscription.Interval = null;// Do not update Interval
Subscription updatedSubscription = subscriptionService.UpdateAsync(subscription).Result;
Response
{
"data" :{
"id":"sub_dea86e5c65b2087202e3",
"offer":{<Object>},
"livemode":false,
"amount":3000,
"temp_amount":null,
"currency":"USD",
"name":"Changed Subscription",
"interval":"1 MONTH,FRIDAY",
"trial_start":1399908040,
"trial_end":null,
"period_of_validity":"12 MONTH",
"end_of_period":1435063506,
"next_capture_at":1400575532,
"created_at":1398271207,
"updated_at":1398343548,
"canceled_at":null,
"payment":{<Object>},
"app_id":null,
"is_canceled":false,
"is_deleted":false,
"status":"active",
"client":{<Object>}
},
"mode" : "test"
}
Amount
Request
curl https://api.paymill.com/v2.1/subscriptions/sub_dea86e5c65b2087202e3 \
-u <YOUR_PRIVATE_KEY>: \
-d "amount=1234" \
-d "amount_change_type=0" \
-X PUT
#amount temporary:
subscription = Paymill::Subscription.find('sub_dea86e5c65b2087202e3')
subscription.update_amount_once(1234)
#amount permanently:
subscription = Paymill::Subscription.find('sub_dea86e5c65b2087202e3')
subscription.update_amount_permanently(1234)
SubscriptionService subscriptionService = paymillContext.getSubscriptionService();
subscriptionService.changeAmountTemporary( "sub_dea86e5c65b2087202e3" , 1234 );
pm.subscriptions.detail("sub_dea86e5c65b2087202e3").then(function(subscription) {
return pm.transactions.changeAmountTemporary(subscription, 1234);
}).then(function(updatedSubscription) {
console.log("updated subscription amount:" + updatedSubscription.amount);
}, function(error) {
console.log("couldnt update the subscription:" + error);
});
subscription_service = paymill_context.get_subscription_service()
subscription_without_offer.amount = 1234
subscription_service.update_with_amount(subscription_without_offer, amount_change_type=1)
$subscription = new Paymill\Models\Request\Subscription();
$subscription->setId('sub_dea86e5c65b2087202e3');
->setAmount(1234);
->setAmountChangeType(0);
$response = $request->update($subscription);
SubscriptionService subscriptionService = paymillContext.SubscriptionService;
Subscription updatedSubscription = subscriptionService.ChangeAmountTemporaryAsync( "sub_dea86e5c65b2087202e3" , 1234 ).Result;
Response
{
"data" : {
"id":"sub_dea86e5c65b2087202e3",
"offer" : "<Object>",
"livemode":false,
"amount":3000,
"temp_amount":"1234",
"currency":"EUR",
"name":"Example Subscription",
"interval":"1 WEEK,MONDAY",
"trial_start":1398271207,
"trial_end":1399196896,
"period_of_validity":"2 YEAR",
"end_of_period":1461429607,
"next_capture_at":1399308007,
"created_at":1398271207,
"updated_at":1398271302,
"canceled_at":null,
"payment": "<Object>",
"app_id":null,
"is_canceled":false,
"is_deleted":false,
"status":"active",
"client" : "<Object>"
},
"mode" : "test"
}
Offer
Request
curl https://api.paymill.com/v2.1/subscriptions/sub_dea86e5c65b2087202e3 \
-u <YOUR_PRIVATE_KEY>: \
-d "offer=offer_d7e9813a25e89c5b78bd" \
-d "offer_change_type=2" \
-X PUT
#offer with no refund and unchanged capture date:
subscription = Paymill::Subscription.find('sub_dea86e5c65b2087202e3')
offer = Offer.create(name: 'Foo', amount: 4990, currency: 'EUR', interval: '2 WEEK')
subscription.update_offer_without_changes(offer)
#offer with refund and unchanged capture date:
subscription = Paymill::Subscription.find('sub_dea86e5c65b2087202e3')
offer = Offer.create(name: 'Foo', amount: 4990, currency: 'EUR', interval: '2 WEEK')
subscription.update_offer_with_refund(offer)
#offer with refund and capture date:
subscription = Paymill::Subscription.find('sub_dea86e5c65b2087202e3')
offer = Offer.create(name: 'Foo', amount: 4990, currency: 'EUR', interval: '2 WEEK')
subscription.update_offer_with_refund_and_capture_date(offer)
Offer offer = paymillContext.getOfferService().get( "offer_d7e9813a25e89c5b78bd" );
SubscriptionService subscriptionService = paymillContext.getSubscriptionService();
Subscription subscription = subscriptionService.get( "sub_dea86e5c65b2087202e3" );
subscriptionService.changeOfferChangeCaptureDateAndRefund( subscription, offer );
pm.subscriptions.detail("sub_dea86e5c65b2087202e3").then(function(subscription) {
return pm.transactions.changeOfferChangeCaptureDateAndRefund(subscription, "offer_d7e9813a25e89c5b78bd");
}).then(function(updatedSubscription) {
console.log("updated subscription offer:" + updatedSubscription.offer.id);
}, function(error) {
console.log("couldnt update the subscription:" + error);
});
subscription_service = paymill_context.get_subscription_service()
subscription_with_an_offer.offer_id='offer_40237e20a7d5a231d99b'
subscription_service.update_with_offer_id(
subscription_with_an_offer,
offer_change_type=2
)
$subscription = new Paymill\Models\Request\Subscription();
$subscription->setId('sub_dea86e5c65b2087202e3');
->setOffer('offer_d7e9813a25e89c5b78bd');
->setOfferChangeType(2);
$response = $request->update($subscription);
Offer offer = paymillContext.OfferService.GetAsync( "offer_d7e9813a25e89c5b78bd" ).Result;
SubscriptionService subscriptionService = paymillContext.SubscriptionService;
Subscription subscription = subscriptionService.GetAsync( "sub_dea86e5c65b2087202e3" ).Result;
Subscription updatedSubscription = subscriptionService.ChangeOfferChangeCaptureDateAndRefundAsync( subscription, offer ).Result;
Response
{
"data" : {
"id":"sub_dea86e5c65b2087202e3",
"offer" : "<Object>",
"livemode":false,
"amount":3000,
"temp_amount":null,
"currency":"EUR",
"name":"Example Subscription",
"interval":"1 WEEK,MONDAY",
"trial_start":1398271207,
"trial_end":1399196896,
"period_of_validity":"2 YEAR",
"end_of_period":1461429607,
"next_capture_at":1399308007,
"created_at":1398271207,
"updated_at":1398271302,
"canceled_at":null,
"payment": "<Object>",
"app_id":null,
"is_canceled":false,
"is_deleted":false,
"status":"active",
"client" : "<Object>"
},
"mode" : "test"
}
Pause
Request
curl https://api.paymill.com/v2.1/subscriptions/sub_dea86e5c65b2087202e3 \
-u <YOUR_PRIVATE_KEY>: \
-d "pause=true" \
-X PUT
#pause:
subscription = Paymill::Subscription.find('sub_dea86e5c65b2087202e3')
subscription.pause
#play:
subscription = Paymill::Subscription.find('sub_dea86e5c65b2087202e3')
subscription.play
SubscriptionService subscriptionService = paymillContext.getSubscriptionService();
subscriptionService.pause( "sub_dea86e5c65b2087202e3" );
pm.subscriptions.detail("sub_dea86e5c65b2087202e3").then(function(subscription) {
return pm.transactions.pause(subscription);
}).then(function(updatedSubscription) {
console.log("updated subscription status:" + updatedSubscription.status);
}, function(error) {
console.log("couldnt update the subscription:" + error);
});
# pause
subscription_service = paymill_context.get_subscription_service()
subscription_service.pause(subscription_without_offer)
# unpause
subscription_service = paymill_context.get_subscription_service()
subscription_service.unpause(subscription_without_offer)
$subscription = new Paymill\Models\Request\Subscription();
$subscription->setId('sub_dea86e5c65b2087202e3');
->setPause(true);
$response = $request->update($subscription);
SubscriptionService subscriptionService = paymillContext.SubscriptionService;
Subscription updatedSubscription = subscriptionService.PauseAsync( "sub_dea86e5c65b2087202e3" ).Result;
Response
{
"data" : {
"id":"sub_dea86e5c65b2087202e3",
"offer" : "<Object>",
"livemode":false,
"amount":3000,
"temp_amount":null,
"currency":"EUR",
"name":"Example Subscription",
"interval":"1 WEEK,MONDAY",
"trial_start":1398271207,
"trial_end":1399196896,
"period_of_validity":"2 YEAR",
"end_of_period":1461429607,
"next_capture_at":1399308007,
"created_at":1398271207,
"updated_at":1398271302,
"canceled_at":null,
"payment": "<Object>",
"app_id":null,
"is_canceled":false,
"is_deleted":false,
"status":"inactive",
"client" : "<Object>"
},
"mode" : "test"
}
Sub objects
- subscription.offer returns an offer object
- subscription.payment returns a payment object for credit card or a payment object for direct debit
- subscription.client returns a client object
This function updates the subscription of a client. You can change e.g. the trial_end attribute to stop the trial period. Or you can assign the subscription to another offer (offer=<new_offer_id>), change the amount or pause it. NOTE: changing the amount and offer within one request is not possible (throw an exception).
Attributes
id: string
Unique identifier for the subscription
payment: string
Unique identifier describing a payment of the client
offer: string
Unique identifier describing the offer which is subscribed to the client (optional)
offer_change_type: integer / null
permitted values: 0,1,2; linked and required with ‘offer', default: 0 (optional)
Value description:
0: The next_capture_at date will remain unchanged, no refund will be given
1: No function yet
2: The next_capture_at date will change to the current date (immediate charge), a pro-rata refund will be given if due.
The interval will be reset, the capture date is changed permanently.
amount: integer (>0)
the amount of the subscription in cents (optional)
amount_change_type: integer
permitted values: 0,1; linked and required with ‘amount' (optional)
0: The new amount is valid one-time only. It will be set back to the initial amount in the next interval.
1: The new amount is valid permanently until the end of the subscription.
pause: boolean
deactivate a subscription or reactivate it, false: reactivate, true: deactivate (optional)
currency: string
ISO 4217 formatted currency code (optional)
interval: string
Defining how often the client should be charged. Format: number DAY | WEEK | MONTH | YEAR [, WEEKDAY] (optional)
name: string
name of the subscription (optional)
period_of_validity: string
limit the validity of the subscription, format: integer MONTH | YEAR | WEEK | DAY, set to "remove" to unlimit the validity period (optional)
trial_end: boolean
set to false to stop the trial period immediatly (optional)
Cancel or Delete Subscription
Cancel
Request
curl https://api.paymill.com/v2.1/subscriptions/sub_dea86e5c65b2087202e3 \
-u <YOUR_PRIVATE_KEY>: \
-d "remove=false" \
-X DELETE
subscription = Paymill::Subscription.find('sub_dea86e5c65b2087202e3')
subscription.cancel()
SubscriptionService subscriptionService = paymillContext.getSubscriptionService();
subscriptionService.cancel( "sub_dea86e5c65b2087202e3" );
pm.subscriptions.cancel("sub_d68bcdc8656a7932eb44").then(function(subscription) {
console.log("canceled subscription :" + subscription.status);
}, function(error) {
console.log("couldnt cancel subscription:" + error);
});
subscription_service = paymill_context.get_subscription_service()
subscription_service.cancel(subscription_without_offer)
$subscription = new Paymill\Models\Request\Subscription();
$subscription->setId('sub_dea86e5c65b2087202e3');
->setRemove(false);
$response = $request->delete($subscription);
SubscriptionService subscriptionService = paymillContext.SubscriptionService;
Subscription updatedSubscription = subscriptionService.CancelAsync( "sub_dea86e5c65b2087202e3" ).Result;
Response
{
"data" : {
"id":"sub_dea86e5c65b2087202e3",
"offer" : "<Object>",
"livemode":false,
"amount":3000,
"temp_amount":null,
"currency":"EUR",
"name":"Example Subscription",
"interval":"1 WEEK,MONDAY",
"trial_start":1398271207,
"trial_end":1399196896,
"period_of_validity":"2 YEAR",
"end_of_period":1461429607,
"next_capture_at":1399308007,
"created_at":1398271207,
"updated_at":1398271302,
"canceled_at":1401194748,
"payment": "<Object>",
"app_id":null,
"is_canceled":true,
"is_deleted":false,
"status":"active",
"client" : "<Object>"
},
"mode" : "test"
}
Delete
Request
curl https://api.paymill.com/v2.1/subscriptions/sub_d68bcdc8656a7932eb44 \
-u <YOUR_PRIVATE_KEY>: \
-d "remove=true" \
-X DELETE
subscription = Paymill::Subscription.find('sub_dea86e5c65b2087202e3')
subscription.remove()
SubscriptionService subscriptionService = paymillContext.getSubscriptionService();
subscriptionService.delete("sub_d68bcdc8656a7932eb44");
pm.subscriptions.delete("sub_d68bcdc8656a7932eb44").then(function(subscription) {
console.log("deleted subscription :" + subscription.status);
}, function(error) {
console.log("couldnt delete subscription:" + error);
});
subscription_service = paymill_context.get_subscription_service()
subscription_service.remove(subscription_without_offer)
$subscription = new Paymill\Models\Request\Subscription();
$subscription->setId('sub_dea86e5c65b2087202e3');
->setRemove(true);
$response = $request->delete($subscription);
SubscriptionService subscriptionService = paymillContext.SubscriptionService;
subscriptionService.DeleteAsync( "sub_dea86e5c65b2087202e3" ).Wait();
Response
{
"data" : {
"id":"sub_dea86e5c65b2087202e3",
"offer" : "<Object>",
"livemode":false,
"amount":3000,
"temp_amount":null,
"currency":"EUR",
"name":"Example Subscription",
"interval":"1 WEEK,MONDAY",
"trial_start":1398271207,
"trial_end":1399196896,
"period_of_validity":"2 YEAR",
"end_of_period":1461429607,
"next_capture_at":1399308007,
"created_at":1398271207,
"updated_at":1398271302,
"canceled_at":1401194748,
"payment": "<Object>",
"app_id":null,
"is_canceled":true,
"is_deleted":true,
"status":"active",
"client" : "<Object>"
},
"mode" : "test"
}
Sub objects
- subscription.offer returns an offer object
- subscription.payment returns a payment object for credit card or a payment object for direct debit
- subscription.client returns a client object
This function cancels or remove an existing subscription. The subscription will be directly terminated or deleted and no pending transactions will be charged. Deleted subscriptions will not be displayed.
Attributes
id: string
Unique identifier for the subscription
remove: boolean
cancel (false) or delete (true) a subscription
List Subscriptions
Request
curl https://api.paymill.com/v2.1/subscriptions \
-u <YOUR_PRIVATE_KEY>:
Paymill::Subscription.all()
SubscriptionService subscriptionService = paymillContext.getSubscriptionService();
PaymillList subscriptions = subscriptionService.list();
pm.subscriptions.list().then(function(pmlist) {
console.log(pmlist.items.length + " offers from total of " + pmlist.count);
}, function(error) {
console.log("couldnt list subscriptions:" + error);
});
subscription_service = paymill_context.get_subscription_service()
subscription_list = subscription_service.list()
$subscription = new Paymill\Models\Request\Subscription();
$response = $request->getAll($subscription);
SubscriptionService subscriptionService = paymillContext.SubscriptionService;
PaymillList subscriptions = subscriptionService.ListAsync().Result;
Response
{
"data" : [
{
"id":"sub_dc180b755d10da324864",
"offer" : "<Object>",
"livemode" : false,
"cancel_at_period_end" : false,
"trial_start": null,
"trial_end": null,
"next_capture_at": 1369563095,
"created_at" : 1341935490,
"updated_at" : 1349948303,
"canceled_at" : 1349948303,
"payment": "<Object>",
"client" : "<Object>",
"app_id" : null
}
],
"data_count" : "1",
"mode" : "test"
}
Sub objects
- subscription.offer returns an offer object
- subscription.payment returns a payment object for credit card or a payment object for direct debit
- subscription.client returns a client object
This function returns a JSON object with a list of subscriptions. In which order this list is returned depends on the optional parameter order. The following parameters can be used:
- count
- offset
- offer
- canceled_at
- created_at
Available filters:
offer=<offer id>
currency=<string> ISO 4217 formatted currency code
created_at=<timestamp> | <timestamp (from)>-<timestamp (to)>
updated_at=<timestamp> | <timestamp (from)>-<timestamp (to)>
canceled_at=<timestamp> | <timestamp (from)>-<timestamp (to)>
payment_type=creditcard|debit
is_deleted=1|0
mandate_reference=<string>
Export Subscriptions
List
Request
curl https://api.paymill.com/v2.1/subscriptions \
-u <YOUR_PRIVATE_KEY>: \
-H "Accept: text/csv"
# Not implemented yet
/* Not implemented yet */
/* Not implemented yet */
# Not implemented yet
/* Not implemented yet */
/* Not implemented yet */
Response
"id";"livemode";"amount";"temp_amount";"currency";"name";"interval";"trial_start";"trial_end";"period_of_validity";"end_of_period";"next_capture_at";"created_at";"updated_at";"canceled_at";"app_id";"is_canceled";"is_deleted";"status";"offer_id";"client_id";"payment_id"
"sub_c84aadd0c1c7529158ee";"";"499";"";"EUR";"Example Subscription";"3 WEEK";"1401983620";"1404575620";"";"";"";"1342427064";"1342427064";"1402640050";"";"";"";"active";"offer_1a5d80dc75db9b5c0c64";"client_33c8f8c13d759d00b144";"pay_2311e5a076ab0b9c2cdb0399"
This function returns CSV separated by semicolons, encapsulated by double quotes, with a list of subscriptions. In which order this list is returned depends on the optional parameter order. The following parameters can be used:
Available filters:
offer=<offer id>
currency=<string> ISO 4217 formatted currency code
created_at=<timestamp> | <timestamp (from)>-<timestamp (to)>
updated_at=<timestamp> | <timestamp (from)>-<timestamp (to)>
canceled_at=<timestamp> | <timestamp (from)>-<timestamp (to)>
payment_type=creditcard|debit|paypal
is_deleted=1|0
mandate_reference=<string>