{"id":28841,"date":"2021-06-21T16:40:00","date_gmt":"2021-06-21T13:40:00","guid":{"rendered":"https:\/\/themewp.inform.click\/?p=28841"},"modified":"2021-10-18T03:57:50","modified_gmt":"2021-10-18T00:57:50","slug":"integracao-de-gateway-de-pagamento-paypal-no-laravel","status":"publish","type":"post","link":"https:\/\/themewp.inform.click\/pt-pt\/integracao-de-gateway-de-pagamento-paypal-no-laravel\/","title":{"rendered":"Integra\u00e7\u00e3o de gateway de pagamento PayPal no Laravel"},"content":{"rendered":"<p>Recentemente publiquei um artigo sobre <a href=\"https:\/\/themewp.inform.click\/pt-pt\/integracao-do-gateway-de-pagamento-do-paypal-em-php-usando-a-api-rest-do-paypal\/\" title=\"Integra\u00e7\u00e3o de gateway de pagamento PayPal em PHP\" >Integra\u00e7\u00e3o de gateway de pagamento PayPal em PHP<\/a>. Nesse artigo, um de nossos leitores perguntou sobre a integra\u00e7\u00e3o do gateway de pagamento PayPal no Laravel. Embora o Laravel seja constru\u00eddo usando PHP, eles t\u00eam seus pr\u00f3prios padr\u00f5es a seguir. Voc\u00ea tem que ajustar seu c\u00f3digo PHP simples de acordo com o fluxo do Laravel. Neste artigo, mostrarei como aceitar pagamento em seu site Laravel usando a API Rest do PayPal.<\/p>\n<p>PayPal \u00e9 uma das marcas mais confi\u00e1veis \u200b\u200bpara aceitar pagamentos online. O PayPal oferece diferentes maneiras de integrar seu sistema de pagamento em aplicativos da web. Um dos servi\u00e7os \u00e9 o PayPal Rest API, que usaremos neste tutorial. Para come\u00e7ar, primeiro voc\u00ea precisa obter seu ID e segredo do cliente.<\/p>\n<p>V\u00e1 para sua conta de <a href=\"https:\/\/developer.paypal.com\/\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">desenvolvedor do PayPal<\/a> e fa\u00e7a login nela. No painel do desenvolvedor, clique no menu &#8216;Meus aplicativos e credenciais&#8217;. Em seguida, clique no bot\u00e3o &#8216;Criar aplicativo&#8217; na se\u00e7\u00e3o de aplicativos da API REST.<\/p>\n<p>Siga as etapas conforme solicitado e voc\u00ea obter\u00e1 sua sandbox e credenciais ao vivo. Por enquanto, copie o ID do cliente e o segredo do cliente do modo sandbox.<\/p>\n<p><a href=\"https:\/\/themewp.inform.click\/wp-content\/uploads\/2021\/04\/post-20136-6081c137ee496.png\" data-rel=\"lightbox\"><img decoding=\"async\" class=\"SDStudio-light-box-enable SDStudio-editor-tools-md-imp\" src=\"https:\/\/themewp.inform.click\/wp-content\/uploads\/2021\/04\/post-20136-6081c137ee496.png\" alt=\"Integra\u00e7\u00e3o de gateway de pagamento PayPal no Laravel\" ><\/a><\/p>\n<h3>Configura\u00e7\u00e3o b\u00e1sica no Laravel para aceitar pagamento usando PayPal<\/h3>\n<p>Quando os clientes fazem o pagamento em seu site, voc\u00ea precisa armazenar os detalhes do pagamento para uso posterior. Crie uma tabela de &#8216;pagamentos&#8217; no banco de dados para armazenar os detalhes do pagamento. Crie uma migra\u00e7\u00e3o para a tabela de &#8216;pagamentos&#8217; usando o comando:<\/p>\n<pre><code>php artisan make:migration create_payments_table<\/code><\/pre>\n<p>Abra o arquivo de migra\u00e7\u00e3o e modifique as colunas conforme a seguir.<\/p>\n<pre><code>&lt;?php\n...\n...\npublic function up()\n{\n\u00a0\u00a0\u00a0\u00a0Schema::create('payments', function (Blueprint $table) {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$table-&gt;bigIncrements('id');\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$table-&gt;string('payment_id');\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$table-&gt;string('payer_id');\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$table-&gt;string('payer_email');\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$table-&gt;float('amount', 10, 2);\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$table-&gt;string('currency');\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$table-&gt;string('payment_status');\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$table-&gt;timestamps();\n\u00a0\u00a0\u00a0\u00a0});\n}<\/code><\/pre>\n<p>Execute a migra\u00e7\u00e3o acima usando o comando abaixo.<\/p>\n<pre><code>php artisan migrate<\/code><\/pre>\n<p>Este comando criar\u00e1 uma tabela de &#8216;pagamentos&#8217; em seu banco de dados. A seguir, crie um modelo correspondente \u00e0 tabela de &#8216;pagamentos&#8217;.<\/p>\n<pre><code>php artisan make:model Payment<\/code><\/pre>\n<p>Depois disso, adicione as credenciais do PayPal em seu <code>.env<\/code>arquivo.<\/p>\n<pre><code>PAYPAL_CLIENT_ID=PASTE_HERE_CLIENT_ID\nPAYPAL_CLIENT_SECRET=PASTE_HERE_CLIENT_SECRET\nPAYPAL_CURRENCY=USD<\/code><\/pre>\n<p>Limpe o cache de configura\u00e7\u00e3o usando o comando:<\/p>\n<pre><code>php artisan config:cache<\/code><\/pre>\n<p>Eu passei a moeda &#8216;USD&#8217;. O usu\u00e1rio pode alter\u00e1-lo de acordo com os requisitos.<\/p>\n<p>Vamos definir as rotas que vamos exigir nas pr\u00f3ximas etapas.<\/p>\n<p><strong>rotas \/ web.php<\/strong><\/p>\n<pre><code>&lt;?php\n...\n...\nRoute::get('payment', 'PaymentController@index');\nRoute::post('charge', 'PaymentController@charge');\nRoute::get('paymentsuccess', 'PaymentController@payment_success');\nRoute::get('paymenterror', 'PaymentController@payment_error');<\/code><\/pre>\n<h3>Integra\u00e7\u00e3o de gateway de pagamento PayPal no Laravel<\/h3>\n<p>Integrar a API de gateways de pagamento no aplicativo \u00e9 algo bastante complexo. Felizmente, a biblioteca Omnipay facilitou a vida do desenvolvedor. <a href=\"https:\/\/github.com\/thephpleague\/omnipay\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">Omnipay<\/a> \u00e9 a biblioteca de processamento de pagamentos mais popular para PHP. Ele fornece um c\u00f3digo f\u00e1cil e limpo para a integra\u00e7\u00e3o de diferentes gateways de pagamento. Instale a biblioteca Omnipay usando o comando:<\/p>\n<pre><code>composer require league\/omnipay omnipay\/paypal<\/code><\/pre>\n<p>Agora, crie um controlador <code>PaymentController<\/code>e defina os m\u00e9todos mencionados no arquivo de rota.<\/p>\n<pre><code>php artisan make:controller PaymentController<\/code><\/pre>\n<p><strong>PaymentController.php<\/strong><\/p>\n<pre><code>&lt;?php\n\u00a0\u00a0\nnamespace AppHttpControllers;\n\u00a0\u00a0\nuse IlluminateHttpRequest;\nuse OmnipayOmnipay;\nuse AppPayment;\n\u00a0\u00a0\nclass PaymentController extends Controller\n{\n\u00a0\u00a0\n\u00a0\u00a0\u00a0\u00a0public $gateway;\n\u00a0\u00a0\n\u00a0\u00a0\u00a0\u00a0public function __construct()\n\u00a0\u00a0\u00a0\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$this-&gt;gateway = Omnipay::create('PayPal_Rest');\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$this-&gt;gateway-&gt;setClientId(env('PAYPAL_CLIENT_ID'));\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$this-&gt;gateway-&gt;setSecret(env('PAYPAL_CLIENT_SECRET'));\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$this-&gt;gateway-&gt;setTestMode(true); \/\/set it to 'false' when go live\n\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\n\u00a0\u00a0\u00a0\u00a0public function index()\n\u00a0\u00a0\u00a0\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return view('payment');\n\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\n\u00a0\u00a0\u00a0\u00a0public function charge(Request $request)\n\u00a0\u00a0\u00a0\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if($request-&gt;input('submit'))\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0try {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$response = $this-&gt;gateway-&gt;purchase(array(\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'amount' =&gt; $request-&gt;input('amount'),\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'currency' =&gt; env('PAYPAL_CURRENCY'),\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'returnUrl' =&gt; url('paymentsuccess'),\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'cancelUrl' =&gt; url('paymenterror'),\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0))-&gt;send();\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if ($response-&gt;isRedirect()) {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$response-&gt;redirect(); \/\/ this will automatically forward the customer\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0} else {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/ not successful\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return $response-&gt;getMessage();\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0} catch(Exception $e) {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return $e-&gt;getMessage();\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\n\u00a0\u00a0\u00a0\u00a0public function payment_success(Request $request)\n\u00a0\u00a0\u00a0\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/ Once the transaction has been approved, we need to complete it.\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if ($request-&gt;input('paymentId') &amp;&amp; $request-&gt;input('PayerID'))\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$transaction = $this-&gt;gateway-&gt;completePurchase(array(\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'payer_id'\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 =&gt; $request-&gt;input('PayerID'),\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'transactionReference' =&gt; $request-&gt;input('paymentId'),\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0));\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$response = $transaction-&gt;send();\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if ($response-&gt;isSuccessful())\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/ The customer has successfully paid.\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$arr_body = $response-&gt;getData();\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/ Insert transaction data into the database\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$isPaymentExist = Payment::where('payment_id', $arr_body['id'])-&gt;first();\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if(!$isPaymentExist)\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$payment = new Payment;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$payment-&gt;payment_id = $arr_body['id'];\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$payment-&gt;payer_id = $arr_body['payer']['payer_info']['payer_id'];\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$payment-&gt;payer_email = $arr_body['payer']['payer_info']['email'];\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$payment-&gt;amount = $arr_body['transactions'][0]['amount']['total'];\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$payment-&gt;currency = env('PAYPAL_CURRENCY');\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$payment-&gt;payment_status = $arr_body['state'];\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$payment-&gt;save();\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return \"Payment is successful. Your transaction id is: \". $arr_body['id'];\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0} else {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return $response-&gt;getMessage();\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0} else {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return 'Transaction is declined';\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\n\u00a0\u00a0\u00a0\u00a0public function payment_error()\n\u00a0\u00a0\u00a0\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return 'User is canceled the payment.';\n\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\n}<\/code><\/pre>\n<p>No controlador acima, pegamos o valor do formul\u00e1rio HTML e enviamos um usu\u00e1rio ao PayPal para pagamento. No pagamento bem-sucedido, armazenamos todos os detalhes da transa\u00e7\u00e3o na tabela de &#8216;pagamentos&#8217;.<\/p>\n<p>Finalmente, crie um arquivo blade chamado <code>payment.blade.php<\/code>e adicione o c\u00f3digo abaixo nele.<\/p>\n<pre><code>&lt;form action=\"{{ url('charge') }}\" method=\"post\"&gt;\n\u00a0\u00a0\u00a0\u00a0&lt;input type=\"text\" name=\"amount\" \/&gt;\n\u00a0\u00a0\u00a0\u00a0{{ csrf_field() }}\n\u00a0\u00a0\u00a0\u00a0&lt;input type=\"submit\" name=\"submit\" value=\"Pay Now\"&gt;\n&lt;\/form&gt;<\/code><\/pre>\n<p>Quando enviamos este formul\u00e1rio, o controle vai para a <code>charge<\/code>fun\u00e7\u00e3o no <code>PaymentController<\/code>e o controlador processa o fluxo de pagamento restante.<\/p>\n<h3>Envie informa\u00e7\u00f5es do produto para o PayPal<\/h3>\n<p>Nas etapas anteriores, estamos enviando o valor a pagar no PayPal. Voc\u00ea tamb\u00e9m pode enviar informa\u00e7\u00f5es sobre o produto. O usu\u00e1rio pode ver os detalhes desses produtos na p\u00e1gina de pagamento antes de fazer um pagamento.<\/p>\n<p>Para enviar as informa\u00e7\u00f5es do produto, voc\u00ea precisa passar a matriz &#8216;itens&#8217; para o <code>purchase<\/code>m\u00e9todo a seguir.<\/p>\n<pre><code>$response = $this-&gt;gateway-&gt;purchase(array(\n\u00a0\u00a0\u00a0\u00a0'amount' =&gt; $request-&gt;input('amount'),\n\u00a0\u00a0\u00a0\u00a0'items' =&gt; array(\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0array(\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'name' =&gt; 'Course Subscription',\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'price' =&gt; $request-&gt;input('amount'),\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'description' =&gt; 'Get access to premium courses.',\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'quantity' =&gt; 1\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0),\n\u00a0\u00a0\u00a0\u00a0),\n\u00a0\u00a0\u00a0\u00a0'currency' =&gt; env('PAYPAL_CURRENCY'),\n\u00a0\u00a0\u00a0\u00a0'returnUrl' =&gt; url('paymentsuccess'),\n\u00a0\u00a0\u00a0\u00a0'cancelUrl' =&gt; url('paymenterror'),\n))-&gt;send();<\/code><\/pre>\n<p>Aqui estou passando os detalhes do produto estaticamente. Voc\u00ea deve torn\u00e1-lo din\u00e2mico dependendo do seu produto.<\/p>\n<p>Espero que voc\u00ea conhe\u00e7a a integra\u00e7\u00e3o do gateway de pagamento PayPal no Laravel. Por favor, compartilhe seus pensamentos e sugest\u00f5es na se\u00e7\u00e3o de coment\u00e1rios abaixo.<\/p>\n<h4>Artigos relacionados<\/h4>\n<ul>\n<li><a href=\"https:\/\/themewp.inform.click\/pt-pt\/authorize-net-payment-gateway-integration-no-laravel\/\" title=\"Authorize.Net Payment Gateway Integra\u00e7\u00e3o no Laravel\">Authorize.Net Payment Gateway Integra\u00e7\u00e3o no Laravel<\/a><\/li>\n<li><a href=\"https:\/\/themewp.inform.click\/pt-pt\/integracao-do-stripe-payment-gateway-no-laravel\/\" title=\"Integra\u00e7\u00e3o do Stripe Payment Gateway no Laravel\">Integra\u00e7\u00e3o do Stripe Payment Gateway no Laravel<\/a><\/li>\n<li><a href=\"https:\/\/themewp.inform.click\/pt-pt\/integracao-de-gateway-de-pagamento-paykun-no-laravel\/\" title=\"Integra\u00e7\u00e3o de gateway de pagamento PayKun no Laravel\">Integra\u00e7\u00e3o de gateway de pagamento PayKun no Laravel<\/a><\/li>\n<\/ul>\n<p><div id=\"PostUnique_PostSource\" style=\"padding-top: 50px\">Fonte de grava\u00e7\u00e3o:  <a target=\"_blank\" rel=\"noopener nofollow\" href=\"\/\/artisansweb.net\" class=\"external external_icon\">artisansweb.net<\/a><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Neste artigo, discutimos a integra\u00e7\u00e3o do gateway de pagamento PayPal no Laravel. PayPal \u00e9 uma das plataformas mais populares para aceitar online<\/p>\n","protected":false},"author":1,"featured_media":20137,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_wp_rev_ctl_limit":""},"categories":[502],"tags":[848],"class_list":["post-28841","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","tag-affiai-pt-pt"],"_links":{"self":[{"href":"https:\/\/themewp.inform.click\/pt-pt\/wp-json\/wp\/v2\/posts\/28841","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/themewp.inform.click\/pt-pt\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/themewp.inform.click\/pt-pt\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/themewp.inform.click\/pt-pt\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/themewp.inform.click\/pt-pt\/wp-json\/wp\/v2\/comments?post=28841"}],"version-history":[{"count":0,"href":"https:\/\/themewp.inform.click\/pt-pt\/wp-json\/wp\/v2\/posts\/28841\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/themewp.inform.click\/pt-pt\/wp-json\/wp\/v2\/media\/20137"}],"wp:attachment":[{"href":"https:\/\/themewp.inform.click\/pt-pt\/wp-json\/wp\/v2\/media?parent=28841"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/themewp.inform.click\/pt-pt\/wp-json\/wp\/v2\/categories?post=28841"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/themewp.inform.click\/pt-pt\/wp-json\/wp\/v2\/tags?post=28841"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}