我在通过Ominpay,Payum和Symfony配置Securepay时遇到了困难

时间:2015-02-28 16:50:29

标签: php symfony omnipay payum

我目前PayPal在Symfony2中通过Payum工作正常,我现在正在尝试配置SecurePay(通过Omnipay),但它似乎甚至没有连接到SecurePay,也没有文档支持它,所以我很困

在日志中似乎没有任何外部通信。在SecurePay中,没有我的付款记录。

非常感谢您提前寻求帮助,

以下是payment_order数据库记录的示例:

{"amount":45,"currency":"AUD","description":"Payment for #96","clientIp":"127.0.0.1","card":{},"_reference":null,"_status":"failed","_status_code":null,"_status_message":null}

这是我的配置:

payum:
    security:
        token_storage:
            XX\PaymentBundle\Entity\PaymentToken: { doctrine: orm }
    storages:
        XX\PaymentBundle\Entity\Order: { doctrine: orm }
    contexts:
        SecurePay_DirectPost:
            omnipay:
              type: 'SecurePay_DirectPost'
              options:
                merchantId: ABC0001
                transactionPassword: abc123
                testMode: true

我的捕获方法:

 /**
 * @Route("/{id}/cardcapture", name = "card_payment_capture")
 * @Template()
 */
public function captureSecurePayAction(Collection $collection) {

  $paymentName = 'SecurePay_DirectPost';

  $storage = $this->get('payum')->getStorage('XX\PaymentBundle\Entity\Order');

  $order = $storage->createModel();
  $paymentDetails['amount'] = 10;
  $paymentDetails['card'] = new SensitiveValue(array(
      'number' => $_POST['card-number'],
      'cvv' => $_POST['cvv'],
      'expiryMonth' => $_POST['exp-month'],
      'expiryYear' => $_POST['exp-year'],
      'firstName' => $_POST['card-name'],
      'lastName' => '',
  ));

  $order->setNumber($collection->getId());
  $order->setCurrencyCode('AUD');
  $order->setTotalAmount($collection->getAmount()."00");
  $order->setDescription('Payment for #' . $collection->getId());
  $order->setClientId($collection->getId());
  $order->setClientEmail($collection->getEmail());
  $storage->updateModel($order);

  $captureToken = $this->get('payum.security.token_factory')->createCaptureToken(
      $paymentName, 
      $order, 
      'payment_complete'
  );

  return $this->redirect($captureToken->getTargetUrl());
}

最后我的完整行动:

  /**
 * @Route("/complete", name = "payment_complete")
 * @Template()
 */
public function completeAction()
{
    $token = $this->get('payum.security.http_request_verifier')->verify($this->request);

    $payment = $this->get('payum')->getPayment($token->getPaymentName());

    $payment->execute($status = new GetHumanStatus($token));

    $model = $status->getModel();
    $id = explode("#", $model['description']);

    $collection = $this->em->getRepository('XXCollectionBundle:Collection')->find($id[1]);

    if ($status->isCaptured()) {
      $collection->setStatus("PAID");
      $collection->setAmountPaid($model['PAYMENTREQUEST_0_AMT']);
      $collection->setIsActive(true);

    } else if ($status->isPending()) {
      $collection->setStatus("PAYMENT PENDING");

    } else {
      $collection->setStatus("PAYMENT FAILED");
    }

    $this->em->persist($collection);
    $this->em->flush();

    $this->sendReceiptEmail($collection, $status);

    return array(
      'status' => $status,
      'collection' => $collection
    );
}

0 个答案:

没有答案