Skip to content

Fixed application fee for PaymentIntent #155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c8959b6
Added support for Connect Application Fees.
gabsfm Sep 14, 2019
69193b2
Updated unit test for Fetch Application Fee.
gabsfm Sep 14, 2019
d38b7e5
Fixed application fee request parameter when creating a PaymentIntent.
gabsfm Sep 17, 2019
f4b689c
Moved Fetch Application Fee to the AbstractGateway.
gabsfm Sep 18, 2019
d9580b1
Merge pull request #153 from fotomerchant/feature/connect-application…
barryvdh Sep 18, 2019
8f2fd68
Allow configuring `Stripe-Version` at the gateway level
anush Jan 4, 2020
819c2ca
Support for expanding Stripe objects in the response
anush Jan 5, 2020
4faa2cd
Support for level 3 data
anush Jan 5, 2020
a303eda
Merge pull request #167 from anush/gateway_version
barryvdh Jan 5, 2020
1b27d76
Merge pull request #168 from anush/expand
barryvdh Jan 5, 2020
8706887
Support for card present track data
anush Jan 6, 2020
23f998e
add: create setup intent request
Apr 24, 2020
68b4903
add: restrieve setup intent and fix the setup intents response
Apr 25, 2020
2e1355e
add: off session option for payment intents
Apr 25, 2020
2c88b82
red: formatting
Apr 25, 2020
4ecac67
Adds methods for required setting to do token based payments
aimeoscom May 1, 2020
e64b511
Fixes tests
aimeoscom May 1, 2020
4e7fe74
Don't enable off_session in tests so existing tests still succeed
aimeoscom May 1, 2020
a9c9399
Always add off_session parameter to request
aimeoscom May 1, 2020
37266c2
Merge pull request #178 from aimeoscom/master
barryvdh May 25, 2020
f7d4171
Merge pull request #170 from anush/tracks
barryvdh May 25, 2020
56c5735
Merge pull request #169 from anush/level3
barryvdh May 25, 2020
a91faeb
Merge pull request #177 from ampeco/master
barryvdh May 29, 2020
3878249
Add trial_end option for CreateSubscription (#182)
AntoineLemaire Jun 27, 2020
d3c2592
Add FetchSubscriptionSchedulesRequest (#181)
AntoineLemaire Jun 27, 2020
431dfde
Add calls for Coupons (#183)
AntoineLemaire Jun 27, 2020
d287bd3
Add Detach & Fetch source (#184)
AntoineLemaire Jun 27, 2020
2c7cc0a
Update Create plan request (#185)
AntoineLemaire Jun 28, 2020
fbf57b3
Add missing fetchSubscriptionSchedules in Gateway (#187)
AntoineLemaire Jun 30, 2020
76e8fd1
Fixed application fee request parameter when creating a PaymentIntent.
gabsfm Sep 17, 2019
e077f19
Merge branch 'feature/payment-intent-application-fee' of https://gith…
gabsfm Aug 19, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/AbstractGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public function getDefaultParameters()
{
return array(
'apiKey' => '',
'stripeVersion' => null
);
}

Expand Down Expand Up @@ -150,6 +151,24 @@ public function setApiKey($value)
return $this->setParameter('apiKey', $value);
}

/**
* @return string
*/
public function getStripeVersion()
{
return $this->getParameter('stripeVersion');
}

/**
* @param string $value
*
* @return Gateway
*/
public function setStripeVersion($value)
{
return $this->setParameter('stripeVersion', $value);
}

/**
* Authorize Request.
*
Expand Down Expand Up @@ -263,6 +282,21 @@ public function fetchBalanceTransaction(array $parameters = array())
return $this->createRequest('\Omnipay\Stripe\Message\FetchBalanceTransactionRequest', $parameters);
}

//
// Application Fees
// @link https://stripe.com/docs/api#application_fees
//

/**
* @param array $parameters
*
* @return \Omnipay\Stripe\Message\FetchApplicationFeeRequest
*/
public function fetchApplicationFee(array $parameters = array())
{
return $this->createRequest('\Omnipay\Stripe\Message\FetchApplicationFeeRequest', $parameters);
}

//
// Transfers
// @link https://stripe.com/docs/api#transfers
Expand Down
81 changes: 80 additions & 1 deletion src/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,17 @@ public function cancelSubscription(array $parameters = array())
return $this->createRequest('\Omnipay\Stripe\Message\CancelSubscriptionRequest', $parameters);
}

/**
* Fetch Schedule Subscription
*
* @param array $parameters
* @return \Omnipay\Stripe\Message\FetchSubscriptionSchedulesRequest
*/
public function fetchSubscriptionSchedules(array $parameters = array())
{
return $this->createRequest('\Omnipay\Stripe\Message\FetchSubscriptionSchedulesRequest', $parameters);
}

/**
* Fetch Event
*
Expand Down Expand Up @@ -321,13 +332,31 @@ public function createSource(array $parameters = array())

/**
* @param array $parameters
* @return \Omnipay\Stripe\Message\CreateSourceRequest
* @return \Omnipay\Stripe\Message\AttachSourceRequest
*/
public function attachSource(array $parameters = array())
{
return $this->createRequest('\Omnipay\Stripe\Message\AttachSourceRequest', $parameters);
}

/**
* @param array $parameters
* @return \Omnipay\Stripe\Message\FetchSourceRequest
*/
public function detachSource(array $parameters = array())
{
return $this->createRequest('\Omnipay\Stripe\Message\DetachSourceRequest', $parameters);
}

/**
* @param array $parameters
* @return \Omnipay\Stripe\Message\FetchSourceRequest
*/
public function fetchSource(array $parameters = array())
{
return $this->createRequest('\Omnipay\Stripe\Message\FetchSourceRequest', $parameters);
}

/**
* Create a completePurchase request.
*
Expand All @@ -338,4 +367,54 @@ public function completePurchase(array $parameters = array())
{
return $this->createRequest('\Omnipay\Stripe\Message\CompletePurchaseRequest', $parameters);
}

/**
* @param array $parameters
*
* @return \Omnipay\Common\Message\AbstractRequest
*/
public function createCoupon(array $parameters = array())
{
return $this->createRequest('\Omnipay\Stripe\Message\CreateCouponRequest', $parameters);
}

/**
* @param array $parameters
*
* @return \Omnipay\Common\Message\AbstractRequest
*/
public function fetchCoupon(array $parameters = array())
{
return $this->createRequest('\Omnipay\Stripe\Message\FetchCouponRequest', $parameters);
}

/**
* @param array $parameters
*
* @return \Omnipay\Common\Message\AbstractRequest
*/
public function deleteCoupon(array $parameters = array())
{
return $this->createRequest('\Omnipay\Stripe\Message\DeleteCouponRequest', $parameters);
}

/**
* @param array $parameters
*
* @return \Omnipay\Common\Message\AbstractRequest
*/
public function updateCoupon(array $parameters = array())
{
return $this->createRequest('\Omnipay\Stripe\Message\UpdateCouponRequest', $parameters);
}

/**
* @param array $parameters
*
* @return \Omnipay\Common\Message\AbstractRequest
*/
public function listCoupons(array $parameters = array())
{
return $this->createRequest('\Omnipay\Stripe\Message\ListCouponsRequest', $parameters);
}
}
71 changes: 65 additions & 6 deletions src/Message/AbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,27 @@ public function setIdempotencyKeyHeader($value)
return $this->setParameter('idempotencyKey', $value);
}

/**
* @return array
*/
public function getExpand()
{
return $this->getParameter('expand');
}

/**
* Specifies which object relations (IDs) in the response should be expanded to include the entire object.
*
* @see https://stripe.com/docs/api/expanding_objects
*
* @param array $value
* @return AbstractRequest
*/
public function setExpand($value)
{
return $this->setParameter('expand', $value);
}

abstract public function getEndpoint();

/**
Expand Down Expand Up @@ -221,17 +242,42 @@ public function sendData($data)
);

$body = $data ? http_build_query($data, '', '&') : null;
$httpResponse = $this->httpClient->request($this->getHttpMethod(), $this->getEndpoint(), $headers, $body);
$httpResponse = $this->httpClient->request(
$this->getHttpMethod(),
$this->getExpandedEndpoint(),
$headers,
$body
);

return $this->createResponse($httpResponse->getBody()->getContents(), $httpResponse->getHeaders());
}

/**
* Appends the `expand` properties to the endpoint as a querystring.
*
* @return string
*/
public function getExpandedEndpoint()
{
$endpoint = $this->getEndpoint();
$expand = $this->getExpand();
if (is_array($expand) && count($expand) > 0) {
$queryParams = [];
foreach ($expand as $key) {
$queryParams[] = 'expand[]=' . $key;
}
$queryString = join('&', $queryParams);
$endpoint .= '?' . $queryString;
}

return $endpoint;
}

protected function createResponse($data, $headers = [])
{
return $this->response = new Response($this, $data, $headers);
}

/**
* @return mixed
*/
Expand Down Expand Up @@ -311,17 +357,30 @@ protected function getCardData()

$data = array();
$data['object'] = 'card';

// If track data is present, only return data relevant to a card present charge
$tracks = $card->getTracks();
$cvv = $card->getCvv();
$postcode = $card->getPostcode();
if (!empty($postcode)) {
$data['address_zip'] = $postcode;
}
if (!empty($cvv)) {
$data['cvc'] = $cvv;
}
if (!empty($tracks)) {
$data['swipe_data'] = $tracks;
return $data;
}

// If we got here, it's a card not present transaction, so include everything we have
$data['number'] = $card->getNumber();
$data['exp_month'] = $card->getExpiryMonth();
$data['exp_year'] = $card->getExpiryYear();
if ($card->getCvv()) {
$data['cvc'] = $card->getCvv();
}
$data['name'] = $card->getName();
$data['address_line1'] = $card->getAddress1();
$data['address_line2'] = $card->getAddress2();
$data['address_city'] = $card->getCity();
$data['address_zip'] = $card->getPostcode();
$data['address_state'] = $card->getState();
$data['address_country'] = $card->getCountry();
$data['email'] = $card->getEmail();
Expand Down
2 changes: 1 addition & 1 deletion src/Message/AttachSourceRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Class CreateSourceRequest
*
* TODO : Add docblock
* @link https://stripe.com/docs/api/sources/attach
*/
class AttachSourceRequest extends AbstractRequest
{
Expand Down
Loading