Get Payment Method

Use this to retrieve a specific payment method by ID

Get Payment Method

GET https://api.sendwyre.com/v2/paymentMethod/:paymentMethodId

Path Parameters

Name
Type
Description

paymentMethodId

string

the ID of the payment method to retrieve

{
    "id": "PA-W7YN28ABCHT",
    "owner": "account:AC-XX38VYXUA84",
    "createdAt": 1542771684392,
    "name": "Plaid Checking 0000",
    "defaultCurrency": "USD",
    "status": "PENDING",
    "statusMessage": null,
    "waitingPrompts": [],
    "linkType": "LOCAL_TRANSFER",
    "beneficiaryType": "UNKNOWN",
    "supportsDeposit": true,
    "nameOnMethod": null,
    "last4Digits": "0000",
    "brand": null,
    "expirationDisplay": null,
    "countryCode": "US",
    "nickname": null,
    "rejectionMessage": null,
    "disabled": false,
    "supportsPayment": true,
    "chargeableCurrencies": [ "USD" ],
    "depositableCurrencies": [ "USD" ],
    "chargeFeeSchedule": null,
    "depositFeeSchedule": null,
    "minCharge": null,
    "maxCharge": null,
    "minDeposit": null,
    "maxDeposit": null,
    "documents": [],
    "blockchains": {},
    "liquidationBalances": {},
    "srn": "paymentmethod:PA-W7YN28ABCHT"
}

Examples

'''
This is a Python 3.7 Module that gets a payment method in
the test env
'''
import requests
import time
import os
import urllib.parse
import hashlib
import hmac
import json


class WyreApi:
    API_KEY = os.getenv("WYRE_APIKEY")
    SEC_KEY = os.getenv("WYRE_TOKEN")
    API_URL = "https://api.testwyre.com"
    API_VER2 = "/v2"
    API_GET_PAYMENT = "/paymentMethod"

    def calc_auth_sig_hash(self, url_body):
        # calculates a signature per Wyre API:
        # https://docs.sendwyre.com/docs/authentication#secret-key-signature-auth
        message, secret = bytes(
            url_body, 'utf-8'), bytes(WyreApi.SEC_KEY, 'utf-8')
        newhash = hmac.new(secret, message, hashlib.sha256)
        return newhash.hexdigest()

    def calcTimeStamp(self):
        # creates a timestamp to the millisecond
        return str(round(time.time() * 1000))

    def getPaymentMethod(self, paymentId):
        '''
            Get a payment method
            GET https://api.testwyre.com/v2/paymentMethod/:paymentMethodId
            params: post_data - Payment id
        '''
        if not paymentId:
            print("Need to send payment object with public Token")
            return

        params = {
            "timestamp": self.calcTimeStamp()
        }
        url = WyreApi.API_URL + WyreApi.API_VER2 + WyreApi.API_GET_PAYMENT + "/" + \
            paymentId + "?" + urllib.parse.urlencode(params, encoding="utf-8")

        headers = {
            "X-API-Key": WyreApi.API_KEY,
            "X-API-Signature": self.calc_auth_sig_hash(url)
        }

        response = requests.get(url, headers=headers)
        if response.status_code == 200:
            return json.loads(response.text)
        else:
            print(response)
            print(response.text)


if __name__ == "__main__":

    # initialize a Wyre Object
    wyre = WyreApi()

    paymentId = "PA_XXXXXXXXXX"
    payment = wyre.getPaymentMethod(paymentId)
    if payment:
        print(payment)

Last updated

Was this helpful?