2

我正在尝试使用2checkout设置payumbundle ,但我似乎无法理解如何设置以及如何将信息发送到 2checkout。config.yml

在此之前,我已经使用 Payum 成功设置了 PayPal 快速结账,并且我对 Payum 有点熟悉(仍在学习 Payum)

这是我到目前为止所做的

我已经安装了omnipay 2checkout 捆绑包

composer require "payum/omnipay-bridge" "omnipay/2checkout"

因为我似乎无法在网上找到 2checkout 的任何示例,而我找到的最接近的是 stripe,所以查看它的示例 这是我的 config.yml

payum:
    security:
        .....
    contexts:
        paypal:
            paypal_express_checkout_nvp:
                username: ....
                password: ....
                signature: ....
                sandbox: true

        2checkout:
            omnipay:
                type: TwoCheckout
                options:
                    apiKey: ....
                    pri: ....
                    act: ....
                    testMode: true

这里我的第一个问题出现了

Q1:我如何知道在 config.yml 中为不同的网关添加哪些信息

现在转到我的操作中的代码,该代码应该将信息发送到 2checkout 并将数据添加到数据库。

$paymentName = 'TwoCheckout';

$storage = $this->get('payum')->getStorage('ClickTeck\featuresBundle\Entity\Orders');
$paymentDetails = $storage->create();

// insert order into database
$paymentDetails->setClientFname('First');
$paymentDetails->setClientLname('Last');
$paymentDetails->setClientPhone('111-111-111');
$paymentDetails->setClientEmail('xyz@abc.com');
$paymentDetails->setInvoiceId('123');
$paymentDetails->setNumber('456');
$paymentDetails->setDescription('This is description');
$paymentDetails->setCurrencyCode('USD');
$paymentDetails->setTotalAmount('20');
$paymentDetails->setClientId($clientID);
$paymentDetails->setPaymentOption($paymentName);

$storage->update($paymentDetails);


$paymentDetails['amount'] = 20;
$paymentDetails["currency"] = 'USD';
$paymentDetails["description"] = "This is description";

$storage->update($paymentDetails);

$captureToken = $this->get('payum.security.token_factory')->createCaptureToken(
    $paymentName,
    $paymentDetails,
    'payment_done' // the route to redirect after capture;
);


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

我正在使用与 PayPal 和 paypal payum 相同的实体,在details数据库列中添加了数据,但是对于 2checkout,它没有添加任何详细信息并给出一个Integrity constraint violation可以理解的错误,因为详细信息不应该为空,所以这是我的第二个问题

Q2:我们不能为不同的支付方式使用同一个实体吗?还是每种支付方式都应该有自己的实体?如果我们可以使用相同的实体,为什么 payum 不会为details列生成任何内容。我在这里做错了什么

如果有人可以帮助我,我将非常感激,我需要查看一个示例,而不仅仅是关于如何集成 2checkout 的说明。然而,解释也将不胜感激。

更新

这是我在我的操作中更新的代码,它正在准备添加到数据库中的付款,但交易失败

$paymentName = 'TwoCheckout';
$storage = $this->get('payum')->getStorage('ClickTeck\featuresBundle\Entity\Orders');
/** @var Orders $details */

$details = $storage->create();

// insert order into database
$details->setClientFname($form->get('client_fname')->getData());
$details->setClientLname($form->get('client_lname')->getData());
$details->setClientPhone($form->get('client_phone')->getData());
$details->setClientEmail($form->get('client_email')->getData());
$details->setInvoiceId('123');
$details->setNumber('456');
$details->setDescription('This is description');

//change currency to dynamic before live
$details->setCurrencyCode('USD');
$details->setTotalAmount($cartTotal.".00");
$details->setClientId($clientID);
$details->setPaymentOption($paymentName);



$details["sid"] = '201308888';
$details["cart_order_id"] = '123456';
$details["merchant_order_id"] = '789';
$details["total"] = $cartTotal.".00";

$details["amount"] = $cartTotal.".00";
$details["tco_currency"] = 'USD';
$details['fixed'] = 'Y';
$details['skip_landing'] = 1;
$details['card_holder_name'] = 'Hold Name';
$details['street_address'] = 'Address 1';
$details['street_address2'] = 'Address 2';
$details['city'] = 'City';
$details['state'] = 'State';
$details['zip'] = '08610';
$details['country'] = 'USA';
$details['phone'] = '111-111-111';
$details['email'] = 'dummy@xyz.com';

$details["name"] = 'a name';
$details["description"] = 'a description';
$details['card'] = new SensitiveValue(array(
    'number' => $form->get('cardNumber')->getData(),
    'cvv' => $form->get('cvv')->getData(),
    'expiryMonth' => $form->get('expiryMonth')->getData(),
    'expiryYear' => $form->get('expiryYear')->getData(),
    'firstName' => $form->get('client_fname')->getData(),
));

$storage->update($details);
$captureToken = $this->get('payum.security.token_factory')->createCaptureToken(
    $paymentName,
    $details,
    'payment_done' // the route to redirect after capture;
);
$details["returnUrl"] = $captureToken->getTargetUrl();
//return $this->redirect($captureToken->getTargetUrl());
return $this->forward('PayumBundle:Capture:do', array(
    'payum_token' => $captureToken,
));

这是我看到的回复,我似乎无法理解为什么它会失败

{"status":"failed","order":{"total_amount":500,"currency_code":"USD","details":{"sid":"201308888","cart_order_id":"123456","merchant_order_id":"789","total":"500.00","amount":"500.00","tco_currency":"USD","fixed":"Y","skip_landing":1,"card_holder_name":"Hold Name","street_address":"Address 1","street_address2":"Address 2","city":"city","state":"State","zip":"08610","country":"USA","phone":"111-111-111","email":"dummy@xyz.com","name":"a name","description":"a description","card":[],"returnUrl":"http:\/\/127.0.0.1:8000\/payment\/capture\/mjIo0HsxKQ1-DRISYUZ6fMZLUmOXD0-cPiOheqRqpH8","clientIp":"127.0.0.1","_reference":null,"_status":"failed","_status_code":null,"_status_message":null}}}
4

1 回答 1

0

Q1:我如何知道在 config.yml 中为不同的网关添加哪些信息

Payum 的支付工厂提供有关可能选项的信息。它的默认值和必需值。您必须调用 $factory->createConfig() 并查找payum.required_optionspayum.default_options示例)。在 PayumBundle 中,事情变得更加简单。该捆绑包提供了可以使用可能选项扩展容器配置的工厂。因此它们将由 Symfony 的标准配置验证器进行验证。

要找出您必须在 Omnipay 网关中传递哪些选项,您必须查看该网关设置器\获取器方法(示例)。例如,网关有方法setTestMode,要在 PayumBundle 中配置它,您必须定义一个选项testMode这就是选项转换为 setter 调用的方式。

2Checkout 我猜一定是这样配置的。

payum:
    contexts:
        2checkout:
            omnipay:
                type: TwoCheckout
                options:
                    accountNumber: ....
                    secretWord: ....
                    testMode: true

Q2:我们不能为不同的支付方式使用同一个实体吗?还是每种支付方式都应该有自己的实体?如果我们可以使用相同的实体,为什么 payum 不会为详细信息列生成任何内容。我在这里做错了什么

从 Payum 的角度来看,您可以使用相同的实体\模型来存储不同的付款。由于我从未使用过 Omnipay 和 2Checkout 网关,我无法在此提供更多帮助。

于 2015-02-11T09:28:08.167 回答