[英]How to configure Payum so it can handle PayPal standard payments (not express checkout payments)?
如何配置Payum for Symfony ,使其可以處理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)的情況下進行付款。
好吧,我的工作現在已經完成,您只需要設置Solutiontype
獨家:買家無需創建PayPal帳戶即可結帳。 這稱為“貝寶帳戶可選”。
馬克:買家必須擁有PayPal帳戶才能簽出。
$payment['SOLUTIONTYPE'] = 'Sole';
在這里簽出: https : //developer.paypal.com/docs/classic/api/merchant/SetExpressCheckout_API_Operation_NVP/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.