Search code examples
restintegrationpayment-processingwirecard

Wirecard refund request


I'm trying to integrate wirecard payments and got a problem with the refund transaction.

With test username "70000-APILUHN-CARD" and password "8mhwavKVb91T" i've created payment processing and could see that it's successful. But when it comes to refund i get "405 method not allowed" result.

So the payment request looks like this:

POST https://wpp-test.wirecard.com/api/payment/register

With auth header including encoded username/password, content-type header, and body:

{
"payment" :
{
"merchant-account-id" : 
{
    "value" : merchantId
},
"request-id" : generatedRequestId,
"transaction-type" : "auto-sale",
"requested-amount" : 
{
  "value" : 1,
  "currency" : "EUR"
},
"payment-methods" : 
{
  "payment-method" : 
  [ 
    {"name" : "creditcard"} 
  ]
}
},
"options" :
{
"mode" : "seamless",
"frame-ancestor" : ancestorURL
}
}

After verification i could check that such transaction successfully completed and everything is fine, so i tried to make a refund request with the same headers:

POST https://api-test.wirecard.com/engine/rest/merchants/{merchantId}/payments/{transactionId}

and body:

{
   "payment":{
  "merchant-account-id":{
 "value":merchantId
  },
  "request-id":generatedRequestId,
  "requested-amount":{
     "value":1,
     "currency":"EUR"
  },
  "payment-methods":{
     "payment-method":[
        {
           "name":"creditcard"
        }
     ]
  },
  "card-token":{
     "token-id":"4819253888096002"
  },
  "card":{
     "expiration-month":"1",
     "expiration-year":"2023",
     "card-type":"visa"
  },
  "parent-transaction-id": parentTransactionId,
  "transaction-type":"refund-request"
   },
   "options":{
  "mode":"seamless",
  "frame-ancestor":ancestorURL
   }
}

Where all the data about card/card-token/etc were obtained from transaction state request.

Is there any mistakes in my refund request, or maybe there are some extra steps that i should perform?


Solution

  • There are a set of mistakes both in payment and in refund requests:

    • Payment request needs to have the "transaction-type" : "purchase" instead of "transaction-type" : "auto-sale"
    • Refund request should have the "transaction-type" : "refund-purchase" instead of "transaction-type" : "refund-request"
    • Also refund request should be sent at URL: "https://api-test.wirecard.com/engine/rest/payments/"

    (From wirecard support answer)