我目前通过 Symfony2 中的 Payum 让 PayPal 工作正常,现在我正在尝试配置 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
);
}