phpnode.jslaravelpayment-gatewayyandex

How to connect YooMoney to PHP via Omnipay


There was a need to add integration with YooMoney to the site, that is, add a payment method through this site. At the moment, the site has payment methods through PayPal and a bank card, and all of them are implemented through the Omnipay payment gateway and YooMoney must be added through it. The problem is that I have never worked with either payment gateways or Omnipay, respectively. Maybe someone has done the integration with YooMoney and will be able to explain in detail how and what to do point by point, preferably with a code example. Your help would be very helpful :)

P.S. The driver for YooMoney already exists: https://github.com/leonardjke/omnipay-yoomoney


Solution

  •  /** @var YooMoneyGateway $gateway */
      $gateway = Omnipay::create('Yoomoney');
        
      $gateway->setReceiver(config('gateways.yoomoney_receiver'));
      $gateway->setSecret(config('gateways.yoomoney_secret'));
      $gateway->setQuickpayForm('shop');
    
      $response = $gateway->purchase([
        'amount' => $payment->price,
        'transactionId' => $transactionId,
        'description' => $payment->description,
        'currency' => 'RUB',
      ])->send();
    
    
      $url = $response->getRedirectUrl() . '?' . http_build_query($response->getRedirectData());
    
      return redirect($url);