简体   繁体   中英

Braintree Webhooks : transaction details via PHP

Braintree Payments supports Webhooks which return a subscription_id. I have been looking for a PHP code sample that will return the transaction details for a given subscription_id. The Braintree documentation provides no examples.

I know this code is wrong but I wanted to show some effort at a solution. :)

<?php
 $id = $_SERVER['QUERY_STRING'];
 require_once '_environment.php';
 $collection = Braintree_Transaction::search(array(
  Braintree_TransactionSearch::subscriptionId()->is($id)
 ));
 foreach ($collection AS $item) {
  echo "<li>" . $item->id;
 }
?>

I work at Braintree. If you need more help, you can always reach out to our support team .

You just need to get the subscription :

$subscription = Braintree_Subscription::find('a_subscription_id');

It has a list of all of its transactions :

$transactions = $subscription->transactions;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM