File: /var/www/BtPayments/BtPayments-platform/app/Models/MerchantIntegrationConfig.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class MerchantIntegrationConfig extends Model
{
const TYPE_SHOPIFY = 'shopify';
protected $guarded = [];
protected $casts = [
'data' => 'object',
];
/**
* Relation: 商户
*/
public function merchant()
{
return $this->belongsTo(Merchant::class);
}
/**
* Attribute: Shopify 收银台代码
*/
public function getShopifyCheckoutCodeAttribute()
{
$gatewayName = 'BtPayments';
$merchantNo = $this->merchant->id;
$paymentUrl = route('gateway.payments.shopify.checkout');
$code = file_get_contents(resource_path('views/portal/integrations/stubs/shopify-payment-code.stub.html'));
$code = str_replace('{{ $gatewayName }}', $gatewayName, $code);
$code = str_replace('{{ $merchantNo }}', $merchantNo, $code);
$code = str_replace('{{ $paymentUrl }}', $paymentUrl, $code);
return $code;
}
}