PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, November 11, 2022

[FIXED] How to connect YooMoney to PHP via Omnipay

 November 11, 2022     laravel, node.js, payment-gateway, php, yandex     No comments   

Issue

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);



Answered By - Leonard
Answer Checked By - Terry (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing