| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace App\Http\Controllers;
- use Illuminate\Http\Request;
- use PayPal\Auth\OAuthTokenCredential;
- use PayPal\Rest\ApiContext;
- use Response;
- use Redirect;
- use Captcha;
- use Cache;
- use PayPal\Api;
- use Paypal\Rest;
- use Paypal\Auth;
- class PaymentController extends Controller
- {
- function __construct()
- {
- //
- }
- public function create(Request $request)
- {
- $apiContext = new ApiContext(
- new OAuthTokenCredential(
- 'AYSq3RDGsmBLJE-otTkBtM-jBRd1TCQwFf9RGfwddNXWz0uFU9ztymylOhRS', // ClientID
- 'EGnHDxD_qRPdaLdZz8iCr8N7_MzF-YHPTkjs6NKYQvQSBngp4PTTVWkPZRbL' // ClientSecret
- )
- );
- $payer = new Api\Payer();
- $payer->setPaymentMethod('paypal');
- $amount = new \PayPal\Api\Amount();
- $amount->setTotal('1.00');
- $amount->setCurrency('USD');
- $transaction = new \PayPal\Api\Transaction();
- $transaction->setAmount($amount);
- $redirectUrls = new \PayPal\Api\RedirectUrls();
- $redirectUrls->setReturnUrl("https://example.com/your_redirect_url.html")
- ->setCancelUrl("https://example.com/your_cancel_url.html");
- $payment = new \PayPal\Api\Payment();
- $payment->setIntent('sale')
- ->setPayer($payer)
- ->setTransactions(array($transaction))
- ->setRedirectUrls($redirectUrls);
- }
- }
|