Search code examples
braintree

Customer page URL


So, I have a Braintree customer id and access to the Braintree API (Python).

Knowing the customer id, how do construct URL for customer page on Braintree site? Something like https://sandbox.braintreegateway.com/merchants/{merchant_id}/customers/{customer_id}

Do I do this manually or there is an API for this?

This is my current solution:

if user.braintree_customer_id:
    bt_customer_url = braintree.Configuration.gateway().customer.config.base_merchant_url(
    ) + '/customers/%s' % user.braintree_customer_id
    url_parts = urlparse.urlsplit(bt_customer_url)
    if url_parts.netloc.startswith('api.'):
        url_parts = list(url_parts)
        url_parts[1] = url_parts[1][4:]
        bt_customer_url = urlparse.urlunsplit(url_parts)

Solution

  • I work at Braintree. There is no API call for the URL you are looking for, but you can structure it the way you have done. I can't guarantee that the url structure will never change, but it should be simple to update your script if it does.