Braintree Webhooks: How can I notify customer that their subscription has been canceled - braintree

When I receive the subscription canceled webhook I can't retrieve the customers information via their payment info because it is deleted. Specifically I am trying to get the customers e-mail.

Full disclosure: I work at Braintree.
You can extract the customer id from the webhook. You didn't specify your client library language, but this is how you would do it in Ruby:
webhook_notification = Braintree::WebhookNotification.parse(
bt_signature_param, bt_payload_param
)
customer_id = webhook_notification.subject.subscription.transactions.first.customer.id
Pass the customer id from your webhook into a Customer.find call. Then inspect the result object to extract the email address.
More information on parsing webhooks here.
If you have any additional questions, feel free to reach out to Braintree support.

Related

Generate payment link and sms invoice using Zoho Books API

My application needs me to send a payment link to the customer via SMS. Once the payment is done, capture it and create a paid invoice and again send it via SMS to the customer. But I observed
There is no API to generate a payment link
Invoice cannot be sent via SMS.
Is there any other way of doing this?
There IS payment link API, it's just not documented.
If you POST something like
{
"customer_id": 123456000001234567,
"payment_amount": "1.00",
"expiry_time": "2022-04-30",
"description": "TEST"
}
to https://books.zoho.[eu]/api/v3/paymentlinks?organization_id=123456
you will get a new payment link with default contact email and status "generated". You can get URL from the response->payment_link->url.
Unfortunately, I didn't find out how to change the status of the payment link.
You can also send an email with POST to /api/v3/paymentlinks/{paymentlink_id}/email?organization_id=123456 if you specify subject, body and to_mail_ids array, and also do changes with PUT to i.e. expiry_time, but it would be great to know how to mark payments.

Is there a refund webhook for Braintree?

I didn't find some refund webhook in webhooks list.
Is Disbursment webhook something what can help me in this case https://developers.braintreepayments.com/reference/general/webhooks/disbursement/php ?
[Edit #1]: I've tested it and found that Disbursment webhook won't trigger after refund button is clicked in Braintree sandbox admin.
So I presume there is no webhook for refunds. For now I ended up with scheduled cron task to get refund transactions from the Braintree API:
$collection = Braintree_Transaction::search([
Braintree_TransactionSearch::createdAt()->greaterThanOrEqualTo($hourAgo),
Braintree_TransactionSearch::type()->is(Braintree_Transaction::CREDIT),
Braintree_TransactionSearch::refund()->is(true)
]);
P.S. hey, downvoters, why wouldn't you argument your opinion in comments? At least it could be helpful for someone who will find this thread.
Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.
Braintree does not have a webhook which fires when a refund is created. Webhooks are used for asynchronous events—in other words, events which are not triggered directly by an API call made by your integration. You get immediate feedback on the success or failure of a refund via the result object from the refund API call. Use that result to trigger whatever action you wanted to take when a refund occurs.
(If what you're actually looking for is to get information when a refund transaction disburses—i.e., when the funds for a refund are moved out of your bank account—then you actually do want a disbursement webhook. Disbursements represent the sum of your incoming and outgoing funds.)

Why would a Subscription have no Payment Method Token, and how can I map it to a Customer?

I'm trying to retrieve the customer who created a subscription via its payment_method_token, as described by Braintree developer agf. However, one of my subscriptions has no Payment Method Token. The field comes back as null from the API, and shows up as a blank space in the dashboard:
The docs offer no suggestion that this field could ever be empty. What can cause this to occur, and how can I find out which customer this subscription is associated with?
Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.
If a payment method is deleted and it has subscriptions connected to it, then the subscription will be canceled, the token will be disassociated from the subscription and you will see this in the control panel.
If there are transactions associated with the subscription, you can get customer information from the transaction objects. In this case, it seems like the subscription never created a transaction before it was deleted so unfortunately you won't be able to trace that back to a customer.

How to check if user subscription is up to date?

I create new customer with credit card using gateway.customer.create
I create new subscription for a customer using gateway.subscription.create
Now when my application starts I have to check if customers subscriptions is still valid. Is there any api endpoint that will allow me to do this?
I am looking for example for a method like this:
isUserSubscribed(customerId)
Maybe also something to get info in which plan user is subscribed (silver,gold,etc)
I work at Braintree. If you have more questions, feel free to reach out to our support team.
When you get a customer from Braintree, you get all of its credit cards and subscriptions:
customer = gateway.customer.find(customerId)
subscriptions = customer.credit_cards.flat_map(&:subscriptions)
You can then look at the customer's subscriptions to find any info you need.

Google Checkout subscription: How to identify the user

We are using Google Checkout - google handled subscriptions. In our html form we are using merchant-item-id parameter to store the subscription plan id and user id, so when Google Checkout send us back the notification for the new orders (merchant-item-id is there) we know what user for what plan to charge. So far this works perfect.
But now, when a month is passed, and Google Checkout start creating the reoccurring orders, there is no merchant-item-id parameter in the notifications they send. So we don't know what user for what plan is charged.
What should we use as user identifier, so we can handle properly the subscription on our site?
Any ideas?
Btw. I know about the "buyer-id" parameter which is send with each new order notification, but that will not work for us, because it is possible that the same google buyer is paying for several of our users accounts.
I would try putting some unique info in "shopping-cart.items.item-1.merchant-private-item-data" to something unique that I can identify the subscription by.
Nikolaj

Resources