Changeset View
Changeset View
Standalone View
Standalone View
src/app/Providers/PaymentProvider.php
Show First 20 Lines • Show All 255 Lines • ▼ Show 20 Lines | protected function storeRefund(Wallet $wallet, array $refund): void | ||||
'type' => $transaction_type, | 'type' => $transaction_type, | ||||
'amount' => $amount * -1, | 'amount' => $amount * -1, | ||||
'description' => $refund['description'] ?? '', | 'description' => $refund['description'] ?? '', | ||||
]); | ]); | ||||
$refund['status'] = self::STATUS_PAID; | $refund['status'] = self::STATUS_PAID; | ||||
$refund['amount'] = -1 * $amount; | $refund['amount'] = -1 * $amount; | ||||
// FIXME: Refunds/chargebacks are out of the reseller comissioning for now | |||||
$this->storePayment($refund, $wallet->id); | $this->storePayment($refund, $wallet->id); | ||||
} | } | ||||
/** | /** | ||||
* List supported payment methods from this provider | * List supported payment methods from this provider | ||||
* | * | ||||
* @param string $type The payment type for which we require a method (oneoff/recurring). | * @param string $type The payment type for which we require a method (oneoff/recurring). | ||||
* | * | ||||
▲ Show 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | public static function paymentMethods(Wallet $wallet, $type): array | ||||
$provider = PaymentProvider::factory($providerName); | $provider = PaymentProvider::factory($providerName); | ||||
$methods = self::applyMethodWhitelist($type, $provider->providerPaymentMethods($type)); | $methods = self::applyMethodWhitelist($type, $provider->providerPaymentMethods($type)); | ||||
Cache::put($cacheKey, $methods, now()->addHours(1)); | Cache::put($cacheKey, $methods, now()->addHours(1)); | ||||
return $methods; | return $methods; | ||||
} | } | ||||
/** | |||||
* Returns the full URL for the wallet page, used when returning from an external payment page. | |||||
* Depending on the request origin it will return a URL for the User or Reseller UI. | |||||
* | |||||
* @return string The redirect URL | |||||
*/ | |||||
public static function redirectUrl(): string | |||||
{ | |||||
$url = \App\Utils::serviceUrl('/wallet'); | |||||
$domain = preg_replace('/:[0-9]+$/', '', request()->getHttpHost()); | |||||
if (strpos($domain, 'reseller') === 0) { | |||||
$url = preg_replace('|^(https?://)([^/]+)|', '\\1' . $domain, $url); | |||||
} | |||||
return $url; | |||||
} | |||||
} | } |