Changeset View
Changeset View
Standalone View
Standalone View
src/app/Payment.php
<?php | <?php | ||||
namespace App; | namespace App; | ||||
use Illuminate\Database\Eloquent\Model; | use Illuminate\Database\Eloquent\Model; | ||||
/** | /** | ||||
* A payment operation on a wallet. | * A payment operation on a wallet. | ||||
* | * | ||||
* @property int $amount Amount of money in cents | * @property int $amount Amount of money in cents of CHF | ||||
* @property string $description Payment description | * @property string $description Payment description | ||||
* @property string $id Mollie's Payment ID | * @property string $id Mollie's Payment ID | ||||
* @property \App\Wallet $wallet The wallet | * @property \App\Wallet $wallet The wallet | ||||
* @property string $wallet_id The ID of the wallet | * @property string $wallet_id The ID of the wallet | ||||
* @property int $amountInCurrency Amount of money in cents of $currency | |||||
* @property string $currency Currency of this payment | |||||
*/ | */ | ||||
class Payment extends Model | class Payment extends Model | ||||
{ | { | ||||
public $incrementing = false; | public $incrementing = false; | ||||
protected $keyType = 'string'; | protected $keyType = 'string'; | ||||
protected $casts = [ | protected $casts = [ | ||||
'amount' => 'integer' | 'amount' => 'integer' | ||||
]; | ]; | ||||
protected $fillable = [ | protected $fillable = [ | ||||
'id', | 'id', | ||||
'wallet_id', | 'wallet_id', | ||||
'amount', | 'amount', | ||||
'description', | 'description', | ||||
'provider', | 'provider', | ||||
'status', | 'status', | ||||
'type', | 'type', | ||||
'currency', | |||||
machniak: It would be good to have some logic to make sure the currency code is always upper-case'd. I… | |||||
'amountInCurrency', | |||||
Done Inline ActionsShouldn't this be removed for now? machniak: Shouldn't this be removed for now? | |||||
Done Inline ActionsI would propose to leave all infrastructure for currency conversion in place so we can simply enable it by implementing the conversion rate and enabling the EUR payment method. mollekopf: I would propose to leave all infrastructure for currency conversion in place so we can simply… | |||||
Done Inline ActionsYou do not provide database migration that would add these columns. That's why I complain. machniak: You do not provide database migration that would add these columns. That's why I complain. | |||||
]; | ]; | ||||
/** | /** | ||||
* The wallet to which this payment belongs. | * The wallet to which this payment belongs. | ||||
* | * | ||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo | ||||
*/ | */ | ||||
public function wallet() | public function wallet() | ||||
{ | { | ||||
return $this->belongsTo( | return $this->belongsTo( | ||||
'\App\Wallet', | '\App\Wallet', | ||||
'wallet_id', /* local */ | 'wallet_id', /* local */ | ||||
'id' /* remote */ | 'id' /* remote */ | ||||
); | ); | ||||
} | } | ||||
} | } |
It would be good to have some logic to make sure the currency code is always upper-case'd. I think different payment providers may use different casing. It could be done in an observer, but probably a mutator would be better here. See App\Domain::setNamespaceAttribute() for an example.