【问题标题】:"A successful Billing Agreement has already been created for this token."“已经为此令牌创建了成功的计费协议。”
【发布时间】:2019-01-07 17:29:06
【问题描述】:

我正在尝试在 Symfony 中使用 Payum Bundle 设置定期付款。需要有可能在一个订单中进行多次定期付款并通过 Paypal Sandbox 仪表板判断,因为 PROFILE_START_DATEDATE_ATOM 初始付款通过,即使有多个项目但是当我查看 Phpmyadmin 时,只有RecurringPaymentDetails 的一个条目将具有 "ACK": "Success",其余条目将与 A successful Billing Agreement has already been created for this token. 失败

我有一个处理逻辑的 OrderController,它设置扩展 ArrayObject 的实体的值

/**
 * @Route("/accounts/order/paypal/completed", name="order_paypal_completed")
 */
public function orderPaypalCompletedAction(Request $request)
{
    $token = $this->get('payum')->getHttpRequestVerifier()->verify($request);

    $identity = $token->getDetails();
    $payment = $this->get('payum')->getStorage($identity->getClass())->find($identity);

    $gateway = $this->get('payum')->getGateway($token->getGatewayName());
    $gateway->execute($status = new GetHumanStatus($token));

    $order = $payment->getOrder();

    if ($status->isCaptured() || $status->isAuthorized()) {
        $order->setStatus(Order::STATUS_COMPLETED);

        $agreement = $status->getModel();
        $storage = $this->get('payum')->getStorage(RecurringPaymentDetails::class);
        $payments = [];
        foreach ($order->getItems() as $item) {
          $payment = $storage->create();
          $payment['TOKEN'] = $agreement['TOKEN'];
          $payment['DESC'] = $agreement['L_BILLINGAGREEMENTDESCRIPTION0'];
          $payment['EMAIL'] = $agreement['EMAIL'];
          $payment['AMT'] = $item->getPrice();
          $payment['CURRENCYCODE'] = $order->getCurrency();
          $payment['BILLINGFREQUENCY'] = $item->getDuration();
          $payment['PROFILESTARTDATE'] = date(DATE_ATOM);
          $payment['BILLINGPERIOD'] = Api::BILLINGPERIOD_DAY;

          $payments[] = $payment;
        }
        $this->addFlash('success', $this->get('translator')->trans('Payment has been successful.'));
    }

    if ($status->isPending()) {
        $this->addFlash('danger', $this->get('translator')->trans('Payment has been canceled.'));
    }

    if ($status->isFailed() || $status->isCanceled()) {
        $order->setStatus(Order::STATUS_CANCELED);
        $this->addFlash('danger', $this->get('translator')->trans('Payment has been canceled.'));
    }
    foreach ($payments as $payment) {
      $gateway->execute(new CreateRecurringPaymentProfile($payment));
      $gateway->execute(new Sync($payment));
      $recurringPaymentStatus = new GetHumanStatus($payment);
      $gateway->execute($recurringPaymentStatus);
    }

    try {
        $em = $this->getDoctrine()->getManager();
        $em->persist($order);
        $em->flush();
    } catch (\Exception $e) {
        $this->addFlash('danger', $this->get('translator')->trans('An error occurred when saving object.'));
    }
    return $this->redirectToRoute('homepage');
}

有了这个,我觉得,如果只能从贝宝返回一个令牌,我必须将它们重定向回贝宝,这是无意义的。有没有办法可以复制每个项目的令牌或您有什么建议?

【问题讨论】:

    标签: php symfony paypal payum


    【解决方案1】:

    环顾四周,我发现this 显然我必须为每个订阅将它们重定向到 Paypal。有点费力,但显然这是唯一的方法。

    编辑:我很快就谈到,这个问题与同一结帐中的不同类型的计费协议有关,我的问题是针对具有相同条件的多个计费协议。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-06
      • 2022-01-14
      • 2019-02-24
      • 2016-07-31
      • 2015-01-10
      • 2021-03-24
      • 1970-01-01
      • 2016-02-10
      相关资源
      最近更新 更多