如何配置Payum for Symfony以便它可以处理PayPal标准付款(不是快速结帐付款);与基本的PayPal按钮完全相同?
文档中提供的示例仅适用于Express Checkout:
public function prepareAction()
{
$gatewayName = 'paypal_express_checkout';
$storage = $this->get('payum')->getStorage('FrontBundle\Entity\Payment');
$payment = $storage->create();
$payment->setNumber(uniqid());
$payment->setCurrencyCode('CHF');
$payment->setTotalAmount(100); // 1.00
$payment->setDescription('A description');
$payment->setClientId('anId');
$payment->setClientEmail('foo@example.com');
$storage->update($payment);
$captureToken = $this->get('payum')->getTokenFactory()->createCaptureToken(
$gatewayName,
$payment,
'done' // the route to redirect after capture
);
return $this->redirect($captureToken->getTargetUrl());
}
public function doneAction(Request $request)
{
dump($request);
$token = $this->get('payum')->getHttpRequestVerifier()->verify($request);
$gateway = $this->get('payum')->getGateway($token->getGatewayName());
// You can invalidate the token, so that the URL cannot be requested any more:
// $this->get('payum')->getHttpRequestVerifier()->invalidate($token);
// Once you have the token, you can get the payment entity from the storage directly.
// $identity = $token->getDetails();
// $payment = $this->get('payum')->getStorage($identity->getClass())->find($identity);
// Or Payum can fetch the entity for you while executing a request (preferred).
$gateway->execute($status = new GetHumanStatus($token));
$payment = $status->getFirstModel();
// UPDATE SUBSCRIPTION END DATE IN USER ENTITY
$subscription_end_date = new \DateTime("now+ 365 day");
$subscription_end_date_string = $subscription_end_date->format('Y-m-d H:i:s');
$user = $this->get('security.token_storage')->getToken()->getUser();
$user->setSubscriptionEndDate($subscription_end_date);
$em = $this->getDoctrine()->getManager();
$em->persist($user);
$em->flush($user);
return $this->render('FrontBundle:App:subscription_confirmation.html.twig', [
'page_title' => 'Accompagnement, coaching de vie personnelle et professionnelle à Genève',
'subscription_end_date' => $subscription_end_date_string,
]);
}
但我的客户希望他的用户可以在没有任何PayPal帐户的情况下付款(PayPal Guest Checkout)。
答案 0 :(得分:0)
我的工作现在好了,你只需要设置Solutiontype
唯一:买方可以在不创建PayPal帐户的情况下结帐。这被称为PayPal帐户可选。
标记:买方必须拥有PayPal帐户才能结帐。
$payment['SOLUTIONTYPE'] = 'Sole';
点击此处:https://developer.paypal.com/docs/classic/api/merchant/SetExpressCheckout_API_Operation_NVP/