Subscription
We provide the option to schedule your payments so that the amount will be deducted automatically without the customer's intervention by adding a schedule id to the transaction.
Enabling Subscription
You have two methods to implement scheduling.
1- Managed by Your System
To have control over the scheduling process and trigger it from your system, you can modify it in the Authentication request, recurring_init = true
to indicate that this is a scheduled transaction.
If the customer approves the subscription plan, in the response, you will receive recurring_init_trans_id
and recurring_token
, which you need to store in your system to make recurring requests using them in the future.
Creating Recurring Transaction
If you have the recurring_init_trans_id
and recurring_token
stored on your system, you can send a request to /api/v1/payment/reсurring, if the transaction is successful, the amount will be deducted from the customer without the need for his presence.
Sample Request To Indicate a Subscription Transaction
{
"merchant_key": "1d903dfda0-e8dc-11ed-bbba-d60edfb1bd8d8",
"operation": "purchase",
"order": {
"number": "order-1234",
"amount": "19",
"currency": "SAR",
"description": "Important gift"
},
"cancel_url": "https://test.com",
"success_url": "https://test.com",
"customer": {
"name": "Amer Mo",
"email": "aalshabebei@dineropay.com"
},
"billing_address": {
"country": "SA",
"state": "string",
"address": "string",
"city": "string",
"house_number": "string",
"zip": "string",
"phone": "+96600000000"
},
"recurring_init": true,
"hash": "416830ec3be6ac7fd6ca539a4e9dbdd5c8971097d"
}
Sample Response
id=f0a51dfa-fc43-11ec-8128-0242ac120004
order_number=order-1234
order_amount=3.01
order_currency=SAR
order_description= gift
type=sale
status=success
card=411111****1111
card_expiration_date=12/2022
schedule_id=null
recurring_init_trans_id=f0a51dfa-fc43-11ec-8128-0242ac120004
recurring_token=f0e24964-fc43-11ec-a7e0-0242ac120004
date=2022-07-05 09:22:09
hash=6d8d440e25bdfc5288616ce567496948d2562852
customer_name=Khalid Nasser
customer_email=success@gmail.com
customer_country=SA
customer_state=Najd
customer_city=Riyadh
customer_address=exit 10
customer_ip=10.10.10.2
2- Managed By The Payment Gateway
To ease your transactions, you can let the scheduling be handled by us, the process will be similar to the previous method. However, this time there is no need for your system to schedule the recurring transaction it will be maintained by us; you will receive notification calls for each payment.
First you will need to create a schedule object , there are two ways to create it .
Dashboard
Once you log in to the dashboard, on the left sidebar, you will see Schedules, click on that, and it will navigate you to the Recurring Schedules page; on the top left corner, you will see a plus button, click on it to create a schedule
object.
API
You can create a schedule
object using the API by sending a request to https://api.dineropay.com/post/.
This request should have the content type as Content-Type: multipart/form-data
Example Request To Create a Schedule Id
https://api.dineropay.com/post?action="CREATE_SCHEDULE",&"client_key"="1dfeda0-e8dc-11ed-hhba-d60e6b1bd8d8",&"name"="for testing scheduled payment through api",&"inverval_length"="1",&"interval_unit"="day",&"payment_count"="3",&"hash"="0D6F1971358364EEFE3E3A31928A37F8"&}=
Create a Recurring Payment
Now that you have the schedule id, you can use it in future requests to indicate that this transaction should be scheduled and handled by us in case you provide the schedule_id
; otherwise, it will be handled by your system.
In the request body, add the parameters recurring_init = true
and schedule_id = xxxxx-xxx
in case you want the scheduling to be handled by the gateway.
Refer to the Payment section for more details.
The schedule object can be used in more than one transaction.
Keep in mind to count the first initial transaction for the recurring payments.