Create a Smart Transaction for Subscription
After we have created the Subscription Plans for you, we create a first Smart Transaction for one of it.
These are the few little differences to the creation of a typical Smart Transaction:
a special checkout template for subscriptions;
a special basket item for the subscription.
In our example we assume a plan for a newspaper:
POST /api/v2/Smart/Transactions HTTP/1.1
Host: connect-testing.secuconnect.com
Authorization: Bearer qb56tjj1bcvo9n2nj4u38k84lo
Content-Type: application/json
Accept: application/json
{
"is_demo"
:
true
,
"contract"
: {
"id"
:
"GCR_9OIH9JOL8KIV5PFJBEOS2NN8TCM1DF"
},
"customer"
: {
"contact"
: {
"forename"
:
"Raina"
,
"surname"
:
"Mustermann"
,
"address"
: {
"street"
:
"Musterstr."
,
"street_number"
:
"771"
,
"additional_address_data"
:
"App. 197"
,
"postal_code"
:
"09999"
,
"city"
:
"North Alphonsofurt"
,
"country"
:
"DE"
},
"email"
:
"Jacinto_Daugherty@example.net"
,
"mobile"
:
"+491775555555"
,
"phone"
:
"+495555555555"
,
"dob"
:
"1965-12-31"
}
},
"intent"
:
"sale"
,
"basket"
: {
"products"
: [
{
"id"
: 1,
"item_type"
:
"subscription"
,
"desc"
:
"Abo Beispielzeitung (incl. Tablet PC für 99 EUR, 3 Probewochen á 99 ct, dann 9,90 EUR p. M.)"
,
"quantity"
: 1,
"priceOne"
: 9900,
"tax"
: 19,
"plan_id"
:
"PLN_9XE5CDX7JKKFP5Q9UH9S2IJ6BOL56T"
,
"start_at"
:
"2020-03-04T00:00:00Z"
}
]
},
"basket_info"
: {
"sum"
: 9900,
"currency"
:
"EUR"
},
"payment_context"
: {
"auto_capture"
:
true
},
"application_context"
: {
"checkout_template"
:
"COT_QV85D3F542XWFFJYCSWG00W400YWAT"
,
"return_urls"
: {
"url_success"
:
"https://shop.example.com/payment-success"
,
"url_error"
:
"https://shop.example.com/payment-failure"
,
"url_abort"
:
"https://shop.example.com/payment-abort"
},
}
}
Smart Transactions for subscriptions can only have one basket item. These are the details:
Field |
Explanation |
id |
A reference ID to manage the basket |
item_type |
Must be "subscription" |
desc |
A brief text description of the basket item |
quantity |
Must be 1 |
priceOne |
The amount to be authorised. We recommend authorising the highest price to expect for a single payment. This is usually the setup fee plus the first single rate, or the highest rate being paid later. The amount authorised by PayPal may differ. The actual payments are derived from the Subscription Plan only. |
tax |
The VAT rate |
plan_id |
The ID of the Subscription Plan |
start_at |
The start date and time of the subscription |
Monetary amounts are expressed in the smallest currency unit (e. g. Euro Cent).
The subscriber is passed in the field customer. If it shall be delivered to another address, you can pass another Payment Customer object to the field shipping_address.
The checkout_template (line 53) has the fixed value COT_QV85D3F542XWFFJYCSWG00W400YWAT for subscriptions. There is another value for ordinary payments.
If everything is fine, the API responds with 200 OK:
HTTP/1.1 200 OK
Content-Type: application/json
...
{
"object"
:
"smart.transactions"
,
"id"
:
"STX_3MTRMHGGS2NT543DYK2VT3MUMZ6BA2"
,
"merchant"
: {
"object"
:
"general.merchants"
,
"id"
:
"MRC_G8SE48FRHVITKILAPNCEDU0NUD55W8"
,
"companyname"
:
"Secupay Test-Shop"
},
"contract"
: {
"object"
:
"general.contracts"
,
"id"
:
"GCR_9OIH9JOL8KIV5PFJBEOS2NN8TCM1DF"
},
"customer"
: {
"object"
:
"payment.customers"
,
"id"
:
"PCU_3ZZ6598CB2NT543DSDZUH5CQGKQ4A2"
,
"contact"
: {
"forename"
:
"Raina"
,
"surname"
:
"Mustermann"
,
"name"
:
"Raina Mustermann"
,
"address"
: {
"street"
:
"Musterstr."
,
"street_number"
:
"771"
,
"additional_address_data"
:
"App. 197"
,
"postal_code"
:
"09999"
,
"city"
:
"North Alphonsofurt"
,
"country"
:
"DE"
},
"email"
:
"Jacinto_Daugherty@example.net"
,
"mobile"
:
"+491775555555"
,
"phone"
:
"+495555555555"
,
"dob"
:
"1965-12-31T00:00:00+01:00"
}
},
"transactions"
: [],
"created"
:
"2020-11-06T11:09:31+01:00"
,
"status"
:
"created"
,
// ...
"intent"
:
"sale"
,
"basket"
: {
"products"
: [
{
"id"
: 1,
"item_type"
:
"subscription"
,
"desc"
:
"Abo Beispielzeitung (incl. Tablet PC für 99 EUR, 3 Probewochen á 99 ct, dann 9,90 EUR p. M.)"
,
"quantity"
: 1,
"priceOne"
: 9900,
"tax"
: 19,
"plan_id"
:
"PLN_9XE5CDX7JKKFP5Q9UH9S2IJ6BOL56T"
,
"start_at"
:
"2020-03-04T00:00:00Z"
}
]
},
"basket_info"
: {
"sum"
: 9900,
"currency"
:
"EUR"
},
"is_demo"
:
true
,
// ...
"payment_context"
: {
"auto_capture"
:
true
},
"application_context"
: {
// ...
"return_urls"
: {
"url_success"
:
"https://shop.example.com/payment-success"
,
"url_error"
:
"https://shop.example.com/payment-failure"
,
"url_abort"
:
"https://shop.example.com/payment-abort"
},
// ...
"checkout_template"
:
"COT_QV85D3F542XWFFJYCSWG00W400YWAT"
},
// ...
"payment_links"
: {
"creditcard"
:
"https://pay-dev.secuconnect.com?payment-method=creditcard&stx=STX_3EM6ECE9P2P6CQVYWN0SQH9HGFZ6A4&contract=GCR_82LCT9C99SICEQXO0F309J55UC1YUD&server=testing"
,
"debit"
:
"https://pay-dev.secuconnect.com?payment-method=debit&stx=STX_3EM6ECE9P2P6CQVYWN0SQH9HGFZ6A4&contract=GCR_82LCT9C99SICEQXO0F309J55UC1YUD&server=testing"
,
"paypal"
:
"https://pay-dev.secuconnect.com?payment-method=paypal&stx=STX_3EM6ECE9P2P6CQVYWN0SQH9HGFZ6A4&contract=GCR_82LCT9C99SICEQXO0F309J55UC1YUD&server=testing"
}
}
Now the transaction is ready to be authorised for payment.