Skip to content
Loic Teixeira edited this page May 28, 2018 · 1 revision

Welcome to the eway-rapid-python wiki!

Snippets

How to Refund an eway transaction?

By Devendra Kavthekar

import requests

environment = 'test'
environment = 'production'

_api_key = 'xxxxxxxxxxxxxxxx' #Eway - API Key
_api_password = 'zzzz' #Eway - API Password

trans_type = 'Refund'

refund_amount = 100 # Refund amount

refund_payload = { 
   "TotalAmount": refund_amount, 
   "InvoiceNumber": "Inv 21540", 
   "InvoiceDescription": "Individual Invoice Description", 
   "InvoiceReference": "513456",
   "CurrencyCode": "AUD"
}

transaction_id = 17799963 #Refund against which eway transaction

if environment == 'test':
    refund_url = r'https://api.sandbox.ewaypayments.com/Transaction/'+ transaction_id +'/Refund'
else:
    refund_url = r'https://api.ewaypayments.com/Transaction/'+ transaction_id +'/Refund'

json_payload = {
    'Customer': 'XYZ Customer',
    'Refund': refund_payload,
    'ShippingAddress': 'ShippingAddress',
    }

response = requests.post(refund_url, auth=(_api_key, _api_password), data=json_payload, headers={'Content-Type': 'application/json'})

return {'response': response}
Clone this wiki locally