2017-09-08 4 views
1

Ich habe ein Problem mit Paypal REST Api Abrechnung (wiederkehrende Zahlungen).PayPal Rechnung REST Api Php Problem

Ich tat genau wie in paypal Dokumentation, aber wenn ich auf Zahlung Schaltfläche klicke öffnet es leere Seite (keine Fehler im Fehlerprotokoll). Hier

ist, was ich tue:

Front-End-Knopf

<form action="WEBSITE/subscribe/paypal/paypal_agreement.php" method="POST"> 
            <button type="submit" style="margin-top:10px;border: 0; background: transparent"> 
              <img src="WEBSITE/wp-content/uploads/2017/05/paypal.png" style = "width:170px;" alt="submit" /> 
            </button>         
        </form> 

paypal_agreement.php (Kopieren/Einfügen von PayPal docs)

<?php 
require_once("../../paypal/vendor/autoload.php"); 


$createdPlan = require 'paypal_createplan.php'; 

use PayPal\Api\Agreement; 
use PayPal\Api\Payer; 
use PayPal\Api\Plan; 
use PayPal\Api\ShippingAddress; 


$ppstartdate = date('c', time()+210); 

$agreement = new Agreement(); 
$agreement->setName('Title Agreement') 
    ->setDescription('Description Agreement') 
    ->setStartDate($ppstartdate); 

// Add Plan ID 
// Please note that the plan Id should be only set in this case. 
$plan = new Plan(); 
$plan->setId($createdPlan->getId()); 
$agreement->setPlan($plan); 
// Add Payer 
$payer = new Payer(); 
$payer->setPaymentMethod('paypal'); 

$agreement->setPayer($payer); 



// ### Create Agreement 
try { 
    // Please note that as the agreement has not yet activated, we wont be receiving the ID just yet. 
    $agreement = $agreement->create($apiContext); 
    // ### Get redirect url 
    // The API response provides the url that you must redirect 
    // the buyer to. Retrieve the url from the $agreement->getApprovalLink() 
    // method 
    $approvalUrl = $agreement->getApprovalLink(); 

    header("Location: ".$approvalUrl); 
} catch (Exception $ex) { 

    exit(1); 
} 


return $agreement; 

?> 

paypal_createplan.php (Kopieren/Einfügen von Paypal-Dokumenten)

<?php 
require_once("../../paypal/vendor/autoload.php"); 

use PayPal\Api\Currency; 
use PayPal\Api\MerchantPreferences; 
use PayPal\Api\PaymentDefinition; 
use PayPal\Api\Plan; 



// Create a new instance of Plan object 
$plan = new Plan(); 


// # Basic Information 
// Fill up the basic information that is required for the plan 
$plan->setName('Title Plan') 
    ->setDescription('Description Subscription Plan') 
    ->setType('fixed'); 


// # Payment definitions for this billing plan. 
$paymentDefinition = new PaymentDefinition(); 


// The possible values for such setters are mentioned in the setter method documentation. 
// Just open the class file. e.g. lib/PayPal/Api/PaymentDefinition.php and look for setFrequency method. 
// You should be able to see the acceptable values in the comments. 
$paymentDefinition->setName('Regular Payments') 
    ->setType('REGULAR') 
    ->setFrequency('Month') 
    ->setFrequencyInterval("1") 
    ->setCycles("6") 
    ->setAmount(new Currency(array('value' => 94.99, 'currency' => 'USD'))); 

$merchantPreferences = new MerchantPreferences(); 
$baseUrl = "https://websitelink.com"; 

$merchantPreferences->setReturnUrl("$baseUrl/subscribe/paypal/execute.php?success=true") 
->setCancelUrl("$baseUrl/subscribe/paypal/execute.php?success=false") 
->setAutoBillAmount("yes") 
->setInitialFailAmountAction("CONTINUE") 
->setMaxFailAttempts("0") 
->setSetupFee(new Currency(array('value' => 0, 'currency' => 'USD'))); 



// ### Create Plan 
try { 
    $output = $plan->create($apiContext); 
} catch (Exception $ex) { 

    exit(1); 
} 


return $output; 

?> 

execute.php (Kopieren/Einfügen von PayPal docs)

<?php 
// #Execute Agreement 
// This is the second part of CreateAgreement Sample. 
// Use this call to execute an agreement after the buyer approves it 
require_once("../../paypal/vendor/autoload.php"); 

// ## Approval Status 
// Determine if the user accepted or denied the request 
if (isset($_GET['success']) && $_GET['success'] == 'true') { 
$token = $_GET['token']; 
$agreement = new \PayPal\Api\Agreement(); 
try { 
    // ## Execute Agreement 
    // Execute the agreement by passing in the token 
    $agreement->execute($token, $apiContext); 
} catch (Exception $ex) { 

    exit(1); 
} 


// ## Get Agreement 
// Make a get call to retrieve the executed agreement details 
try { 
    $agreement = \PayPal\Api\Agreement::get($agreement->getId(), $apiContext); 

    //done 
    header('Location: https://websitelink.com/subscribe/subscribe.php'); 


} catch (Exception $ex) { 

    exit(1); 
} 

} else { 
    $_SESSION['pmsg'] = $_SESSION['pmsg'].'<h2>Subscription Failed</h2>'; 
} 

Aber ich kann nichts Authentifizierung OAuth2 (wie zum Beispiel mit Express Check-Out), nichts in der Dokumentation finden. Vielleicht funktioniert es deswegen nicht? "Variable $ apiContext enthalten sollte paypal App-Authentifizierung & setConfig"

die Lösung für dieses Problem ?: Ich habe ein Problem mit Paypal:

Antwort

0

Variable $ apiContext paypal App-Authentifizierung & setConfig

0

Ist das enthalten sollte REST Api-Abrechnung (wiederkehrende Zahlungen). Ich tat genau wie in der Paypal-Dokumentation, aber wenn ich auf die Zahlungsschaltfläche klicke, öffnet sich eine leere Seite (keine Fehler im Fehlerprotokoll).

Ich habe ein ähnliches Problem. Bitte bestätigen. Und wie erhalten wir die Paypal App Authentifizierung & setConfig?

+0

Ja, das war es! Ich habe diese Variable nicht beachtet, bis ich verstanden habe, dass sie die Authentifizierung und setConfig enthalten sollte. Aber scannen Sie durch alle Dateien mit Paypal-Code, Sie werden es mehrmals sehen, Sie müssen dort Paypal Variable übergeben – user1584043

+0

http://www.primitivecode.com/index.php?topic=-how%20to-integrate%20paypal% 20payment% 20api-rest-instant-zahlung-php-sdk-install-composer- hier ist, wie es geht – user1584043

+0

Vielen Dank. Aber wir bekommen immer noch den leeren Bildschirm. –

Verwandte Themen