diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e94933..56d2e72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## 2.3.5 - 2020-03-26 + +### Fixed + +- Fixed project config bug + ## 2.3.4 - 2020-03-12 ### Changed diff --git a/composer.json b/composer.json index c23230d..234098a 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "kuriousagency/commerce-braintree", "description": "Braintree gateway for Craft Commerce", "type": "craft-plugin", - "version": "2.3.4", + "version": "2.3.5", "keywords": [ "craft", "cms", diff --git a/src/gateways/Gateway.php b/src/gateways/Gateway.php index 095837d..5e3f6b5 100644 --- a/src/gateways/Gateway.php +++ b/src/gateways/Gateway.php @@ -85,7 +85,7 @@ class Gateway extends BaseGateway public $sendCartInfo; - public $gateway; + private $gateway; private $customer; @@ -508,6 +508,12 @@ public function getSubscriptionPlans(): array return $output; } + public function createSubscription($data) + { + return (object)$this->gateway->subscription()->create($data); + + } + public function subscribe(User $user, BasePlan $plan, SubscriptionForm $parameters): SubscriptionResponseInterface { $source = $this->getPaymentSource($user->id); @@ -516,12 +522,14 @@ public function subscribe(User $user, BasePlan $plan, SubscriptionForm $paramete } $plan = new Plan($plan); - $response = (object)$this->gateway->subscription()->create([ + $data = [ 'paymentMethodToken' => $source->token, 'planId' => $plan->reference, 'price' => $plan->price, 'merchantAccountId' => $this->merchantAccountId[$plan->getCurrency()], - ]); + ]; + + $response = $this->createSubscription($data); if (!$response->success) { //Craft::dd($response);