Create a new subscription

**POST**https://api.okepay.info/v1.0/Subscription/

PHP
<?php
// $instanceName is a part of the url where you access your okepay installation.
// https://{$instanceName}.okepay.info
$instanceName = 'YOUR_INSTANCE_NAME';

// $secret is the okepay secret for the communication between the applications
// if you think someone got your secret, just regenerate it in the okepay administration
$secret = 'YOUR_SECRET';

$okepay = new \Okepay\Okepay($instanceName, $secret);

$subscription = new \Okepay\Models\Request\Subscription();
$subscription->setUserId(1);
$subscription->setPsp(4);
$subscription->setPurpose('Test');
$subscription->setAmount(100);
$subscription->setCurrency('CHF');
$subscription->setPaymentInterval('P1M');
$subscription->setPeriod('P1Y');
$subscription->setCancellationInterval('P1M');
try {
    $response = $okepay->create($subscription);
    var_dump($response);
} catch (\Okepay\OkepayException $e) {
    print $e->getMessage();
}

 

QUERY PARAMS  
instance
string
REQUIRED
Your OkePay instance name
BODY PARAMS  
userId
string
REQUIRED
The contact id you got from webhook
psp
string
REQUIRED
The ID of the psp to use.
amount
string
REQUIRED
The amount of the payment to fire in cents.
currency
string
REQUIRED
The ISO Code of the currency of the payment
purpose
string
REQUIRED
The payment purpose. What is the payer paying for?
paymentInterval
string
REQUIRED
The payment interval as string. (see PHP documentation of date interval for format)
period
string
REQUIRED
The subscription's period as string. (see PHP documentation of date interval for format)
cancellationInterval
string
REQUIRED
The interval of cancellation as string. (see PHP documentation of date interval for format)
referenceId
string
The internal reference id. (Will be sent back with Webhook, can be used as indetification)

Experimental documentation state

This functionality is already in productional use, but the documentation might contain some errors. Please contact us if you are interested in handling Subscriptions though your own application