-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3535148
commit c34c25b
Showing
9 changed files
with
75 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
namespace Dfe\Stripe; | ||
use Dfe\Stripe\Facade\Token as fToken; | ||
use Stripe\Source as lSource; | ||
// 2017-11-12 | ||
/** @used-by \Df\StripeClone\P\Charge::request() */ | ||
final class Payer extends \Df\StripeClone\Payer { | ||
/** | ||
* 2017-11-12 | ||
* Note 1. | ||
* Some Stripe's sources are single-use: https://stripe.com/docs/sources#single-use-or-reusable | ||
* «Stripe API Documentation» → «Payment Methods Supported by the Sources API» → «Single-use or reusable»: | ||
* «If a source can only be used once, this parameter is set to `single_use` | ||
* and a source must be created each time a customer makes a payment. | ||
* Such sources should not be attached to customers and should be charged directly instead.» | ||
* Note 2. «Stripe API Reference» → «Sources» → «The source object» → `usage`: | ||
* «Either `reusable` or `single_use`. | ||
* Whether this source should be reusable or not. | ||
* Some source types may or may not be reusable by construction, | ||
* while other may leave the option at creation. | ||
* If an incompatible value is passed, an error will be returned.» | ||
* https://stripe.com/docs/api#source_object-usage | ||
* @override | ||
* @see \Df\StripeClone\Payer::tokenIsSingleUse() | ||
* @used-by \Df\StripeClone\Payer::cardId() | ||
* @used-by \Df\StripeClone\Payer::customerId() | ||
* @return bool | ||
*/ | ||
protected function tokenIsSingleUse() {return dfc($this, function() {return | ||
fToken::isPreviouslyUsedOrTrimmedSource($t = fToken::trimmed($this->token())) | ||
&& 'single_use' === dfe_stripe_source($t)['usage'] | ||
;});} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,28 @@ | ||
<?php | ||
use Dfe\Stripe\Method as M; | ||
use Stripe\Source as lSource; | ||
use Stripe\StripeObject as lO; | ||
/** | ||
* 2017-10-22 Allowing $o to be an array makes my algorithms shorter. | ||
* @used-by \Dfe\Stripe\Facade\Card::__construct() | ||
* @used-by \Dfe\Stripe\Facade\Card::__construct() | ||
* @used-by \Dfe\Stripe\Facade\O::toArray() | ||
* @used-by \Dfe\Stripe\Init\Action::redirectUrl() | ||
* @param lO|array(string => mixed) $o | ||
* @return array(string => mixed) | ||
*/ | ||
function dfe_stripe_a($o) {return is_array($o) ? $o : $o->__toArray(true);} | ||
function dfe_stripe_a($o) {return is_array($o) ? $o : $o->__toArray(true);} | ||
|
||
/** | ||
* 2017-11-12 | ||
* @used-by \Dfe\Stripe\Block\Info::cardData() | ||
* @used-by \Dfe\Stripe\Controller\CustomerReturn\Index::isSuccess() | ||
* @used-by \Dfe\Stripe\Facade\Card::__construct() | ||
* @used-by \Dfe\Stripe\Init\Action::sourceInitial() | ||
* @used-by \Dfe\Stripe\Payer::tokenIsSingleUse() | ||
* @param string $id | ||
* @return lSource | ||
*/ | ||
function dfe_stripe_source($id) {return dfcf(function($id) { | ||
dfps(M::class)->init(); return lSource::retrieve($id); | ||
}, [$id]);} |