Skip to content

Instantly share code, notes, and snippets.

@akmalhazim
Created May 19, 2019 01:07
Show Gist options
  • Save akmalhazim/983b5e0022cda6d032aa39ed007fd303 to your computer and use it in GitHub Desktop.
Save akmalhazim/983b5e0022cda6d032aa39ed007fd303 to your computer and use it in GitHub Desktop.
<?php
namespace App\Services;
use App\Traits\Braintree\Helpers;
use App\Traits\Braintree\Base;
use App\User;
use App\PaymentMethod;
use App\Jobs\PaymentMethod\DeleteCard;
use Braintree_Gateway;
class BraintreeService implements \App\Contracts\PaymentGateway {
use Base;
use Helpers;
protected $gateway;
protected $user;
/**
* Construct new Braintree instance
*/
public function __construct() {
$this->gateway = new Braintree_Gateway([
'environment' => config('braintree.environment', 'sandbox'),
'merchantId' => config('braintree.merchant_id'),
'publicKey' => config('braintree.public_key'),
'privateKey' => config('braintree.private_key')
]);
}
/**
* Set user
*/
public function setUser(User $user) {
$this->user = $user;
return $this;
}
/**
* Return Braintree SDK Customer Instance
*/
public function customer() {
return $this->gateway->customer();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment