Process Refund Request

To process a refund, SHOPLINE will make an HTTP call to the latest refund URL set by your payment app, using a predetermined parameter protocol. The following diagram illustrates how the refund process between your payment app and SHOPLINE works:

image.png

  1. The merchant requested a refund.
  2. SHOPLINE sends a backend request to the payment app specifying a refund.
  3. The payment app handles refunds.
  4. The payment app completes the refund process and returns the refund result to SHOPLINE.
  5. SHOPLINE updates refund status.

Refund Status Flow

For a refund request initiated by a payment app, we expect its refund status to flow as follows:

image.png

Request refund interface

When requesting a refund, Shopline will request the refund Url provided by you through Http-Post;

Example request header

Correnspods to Http Request Header

pay-api-version: 1.0.0
pay-api-idempotency-key: TESTKEYKEYKEY
pay-api-signature: SIGNSIGNSIGN
pay-api-timestamp: 1665632758606000
FieldIs it required?Description
pay-api-versionYesThe API VERSION you filled in when configuring the payment app extension
pay-api-idempotency-keyYesidempotent key
pay-api-signatureYesSignature value
pay-api-timestampYesTimestamp when the request was initiated

Request body Example

Corresponds to Http Request Body

{
"refundTransactionId": "test_9b20051a834a",
"channelOrderTransactionId": "test_23ad103a2d40",
"amount": 60,
"currency": "test_999f91411796",
"notifyUrl": "test_6682bc9bbd0e",
"reason": "test_41b3cb8a59e7"
}
FieldTyperequired?Description
refundTransactionIdstringYesRefund serial number
channelOrderTransactionIdstringYesChannel ID of the payment order
amountintegerYesAmount of refund
currencystringYesCurrency of refund
notifyUrlstringYesNotification URL for asynchronous results
reasonstringNoreason for refund

Response header example

SHOPLINE must receive the expected result before it considers the call successful. If the expected result is not returned, then SHOPLINE will re-initiate the request with the same parameters after a certain period of time until it finally gets the expected response or reaches Maximum number of retries;

corresponding to Http Response Header

pay-api-signature: SIGNSIGNSIGN
FieldIs it required?Description
pay-api-signatureyesSignature value

Response body example

Corresponds to Http Responese Body

{
"refundTransactionId": "test_b2d02e4cf198",
"channelRefundTransactionId": "test_8bc8a9f59480",
"channelOrderTransactionId": "test_93d9fea7eda2",
"amount": 80,
"currency": "test_cea487102235",
"refundStatus": "test_c07b9a2944be",
"returnCode": "test_ee09856d2a50",
"returnMessage": "test_d7d75b56590f",
"returnMessageId": "test_adbad71be1c1"
}
FieldTyperequired?Description
refundTransactionIdstringYesRefund serial number
channelRefundTransactionIdstringYesChannel side refund ID
channelOrderTransactionIdstringYesChannel ID of the payment order
amountintegerYesrefund amount
currencystringYesRefund Currency
refundStatusstringYesRefund status
  • PROCESSING
  • FAILED
  • SUCCEEDED
  • returnCodestringYesinterface status code
    SUCCESS
    returnMessagestringNoFailure reasons
    returnMessageIdstringNoChannel response identifier UUID, such as traceId

    Synchronize refund results

    After receiving the refund request, if you cannot process it to the final state synchronously, then you can use the following two methods to synchronize the refund result with SHOPLINE. SHOPLINE recommends that you provide both methods:

    1. Provide a refund query URL, then Shopline will initiate an HTTP call through the refund query URL at a certain frequency after successfully calling the refund URL, and try to get the result of the payment until the final state is obtained or the timeout is reached;
    2. Actively call our refund notification Webhook interface until a correct response is returned;

    Sample Refund Query Request Header

    Corresponds to Http Request Header

    pay-api-version: 1.0.0
    pay-api-idempotency-key: TESTKEYKEYKEY
    pay-api-signature: SIGNSIGNSIGN
    pay-api-timestamp: 1665632758606000
    FieldIs it required?Description
    pay-api-versionYesThe API VERSION you filled in when configuring the payment app extension
    pay-api-idempotency-keyYesidempotent key
    pay-api-signatureYesSignature value
    pay-api-timestampYesTimestamp when the request was initiated

    Sample Refund Query Request Parameters

    Corresponds to Http Request Query

    refundTransactionId = SLASDJK12312131
    FieldIs it required?Description
    refundTransactionIdYesRefund serial number

    Sample Refund Query Response Header

    Corresponds to Http Response Header

    pay-api-signature: SIGNSIGNSIGN
    FieldIs it required?Description
    pay-api-signatureYesSignature Value

    Sample Refund Query Response Body

    Corresponds to Http Response Header Body

    FieldTypeIs it required?Description
    refundTransactionIdstringYesRefund serial number
    channelRefundTransactionIdstringYesThe refund serial number of the channel
    channelOrderTransactionIdstringYesChannel ID of the channel payment order
    amountintegerYesrefund amount
    currencystringYesRefund currency
    refundStatusstringYesRefund status
  • PROCESSING
  • FAILED
  • SUCCEEDED
  • failCodestringNOfailure error code
    failMessagestringNOFailure reasons
    returnCodestringYesinterface status code
    SUCCESS
    returnMessagestringNOFailure reasons
    returnMessageIdstringNOChannel response identifier UUID, such as traceId

    Proactively notify Shopline of the refund result

    You can actively notify Shopline of the refund result by calling the OpenApi interface of the refund result notification;

    Was this article helpful to you?