Skip to main content
Version: Lastest

Cycle callback

The AppotaPay system calls back the results of the cycle to the partner's system

Note
  • Using the signature parameter to check the integrity of the received data, the partner creates a signature from the data received by AppotaPay and then compares it with the signature parameter sent by AppotaPay.

Web callback

AppotaPay will send the results via the API URL of the partner sending AppotaPay for configuration, the partner server checks the data integrity through the signature parameter then updates the status of cycle.

{
"Content-Type": "applicaton/json"
}

Request params

Method: POST

ParamTypeDescription
dataStringTransaction information is encode with base64encode & json_encode format
signatureStringSignature to check data

signature = HMAC_SHA256(data, secretKey)

timeStringResponse time

Decode

  1. Partners use the Base64Decode function to decode data in string form.
  2. Use the JSON_Decode function to decode the data a second time in json form.
ParamRequiredTypeDescription
eventRequiredString

Event:

- subscription.cycle.created: create cycle successfully

- subscription.cycle.succeeded: charge for the cycle successfully

- subscription.cycle.retrying: charge for the cycle unsuccessfully, so it's necessary to attempt the next time

- subscription.cycle.failed: charge for the cycle unsuccessfully

- subscription.cycle.force_attempt_failed: force cycle attempt unsuccessfully

dataRequiredObjectData
data.cycleIdRequiredStringCycle ID
data.planIdRequiredStringPlan ID
data.cycleNumberRequiredIntegerCycle number
data.currencyRequiredIntegerCurrency unit
data.amountRequiredIntegerAmount
data.attemptCountRequiredIntegerNumber of times the recurring action has been attempted for this recurring cycle object.
attemptDetailsRequiredArrayDetailed information of each action attempts
attemptDetails.*.attemptNumberRequiredIntegerA numbering that tracks the order of cycle attempts. The first attempt will be 1 and subsequent attempts are dependent on retry configuration
attemptDetails.*.createdAtRequiredStringISO 8601 timestamp for attempted actions
attemptDetails.*.attemptIdRequiredIntegerAttempt ID
attemptDetails.*.typeRequiredString

Type of attempt

- INITIAL: the first attempt with each cycle

- RETRY: attempt with type INITIAL failed, then subsequent retry is set

- PAYMENT_LINK: if you use paymentLinkForFailedAttempt while creating a plan, attempts using payment link will have this type

- FORCED: if you perform a force cycle through the API we provide

attemptDetails.*.statusRequiredString

Attempt status:

- PENDING: payment cycle is in progress

- SUCCESS: attempt cycle successfully

- FAILED: attempt cycle unsuccessfully

attemptDetails.*.nextRetryTimeRequiredStringISO 8601 Estimated timestamp for next retry
data.scheduledAtRequiredStringSchedule timestampt (format ISO-8601)
data.statusRequiredString

Cycle status:

- SCHEDULED: cycle has been initialized and waiting for execution time

- PENDING: recurring payment is in progress (cycle cannot be updated)

- RETRYING: cycle needs to charge again

- FAILED: all attempts/retries configured for the cycle have failed

- SUCCEEDED: cycle is charge successfully

- CANCELLED: cycle is canceled due to request from merchant

data.createdAtRequiredStringCycle creation time (standard format: ISO-8601)
data.updatedAtRequiredStringLast updated time (standard format: ISO-8601)

Response format

  • The partner needs to respond to AppotaPay to confirm that they have received the result
  • The response is considered successful when HTTP code = 200