我正在尝试使用Symfony中的Payum Bundle设置定期付款。由于PROFILE_START_DATE
是DATE_ATOM
,因此即使有多个项目,但我看过一次付款后,都可能需要以一个订单进行多次重复付款并由Paypal Sandbox仪表盘判断在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');
}
有了这个,我觉得,如果从贝宝(Paypal)返回的令牌只有一个,我将不得不将它们重定向回贝宝(Paypal),以解决无用的每一项。有什么方法可以复制每个项目的令牌,或者您有什么建议?
答案 0 :(得分:0)
环顾四周,我发现this很显然,我必须为每个订阅将它们重定向到Paypal。有点费劲,但这显然是唯一的方法。
编辑:我很快就谈到,该问题与同一结帐中的不同类型的计费协议有关,我的问题涉及具有相同条件的多个计费协议。