本文整理汇总了PHP中PayPal::Transaction方法的典型用法代码示例。如果您正苦于以下问题:PHP PayPal::Transaction方法的具体用法?PHP PayPal::Transaction怎么用?PHP PayPal::Transaction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PayPal
的用法示例。
在下文中一共展示了PayPal::Transaction方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postCheckout
public function postCheckout()
{
$payer = PayPal::Payer();
$payer->setPaymentMethod('paypal');
$amount = PayPal::Amount();
$amount->setCurrency('USD');
$amount->setTotal(intval(\Cart::getTotal()) / 20);
// This is the simple way,
// you can alternatively describe everything in the order separately;
// Reference the PayPal PHP REST SDK for details.
$transaction = PayPal::Transaction();
$transaction->setAmount($amount);
$transaction->setDescription('Thanh Toán Mua Hàng Từ Couponia?');
$redirectUrls = PayPal::RedirectUrls();
$redirectUrls->setReturnUrl(\Redirect::getUrlGenerator()->route('paypal-done'));
$redirectUrls->setCancelUrl(\Redirect::getUrlGenerator()->route('paypal'));
$payment = PayPal::Payment();
$payment->setIntent('sale');
$payment->setPayer($payer);
$payment->setRedirectUrls($redirectUrls);
$payment->setTransactions(array($transaction));
$response = $payment->create($this->_apiContext);
$redirectUrl = $response->links[1]->href;
return \Redirect::to($redirectUrl);
}
示例2: checkout
/**
* Payments
*/
public function checkout()
{
$ids = session('likes', []);
$total = 0;
foreach ($ids as $id) {
$movie = Movies::find($id);
$total = $total + $movie->price;
}
$payer = PayPal::Payer();
$payer->setPaymentMethod('paypal');
$amount = PayPal::Amount();
$amount->setCurrency('EUR');
$amount->setTotal($total);
$transaction = PayPal::Transaction();
$transaction->setAmount($amount);
$transaction->setDescription("Récapitulatif total des " . count($ids) . " films commandés");
$redirectUrls = PayPal::RedirectUrls();
$redirectUrls->setReturnUrl(route('cart_done'));
$redirectUrls->setCancelUrl(route('cart_cancel'));
$payment = PayPal::Payment();
$payment->setIntent('sale');
$payment->setPayer($payer);
$payment->setRedirectUrls($redirectUrls);
$payment->setTransactions(array($transaction));
//response de Paypal
$response = $payment->create($this->_apiContext);
$redirectUrl = $response->links[1]->href;
//redirect to Plateform Paypal
return Redirect::to($redirectUrl);
}
示例3: getCheckout
public function getCheckout()
{
$payer = PayPal::Payer();
$payer->setPaymentMethod('paypal');
$amount = PayPal::Amount();
$amount->setCurrency('EUR');
$amount->setTotal(42);
// This is the simple way,
// you can alternatively describe everything in the order separately;
// Reference the PayPal PHP REST SDK for details.
$transaction = PayPal::Transaction();
$transaction->setAmount($amount);
$transaction->setDescription('What are you selling?');
$redirectUrls = PayPal::RedirectUrls();
$redirectUrls->setReturnUrl(action('PayPalController@getDone'));
$redirectUrls->setCancelUrl(action('PayPalController@getCancel'));
$payment = PayPal::Payment();
$payment->setIntent('sale');
$payment->setPayer($payer);
$payment->setRedirectUrls($redirectUrls);
$payment->setTransactions(array($transaction));
$response = $payment->create($this->_apiContext);
$redirectUrl = $response->links[1]->href;
return Redirect::to($redirectUrl);
}
示例4: postProcessPayment
public function postProcessPayment()
{
$index = \Input::get('value');
$user = \Input::get('user');
if ($user !== 'company' && $user !== 'agency') {
return \Response::json(['type' => 'danger', 'message' => 'User not recognized']);
}
if (!array_key_exists($index, $this->paymentType)) {
return \Response::json(['type' => 'danger', 'message' => 'Payment not recognized']);
}
$paymentData = $this->paymentType[$index];
if ($index === '2') {
$xAmount = \Input::get('amount');
if ($xAmount <= 0) {
return \Response::json(['type' => 'danger', 'message' => 'Minimum of amount of credit to be bought is 1.']);
}
$paymentData['name'] = $xAmount . ' company credit(s) on Programme Chameleon.';
$paymentData['xCreditAmount'] = $xAmount;
$paymentData['successMessage'] .= $xAmount . ' credit(s)';
}
session(['_temp_payment_sess' => $paymentData]);
$total = isset($xAmount) ? $xAmount * $paymentData['amount'] : $paymentData['amount'];
try {
$payer = PayPal::Payer();
$payer->setPaymentMethod('paypal');
$amount = PayPal::Amount();
$amount->setCurrency('GBP');
$amount->setTotal($total + 0.2 * $total);
$item = PayPal::Item();
$item->setName($paymentData['name'])->setDescription($paymentData['description'])->setCurrency('GBP')->setQuantity(isset($xAmount) ? $xAmount : 1)->setTax(0)->setPrice($paymentData['amount']);
$tax = PayPal::Item();
$tax->setName('VAT TAX')->setDescription('20% VAT Tax')->setCurrency('GBP')->setQuantity(1)->setTax(0)->setPrice(0.2 * $total);
$itemList = PayPal::ItemList();
$itemList->setItems([$item, $tax]);
$transaction = PayPal::Transaction();
$transaction->setAmount($amount);
$transaction->setItemList($itemList);
$transaction->setDescription('Transaction for programmechameleon.com website.');
$redirectUrls = PayPal::RedirectUrls();
if ($user === 'company') {
$redirectUrls->setReturnUrl(action('PaymentController@getCompanyPaymentDone'));
$redirectUrls->setCancelUrl(action('PaymentController@getCompanyPaymentCancel'));
} else {
if ($user === 'agency') {
$redirectUrls->setReturnUrl(action('PaymentController@getAgencyPaymentDone'));
$redirectUrls->setCancelUrl(action('PaymentController@getAgencyPaymentCancel'));
}
}
$payment = PayPal::Payment();
$payment->setIntent('sale');
$payment->setPayer($payer);
$payment->setRedirectUrls($redirectUrls);
$payment->setTransactions(array($transaction));
$response = $payment->create($this->paypalApiContext);
$redirectUrl = $response->links[1]->href;
return \Response::json(['type' => 'success', 'message' => 'Paypal init success', 'redirect' => $redirectUrl]);
} catch (\Exception $e) {
return \Response::json(['type' => 'danger', 'message' => $e->getMessage()]);
}
}