From d09ce42b182324c07033bddcf3fbe2953cfc6c77 Mon Sep 17 00:00:00 2001 From: Rushi Vishavadia Date: Sat, 1 Oct 2016 00:57:39 +0530 Subject: [PATCH 1/2] XOL-3125 Support for the reverse_transfer flag See https://stripe.com/docs/connect/payments-fees\#issuing-refunds --- src/Message/RefundRequest.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/Message/RefundRequest.php b/src/Message/RefundRequest.php index 7e513e51..e3c39532 100644 --- a/src/Message/RefundRequest.php +++ b/src/Message/RefundRequest.php @@ -78,6 +78,31 @@ public function setRefundApplicationFee($value) return $this->setParameter('refundApplicationFee', $value); } + /** + * @return bool Whether the charge transfer should be reversed + */ + public function getReverseTransfer() + { + return $this->getParameter('reverseTransfer'); + } + + /** + * Whether to reverse the transfer associated with the charge. + * + * When refunding a charge that has a destination value, by default the destination account will keep the funds that + * were transferred to it, leaving the platform account to cover the negative balance from the refund. To pull back + * the funds from the connected account to cover the refund, set the reverse_transfer parameter to true when + * creating the refund + * + * @param bool $value Whether the transfer should be reversed or not + * + * @return \Omnipay\Common\Message\AbstractRequest + */ + public function setReverseTransfer($value) + { + return $this->setParameter('reverseTransfer', $value); + } + public function getData() { $this->validate('transactionReference', 'amount'); @@ -89,6 +114,10 @@ public function getData() $data['refund_application_fee'] = 'true'; } + if ($this->getReverseTransfer()) { + $data['reverse_transfer'] = 'true'; + } + return $data; } From 3aebd9bf731da0b0a352ca3fbeb8487d195dd87f Mon Sep 17 00:00:00 2001 From: Rushi Vishavadia Date: Sat, 1 Oct 2016 01:00:10 +0530 Subject: [PATCH 2/2] XOL-3125 Add unit test --- tests/Message/RefundRequestTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/Message/RefundRequestTest.php b/tests/Message/RefundRequestTest.php index d6762ae4..58d91e6c 100644 --- a/tests/Message/RefundRequestTest.php +++ b/tests/Message/RefundRequestTest.php @@ -6,6 +6,9 @@ class RefundRequestTest extends TestCase { + /** @var RefundRequest $request */ + private $request; + public function setUp() { $this->request = new RefundRequest($this->getHttpClient(), $this->getHttpRequest()); @@ -30,6 +33,16 @@ public function testRefundApplicationFee() $this->assertEquals("true", $data['refund_application_fee']); } + public function testShouldSetReverseTransferFlag() + { + $this->request->setTransactionReference('ch_12RgN9L7XhO9mI')->setAmount('10.00'); + $this->request->setReverseTransfer(true); + + $data = $this->request->getData(); + + $this->assertEquals("true", $data['reverse_transfer']); + } + public function testSendSuccess() { $this->setMockHttpResponse('RefundSuccess.txt');