Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2983617
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
4 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/applications/phortune/storage/PhortunePaymentMethod.php b/src/applications/phortune/storage/PhortunePaymentMethod.php
index 1712d3f973..8937d6ee84 100644
--- a/src/applications/phortune/storage/PhortunePaymentMethod.php
+++ b/src/applications/phortune/storage/PhortunePaymentMethod.php
@@ -1,161 +1,165 @@
<?php
/**
* A payment method is a credit card; it is associated with an account and
* charges can be made against it.
*/
final class PhortunePaymentMethod extends PhortuneDAO
implements PhabricatorPolicyInterface {
const STATUS_ACTIVE = 'payment:active';
const STATUS_DISABLED = 'payment:disabled';
protected $name = '';
protected $status;
protected $accountPHID;
protected $authorPHID;
protected $merchantPHID;
protected $providerPHID;
protected $expires;
protected $metadata = array();
protected $brand;
protected $lastFourDigits;
private $account = self::ATTACHABLE;
private $merchant = self::ATTACHABLE;
private $providerConfig = self::ATTACHABLE;
protected function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_SERIALIZATION => array(
'metadata' => self::SERIALIZATION_JSON,
),
self::CONFIG_COLUMN_SCHEMA => array(
'name' => 'text255',
'status' => 'text64',
'brand' => 'text64',
'expires' => 'text16',
'lastFourDigits' => 'text16',
),
self::CONFIG_KEY_SCHEMA => array(
'key_account' => array(
'columns' => array('accountPHID', 'status'),
),
'key_merchant' => array(
'columns' => array('merchantPHID', 'accountPHID'),
),
),
) + parent::getConfiguration();
}
public function generatePHID() {
return PhabricatorPHID::generateNewPHID(
PhortunePaymentMethodPHIDType::TYPECONST);
}
public function attachAccount(PhortuneAccount $account) {
$this->account = $account;
return $this;
}
public function getAccount() {
return $this->assertAttached($this->account);
}
public function attachMerchant(PhortuneMerchant $merchant) {
$this->merchant = $merchant;
return $this;
}
public function getMerchant() {
return $this->assertAttached($this->merchant);
}
public function attachProviderConfig(PhortunePaymentProviderConfig $config) {
$this->providerConfig = $config;
return $this;
}
public function getProviderConfig() {
return $this->assertAttached($this->providerConfig);
}
public function getDescription() {
$provider = $this->buildPaymentProvider();
- return $provider->getPaymentMethodProviderDescription();
+
+ $expires = $this->getDisplayExpires();
+ $description = $provider->getPaymentMethodProviderDescription();
+
+ return pht("Expires %s \xC2\xB7 %s", $expires, $description);
}
public function getMetadataValue($key, $default = null) {
return idx($this->getMetadata(), $key, $default);
}
public function setMetadataValue($key, $value) {
$this->metadata[$key] = $value;
return $this;
}
public function buildPaymentProvider() {
return $this->getProviderConfig()->buildProvider();
}
public function getDisplayName() {
if (strlen($this->name)) {
return $this->name;
}
$provider = $this->buildPaymentProvider();
return $provider->getDefaultPaymentMethodDisplayName($this);
}
public function getFullDisplayName() {
return pht('%s (%s)', $this->getDisplayName(), $this->getSummary());
}
public function getSummary() {
return pht('%s %s', $this->getBrand(), $this->getLastFourDigits());
}
public function setExpires($year, $month) {
$this->expires = $year.'-'.$month;
return $this;
}
public function getDisplayExpires() {
list($year, $month) = explode('-', $this->getExpires());
$month = sprintf('%02d', $month);
$year = substr($year, -2);
return $month.'/'.$year;
}
public function isActive() {
return ($this->getStatus() === self::STATUS_ACTIVE);
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */
public function getCapabilities() {
return array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
);
}
public function getPolicy($capability) {
return $this->getAccount()->getPolicy($capability);
}
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
return $this->getAccount()->hasAutomaticCapability(
$capability,
$viewer);
}
public function describeAutomaticCapability($capability) {
return pht(
'Members of an account can always view and edit its payment methods.');
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Feb 20, 19:30 (2 d, 1 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1164228
Default Alt Text
(4 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment