{"metadata":{"image":[],"title":"","description":""},"api":{"url":"/v2/paymentMethod/:paymentMethodId","auth":"required","results":{"codes":[{"status":200,"language":"json","code":"true","name":""}]},"settings":"","params":[{"name":"paymentMethodId","type":"string","default":"","desc":"ID of the payment method to be removed","required":true,"in":"path","ref":"","_id":"5c0589aea94f0f0209b6fb31"}],"examples":{"codes":[{"code":"'''\nThis is a Python 3.7 Module that deletes a payment methods in\nthe test env\n'''\nimport requests\nimport time\nimport os\nimport urllib.parse\nimport hashlib\nimport hmac\nimport json\n\n\nclass WyreApi:\n    API_KEY = os.getenv(\"WYRE_APIKEY\")\n    SEC_KEY = os.getenv(\"WYRE_TOKEN\")\n    API_URL = \"https://api.testwyre.com\"\n    API_VER2 = \"/v2\"\n    API_DELETE_PAYMENT = \"/paymentMethod\"\n\n    def calc_auth_sig_hash(self, url_body):\n        # calculates a signature per Wyre API:\n        # https://docs.sendwyre.com/docs/authentication#secret-key-signature-auth\n        message, secret = bytes(\n            url_body, 'utf-8'), bytes(WyreApi.SEC_KEY, 'utf-8')\n        newhash = hmac.new(secret, message, hashlib.sha256)\n        return newhash.hexdigest()\n\n    def calcTimeStamp(self):\n        # creates a timestamp to the millisecond\n        return str(round(time.time() * 1000))\n\n    def deletePaymentMethod(self, payment_id):\n        '''\n            Delete a payment method\n            DELETE https://api.testwyre.com/v2/paymentMethods\n        '''\n        if not payment_id:\n            print(\"Need to add a payment id\")\n            return\n\n        params = {\n            \"timestamp\": self.calcTimeStamp()\n        }\n        url = WyreApi.API_URL + WyreApi.API_VER2 + WyreApi.API_DELETE_PAYMENT \\\n            + \"/\" + payment_id + \"?\" + \\\n            urllib.parse.urlencode(params, encoding=\"utf-8\")\n\n        headers = {\n            \"X-API-Key\": WyreApi.API_KEY,\n            \"X-API-Signature\": self.calc_auth_sig_hash(url)\n        }\n\n        response = requests.delete(url, headers=headers)\n        if response.status_code == 200:\n            print(response)\n            return json.loads(response.text)\n        else:\n            print(response)\n            print(response.text)\n\n\nif __name__ == \"__main__\":\n\n    # initialize a Wyre Object\n    wyre = WyreApi()\n    payment_id = \"PA_GBU9DDFFDD4\"\n    # Get all payment methods\n    payments = wyre.deletePaymentMethod(payment_id)\n    if payments:\n        print(payments)\n","language":"python"}]},"method":"delete","apiSetting":"5c50b085aae6150014b3e80e"},"next":{"description":"","pages":[]},"title":"Delete Payment Method","type":"endpoint","slug":"delete-payment-method","excerpt":"","body":"","updates":[],"order":7,"isReference":true,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"5c0588378f19e601cec8a8c4","project":"550f74bb6fc8130d0038aad3","version":{"version":"3","version_clean":"3.0.0","codename":"","is_stable":true,"is_beta":true,"is_hidden":false,"is_deprecated":false,"categories":["550f75de61d9d30d00af9e02","551027e38579861900a86698","551029e08579861900a8669a","551029e7498062190006328a","5bc633a722d682005c9ad9e4","5bc633b08c4b0b000d6a7eaa","5bc633b48f3ff600626e3e18","5bc63538e5a6ba000d22ee6d","5bc63587a18a6b000decd295","5bc635c0937fcb0056223d9c","5bc6360f42f41800319aeaa6","5be5d13ff1d319002baca9ce","5be5d2287cd14d00291fbfdb","5be8b3b09f7cb70023c56a39","5be8b3cbb910100044e20206","5c1d769a4f6aed001fe527f0","5c402942010f0d001496dded"],"_id":"550f75de61d9d30d00af9e01","__v":17,"releaseDate":"2015-03-23T02:09:34.221Z","project":"550f74bb6fc8130d0038aad3","createdAt":"2015-03-23T02:09:34.221Z","forked_from":"550f74bb6fc8130d0038aad6"},"category":{"sync":{"isSync":false,"url":""},"pages":[],"title":"Payment Methods","slug":"payment-methods","order":7,"from_sync":false,"reference":true,"_id":"5bc633b08c4b0b000d6a7eaa","project":"550f74bb6fc8130d0038aad3","version":"550f75de61d9d30d00af9e01","createdAt":"2018-10-16T18:53:36.184Z","__v":0},"user":"56ddd4424acab82000ae9d30","createdAt":"2018-12-03T19:47:03.379Z","__v":4,"parentDoc":null}