Skip to content

Commit a56b463

Browse files
author
Konstantinos Christofilos
committed
Cancel subscription
1 parent 6e2a435 commit a56b463

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

src/Gateway.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,4 +239,14 @@ public function createSubscription(array $parameters = array())
239239
{
240240
return $this->createRequest('\Omnipay\Braintree\Message\CreateSubscriptionRequest', $parameters);
241241
}
242+
243+
/**
244+
* @param string $subscriptionId
245+
*
246+
* @return \Omnipay\Common\Message\AbstractRequest
247+
*/
248+
public function cancelSubscription($subscriptionId)
249+
{
250+
return $this->createRequest('\Omnipay\Braintree\Message\CancelSubscriptionRequest', array('id' => $subscriptionId));
251+
}
242252
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
namespace Omnipay\Braintree\Message;
3+
4+
use Omnipay\Common\Message\ResponseInterface;
5+
6+
/**
7+
* Cancel Subscription Request
8+
*
9+
* @method CustomerResponse send()
10+
*/
11+
class CancelSubscriptionRequest extends AbstractRequest
12+
{
13+
/** @var string */
14+
protected $subscriptionId;
15+
16+
/**
17+
* Get the raw data array for this message. The format of this varies from gateway to
18+
* gateway, but will usually be either an associative array, or a SimpleXMLElement.
19+
*
20+
* @return mixed
21+
*/
22+
public function getData()
23+
{
24+
return $this->subscriptionId;
25+
}
26+
27+
/**
28+
* Send the request with specified data
29+
*
30+
* @param mixed $data The data to send
31+
* @return ResponseInterface
32+
*/
33+
public function sendData($subscriptionId)
34+
{
35+
$response = $this->braintree->subscription()->cancel($subscriptionId);
36+
37+
return $this->response = new SubscriptionResponse($this, $response);
38+
}
39+
40+
public function setId($subscriptionId)
41+
{
42+
$this->subscriptionId = $subscriptionId;
43+
}
44+
}

0 commit comments

Comments
 (0)