Last updated on the 28th. August 2020 at 5:14 p.m.
In this lesson I will explain how we can integrate the Paypal payment gateway into our PHP application. If you want to know more about integration with other payment gateways, please read these messages. The integration of the Paypal payment gateway into the web application takes a few minutes. Before we start, I hope you have a PayPal account or can create a free PayPal developer account.
Real-time demonstration : – PayPal Payment Gateway
Requirements
Here are the steps that can help you integrate PayPal into PHP applications.
PayPalPayment gateway
Step one. Before you start the integration, you can create a PayPal account and retrieve your sandbox login details. Go to developer.paypal.com and register. After logging in, click on the Account menu on the left side of the screen, below the Sandbox, as shown in the figure below.
You can create a new account by clicking on the Create Account button. You cannot use real mail for the sandbox mode.
Step two. You will also need a customer identification and a customer secret, which you can obtain from the My Applications menu and the toolbar login details. Click on View to reveal the secret.
Step three. We now need to install the PHP SDK from Paypal, then you can install the plugin together with the composer.
the composer needs Paypal/rest-api-sdp-php:*
Step four. Now, once our plugin is installed, you will need to create a new PHP file where we can download this plugin and make the payment via Paypal. I create an index.php file in which I create a form in which I simply provide the name and price of the product.
Product = $_POST [Product];
$Entry_amount = $_POST [Amount] ;
Fee in $ = https://demo.trinitytuts.com/paypal/callback.php ; currency exchange
$ = https://demo.trinitytuts.com/paypal/canceled.php ; currency
$ = ‘USD’ ;
$apiContext = new PayPalRestApiContext(
new PayPalAuthOAuthTokenCredential(
‘ATQPCjSAopkGqgqea7ShUok5nlSYaqY5OAl9Td3l9bCBi5F6pC9QgKWkLzZXvkhyVde4Cp2eCxYtSZSo’, // Customer ID
‘EBWXI5X8os7IprmNy94oMeCZhruzJije55Yh5Pv7hUZ5hnCbTsHfr4hiDBz7f0XFvRakf0iuoE1XIH’ // Customer Secrecy
)
) ;
$apiContext->setConfig(
array(
‘mode’ => ‘sandbox’,
)
) ;
$payer = new payer() ;
$payer->setPaymentMethod(paypal) ;
$item1 = new item();
$item1->setName($Product)
->setCurrency(‘USD’)
->setQuantity(1)
->setSku(1) // Same as item number in the classic API
->setPrice($Input_Amount);
$itemArr[] = $item1
$itemList = new ItemList() ;
$itemList–>setItems($itemArr) ;
$details = new details();
$details->setShipping(0)
->setTax(0)
->setSubtotal($enter_amount) ;
Amount $ = new amount();
Amount $->setCurrency(USD)
->setTotal($Input Amount)
->setDetails($Details) ;
transaction = new transaction();
$ transaction->setAmount($amount)
->setItemList($itemList)
->setDescription(payment description)
->setInvoice number(uniqid()) ;
$redirectUrls = new RedirectUrls() ;
$redirectUrls->setReturnUrl($return?success=true)
->setCancelUrl($cancel?success=false) ;
$payment = new payment();
$payment->setIntent(sales)
->setPayer($payer)
->setRedirectUrls($redirectUrls)
->setTransactions(array($transaction)) ;
$Proceeds = Payment of cloning $ ;
try {
$payment->create($apiContext);
}catch (exception $ex) {
$error = $ex;
echo
“;
print_r($error) ;
}
$approvalUrl = $payment->getApprovalLink();
parse_str($approvalUrl, $url) ;
title (location: $ resolutionUrl);
dies;
}
?>
<Html Doctype
Paypal-PHP integration example
Top of Form
Product
Amount
Steer.
Bottom of Form
https://code.jquery.com/jquery-3.4.1.slim.min.js
https://cdn.jsdelivr.net/npm/ [protected e-mail]/dist/dist/um/popper.min.js
https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js.
Step five. You will also need to create a callback.php file, a trade response from the Paypal gateway.
Currency = USD ;
$apiContext = new PayPalRestApiContext(
new PayPalAuthOAuthTokenCredential(
‘ATQPCjSAopkGqgqea7ShUok5nlSYaqY5OAl9Td3l9bCBi5F6pC9QgKWkLzZXvkhyVde4Cp2eCxYtSZSo’, // Customer ID
‘EBWXI5X8os7IprmNy94oMeCZhruzJije55Yh5Pv7hUZ5hnCbTsHfr4hiDBz7f0XFvRakf0iuoE1XIH’ // Customer Secrecy
)
) ;
$apiContext->setConfig (
array (
‘mode’ => ‘sandbox’,
)
) ;
$token = $_GET[‘token’] ;
$paymentId = $_GET[‘paymentId’] ;
$payerId = $_GET[‘PayerID’] ;
$payment = Payment::get($paymentId, $apiContext) ;
$uitvoering = new payment execution() ;
$uitvoering->setPayerId($payerId) ;
$result = $payment ->execution ($execution, $apiContext) ;
$Payment = Payment: :get($paymentId, $apiContext) ;
$-Transactions = $payment->getTransactions() ;
$-Transaction = $-Transactions[0] ;
$-RelatedResources = $-Transaction->getRelatedResources() ;
$-RelatedResource = $-RelatedResources[0] ;
$-Sales = $-RelatedResources[0]->getSale() ;
$-SalesId = $-Sales->getId() ;
$sale = Dirty::get($saleId, $apiContext) ;
$data[‘reference_id’] = $token;
$data[‘payment_request_id’] = $paymentId;
$data[‘payment_id’] = $sale->getID();
$data[‘response’] = ‘{invoice_no : ‘.$sale->invoice number…, method: paypal}’;
$data[‘payment_status’] = $sale->getState() ;
ultrasound
“;
print_r($data) ;
}
You can now test it in your browser, and if all works well, you can update your API key with live details. I’m also making a demo for this example You can try out this link: – Paypal Payment is a real example.
If my mail helps you, don’t forget to enjoy our Facebook page and subscribe to our YouTube channel.
Related Tags:
mail.ru virus reddit,mail ru virus amazon,how to remove mail ru from opera,search mail ru ie_addon_dll dll,mail ru hijacker,delete искать в интернете,faxir.ru virus,block mail ru,mail ru updater,zemana antimalware,malwarebytes free,how to completely remove mail ru virus,clck ru virus,is mail.ru safe,how to delete mail.ru account,horux.cz virus