The “user” parameter is to follow up the user who changes the payment method.
2. Send request to update payment method
An HTTP POST request must be sent to the update payment method endpoint, with the JSON containing the subscription data.
Once the request to update the payment method has been sent and successfully made, a JSON object is obtained in response.
When receiving this response, the expected parameter from the JSON object is the “body”, since it contains the result of the payment method update. The following code shows an example of the response received.
- {
- "code": 200,
- "status": "SUCCESS",
- "result": {
- "id": "3",
- "merchant_id": "143b28c9-32ad-4635-8ed8-d6abfb6863a0",
- "status": "ACTIVE",
- "user_id": "Aaron",
- "user_type": 1,
- "card_tokens": [
- "bf0bd94a-a4e7-4ef6-96c6-2350f3963f93"
- ],
- "purchase_order": {
- "secret": "QUY5MzBEMkRDMzVCMDFCRDc2NzEwRjZCQjE3NjhFNkE0NjhEQ0MxRjkxQzkzMjAwNzVDNUVGNkY5RTc0N0M0NzkzNUEyQUZFQjczMEYyODEyRjJEMDc5Q0ExNTk1NTA0NjdCMkNBODg1N0Q4MzY2MjI0NEREMUVGQjk4NTcwMzg=",
- "terminal": "deKokoTest-eb29-BNCR-CRC",
- "description": "subscription description",
- "currency": "CRC",
- "initialPayment": {
- "amount": 100,
- "description": "some set up description"
- },
- "subscription": [
- {
- "startDate": 1536991200000,
- "endDate": 1544853600000,
- "amount": 10,
- "cadence": {
- "mode": "EVERY",
- "unit": "MONTH",
- "every": 1,
- "day": 15
- }
- }
- ],
- "optional": {
- "key": "value",
- "key1": "value1"
- }
- },
- "next_payment": null,
- "enabled": true,
- "inserted_at": "2018-12-21T20:55:06.299Z",
- "updated_at": "2018-12-21T22:01:11.341Z",
- "general_info": {
- "user": "UserBot"
- }
- },
- "errors": []
- }