Skip to content

Commit

Permalink
Specify currency for PayPal in purchase step (#605)
Browse files Browse the repository at this point in the history
  • Loading branch information
subiabre authored May 6, 2024
1 parent fed00ff commit dd9206b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Goteo/Payment/Method/PaypalPaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Goteo\Application\Currency;
use Goteo\Model\Project;
use Omnipay\Common\Message\ResponseInterface;
use Omnipay\PayPal\ExpressGateway;

class PaypalPaymentMethod extends AbstractPaymentMethod
{
Expand All @@ -24,18 +25,19 @@ public function getGatewayName(): string

public function purchase(): ResponseInterface
{
/** @var ExpressGateway */
$gateway = $this->getGateway();

$invest = $this->getInvest();
$project = Project::get($invest->project);

$transactionId = sprintf("%s-%s", $project->getNumericId(), $invest->id);

$invest->setTransaction($transactionId);

// You can specify your paypal gateway details in config/settings.yml
if (!$gateway->getLogoImageUrl()) $gateway->setLogoImageUrl(SRC_URL . '/goteo_logo.png');

$gateway->setCurrency(Currency::getDefault('id'));

$request = $gateway->purchase([
'amount' => (float) $this->getTotalAmount(),
'description' => $this->getInvestDescription(),
Expand All @@ -49,9 +51,12 @@ public function purchase(): ResponseInterface

public function completePurchase(): ResponseInterface
{
/** @var ExpressGateway */
$gateway = $this->getGateway();
$invest = $this->getInvest();

$gateway->setCurrency(Currency::getDefault('id'));

$payment = $gateway->completePurchase([
'amount' => (float) $this->getTotalAmount(),
'description' => $this->getInvestDescription(),
Expand Down

0 comments on commit dd9206b

Please sign in to comment.