Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/payment/default.htm
Original file line number Diff line number Diff line change
@@ -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 %}
Expand Down
15 changes: 12 additions & 3 deletions paymenttypes/PayPalPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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 = [
Expand Down