Я новичок в реализации Paypal. Поэтому, пожалуйста, будьте терпеливы :-)
Я пытаюсь интегрировать Paypal Plus в магазин TYPO3. С простой кнопкой PayPal это работает нормально.
Для Paypal Plus я создаю такой платеж:
/*-------------------
Paypal START
---------------------*/
if($('#ppplus').length > 0) {
$.get("/fileadmin/shop/paypal.php",
{
'total': paypal_total,
'subtotal': paypal_subtotal,
'tax': paypal_tax,
'shipping': paypal_shipping,
'description': paypal_description,
'invoice_number': 'teetss',
'recipient_name': paypal_recipient_name,
'items':itemlist
},
function (data, status) {
var parsed = $.parseJSON(data);
approvalUrl = parsed.links[1].href;
var ppp = PAYPAL.apps.PPP({
"approvalUrl": approvalUrl,
"placeholder": "ppplus",
"mode": "sandbox",
"country": "DE",
"language": "DE_de"
});
});
}
/*--- Paypal END */
Результат выглядит так:
{id: "PAY-XXX", intent: "sale", state: "created",…}
create_time: "2018-09-13T06:34:28Z"
id: "PAY-XXX"
intent: "sale"
links: [,…]
0: {href: "https://api.sandbox.paypal.com/v1/payments/payment/PAY-XXX", rel: "self",…}
1: {,…}
href: "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-XXX"
method: "REDIRECT"
rel: "approval_url"
2: {href: "https://api.sandbox.paypal.com/v1/payments/payment/PAY-XXX/execute",…}
payer: {payment_method: "paypal"}
payment_method: "paypal"
state: "created"
transactions: [{,…}]
0: {,…}
amount: {total: "34.50", currency: "EUR", details: {subtotal: "24.49", tax: "5.51", shipping: "4.50"}}
currency: "EUR"
details: {subtotal: "24.49", tax: "5.51", shipping: "4.50"}
shipping: "4.50"
subtotal: "24.49"
tax: "5.51"
total: "34.50"
description: "Parkett Herter Shop"
invoice_number: "teetss"
item_list: {}
related_resources: []
paypal.php
<?php
$total = htmlspecialchars($_GET["total"]);
$subtotal = htmlspecialchars($_GET["subtotal"]);
$tax = htmlspecialchars($_GET["tax"]);
$shipping = htmlspecialchars($_GET["shipping"]);
$description = htmlspecialchars($_GET["description"]);
$invoice_number = htmlspecialchars($_GET["invoice_number"]);
$recipient_name = htmlspecialchars($_GET["recipient_name"]);
$items = htmlspecialchars($_GET["items"]);
$ch = curl_init();
$data = '{
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
"transactions": [
{
"amount": {
"total": "'.$total.'",
"currency": "EUR",
"details": {
"subtotal": "'.$subtotal.'",
"tax": "'.$tax.'",
"shipping": "'.$shipping.'"
}
},
"description": "'.$description.'",
"invoice_number": "'.$invoice_number.'",
"item_list": {'.$items.'}
}
],
"redirect_urls": {
"return_url": "xxx",
"cancel_url": "xxx"
}
}';
curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/payments/payment");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"Authorization: Bearer xxx",
"Content-length: ".strlen($data))
);
$output = curl_exec($ch);
curl_close($ch);
//print_r($output);
?>
Итак, создан фрейм "Paypal Wall", и я могу выбрать вариант оплаты. Но когда я перенаправлен на Paypal, нет никакой информации о клиенте, цене ... Что мне не хватает?