Pay upon Invoice not showing

rocketcmd
Contributor
Contributor

Hi, so I want to integrate PayPal Plus (inclusive the Pay upon Invoice feature from Paypal Plus Germany) in my webshop by coding.

 

Everything is working fine, all payment methos (PayPal, CreditCard and Lastschrift) are showing except Pay upon Invoice.

 

 

adewfgr.PNG

Even when I add showPuiOnSandbox: "true" it does not change.

I have also tried adding a shipping address, nothing changes...

PayPal Support is saying, that pay upon invoice is activated on my account.

 

Thank you very much for your help!

 

 

My Code:

if (isset($_GET['test_paypal']))
{
$client_id = 'REMOVED';
$secret = 'REMOVED';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/oauth2/token");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, $client_id.":".$secret);
curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=client_credentials");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/json", "Accept-Language: de_DE"));
$result = curl_exec($ch);

$result = json_decode($result);
$accesstoken = $result->access_token;

$postdata = '{
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
"transactions": [{
"amount": {
"total": "21.50",
"currency": "EUR",
"details": {
"subtotal": "15.00",
"tax": "2.00",
"shipping": "2.50",
"handling_fee": "1.00",
"shipping_discount": "-1.00",
"insurance": "2.00"
}
}, 

"description": "This is the payment transaction description.",
"custom": "This is a hidden value",
"invoice_number": "unique_invoice_number",

"soft_descriptor": "your order description",
"item_list": {
"items": [{
"name": "Item 1",
"description": "add description here",
"quantity": "2",
"price": "10.00",
"sku": "1",
"currency": "EUR"
},
{
"name": "Voucher",
"description": "discount on your order",
"quantity": "1",
"price": "-5.00",
"sku": "vouch1",
"currency": "EUR"
}
]
}
}],
"note_to_payer": "Contact us for any questions on your order.",
"redirect_urls": {
"return_url": "http://example.com/success",
"cancel_url": " http://example.com/cancel"
}
}'; 


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/payments/payment");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"Authorization: Bearer ".$accesstoken,
"Content-length: ".strlen($postdata))
);
$result = curl_exec($ch);

$result = json_decode($result);

?>
<script src=" https://www.paypalobjects.com/webstatic/ppplus/ppplus.min.js" type="text/javascript"></script>

<div id="ppplus"></div>

<script type="application/javascript">
var ppp = PAYPAL.apps.PPP({
"approvalUrl": "<?php echo $result->links[1]->href; ?>",
"placeholder": "ppplus",
"mode": "sandbox",
"country": "DE"
});
</script>
<?php

exit;

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.