hypejunction / hypebraintreepayments
Braintree client for Elgg
Installs: 9
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Type:elgg-plugin
pkg:composer/hypejunction/hypebraintreepayments
Requires
- php: >=7.0
- braintree/braintree_php: ^3.29
- composer/installers: ~1.0
This package is not auto-updated.
Last update: 2020-01-18 13:42:12 UTC
README
A wrapper for Braintree's PHP SDK
Webhooks
Configure your Braintree application to send webhooks to https://<your-elgg-site>/payments/braintree/webhooks
To digest a webhook, register a plugin hook handler:
elgg_register_plugin_hook_handler('subscription_went_past_due', 'braintree', HandleExpiredSubscription::class); class HandleExpiredSubscription { public function __invoke(\Elgg\Hook $hook) { $webhook = $hook->getParam('webhook'); /* @var $webhook \Briantree\WebhookNotification */ // ... do stuff return $result; // data to send back to braintree } }
Card Input
To display a card input:
// Card number, expiry and CVC echo elgg_view_field([ '#type' => 'braintree/card', '#label' => 'Credit or Debit Card', 'required' => true, ]);
You can then retrieve the value of the Braintree token in your action:
$token = get_input('braintree_token'); // Corresponds to payment_method_nonce elgg()->{'payments.gateways.braintree'}->pay($transaction, [ 'braintree_token' => $token, ]);