diff --git a/components/payment/default.htm b/components/payment/default.htm index 640b81b..90b7071 100644 --- a/components/payment/default.htm +++ b/components/payment/default.htm @@ -1,6 +1,6 @@ {% put scripts %} {% for method in paymentMethods %} - {{ method.renderPaymentScripts()|raw }} + {{ method.renderPaymentScripts(invoice.currency ?invoice.currency.code : 'USD')|raw }} {% endfor %} {% endput %} {% if invoice %} diff --git a/paymenttypes/PayPalPayment.php b/paymenttypes/PayPalPayment.php index 8d10681..44f343c 100644 --- a/paymenttypes/PayPalPayment.php +++ b/paymenttypes/PayPalPayment.php @@ -92,13 +92,21 @@ public function getInvoiceCaptureUrl() /** * getPayPalEndpoint */ - public function getPayPalEndpoint() + public function getPayPalEndpoint(): string { return $this->getHostObject()->test_mode ? 'https://api-m.sandbox.paypal.com' : 'https://api-m.paypal.com'; } + /** + * getPayPalClientId + */ + public function getPayPalClientId(): string + { + return $this->getHostObject()->test_mode ? 'test' : $this->getHostObject()->client_id; + } + /** * getPayPalNamespace */ @@ -110,13 +118,14 @@ public function getPayPalNamespace(): string /** * renderPaymentScripts */ - public function renderPaymentScripts() + public function renderPaymentScripts($currency = 'USD') { $queryParams = http_build_query([ - 'client-id' => 'test', + 'client-id' => $this->getPayPalClientId(), 'components' => 'buttons', 'enable-funding' => 'venmo', 'disable-funding' => 'paylater,card', + 'currency' => $currency, ]); $scriptParams = [