/**
  * Get all available payment types
  */
 private function PaymentTypes()
 {
     $gateways = Omnipay\Common\GatewayFactory::find();
     $gateways = array_map(function ($name) {
         $factory = new Omnipay\Common\GatewayFactory();
         return $factory->create($name);
     }, $gateways);
     return $gateways;
 }
 /**
  * Get all available payment types
  */
 private function PaymentTypes()
 {
     $factory = new \Omnipay\Common\GatewayFactory();
     // since the omnipay gateway factory only returns gateways from the composer.json extra data,
     // we should merge it with user-defined gateways from Payment.allowed_gateways
     $gateways = array_unique(array_merge($factory->find(), array_keys(GatewayInfo::getSupportedGateways(false))));
     $supportedGateways = array();
     array_walk($gateways, function ($name, $index) use(&$supportedGateways, &$factory) {
         try {
             $instance = $factory->create($name);
             $supportedGateways[$name] = $instance;
         } catch (\Exception $e) {
         }
     });
     return $supportedGateways;
 }
示例#3
0
    $card = $app['request']->get('card');
    // save POST data into session
    $app['session']->set($sessionVar . '.update', $params);
    $app['session']->set($sessionVar . '.card', $card);
    $params['card'] = $card;
    $params['clientIp'] = $app['request']->getClientIp();
    $response = $gateway->updateCard($params)->send();
    return $app['twig']->render('response.twig', array('gateway' => $gateway, 'response' => $response));
});
// create gateway delete Credit Card
$app->get('/gateways/{name}/delete-card', function ($name) use($app) {
    $gateway = Omnipay\Common\GatewayFactory::create($name);
    $sessionVar = 'omnipay.' . $gateway->getShortName();
    $gateway->initialize((array) $app['session']->get($sessionVar));
    $params = $app['session']->get($sessionVar . '.delete', array());
    return $app['twig']->render('request.twig', array('gateway' => $gateway, 'method' => 'deleteCard', 'params' => $params));
});
// submit gateway delete Credit Card
$app->post('/gateways/{name}/delete-card', function ($name) use($app) {
    $gateway = Omnipay\Common\GatewayFactory::create($name);
    $sessionVar = 'omnipay.' . $gateway->getShortName();
    $gateway->initialize((array) $app['session']->get($sessionVar));
    // load POST data
    $params = $app['request']->get('params');
    // save POST data into session
    $app['session']->set($sessionVar . '.delete', $params);
    $params['clientIp'] = $app['request']->getClientIp();
    $response = $gateway->deleteCard($params)->send();
    return $app['twig']->render('response.twig', array('gateway' => $gateway, 'response' => $response));
});
$app->run();