贝宝计费RESTAPI Php问题

贝宝计费RESTAPI Php问题,php,paypal-sandbox,paypal-rest-sdk,recurring-billing,Php,Paypal Sandbox,Paypal Rest Sdk,Recurring Billing,我对Paypal REST Api计费(定期付款)有问题 我的操作与paypal文档中的操作完全相同,但当我单击“付款”按钮时,它会打开空白页(错误日志中没有错误) 以下是我的工作: 前端按钮 <form action="WEBSITE/subscribe/paypal/paypal_agreement.php" method="POST"> <button type="submit" style="mar

我对Paypal REST Api计费(定期付款)有问题

我的操作与paypal文档中的操作完全相同,但当我单击“付款”按钮时,它会打开空白页(错误日志中没有错误)

以下是我的工作:

前端按钮

<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(从paypal文档复制/粘贴)


paypal_createplan.php(从paypal文档复制/粘贴)


execute.php(从paypal文档复制/粘贴)


变量$apiContext应包含paypal应用程序验证和设置配置

变量$apiContext应包含paypal应用程序验证和设置配置

是这样的:“变量$apiContext应包含paypal应用程序验证和设置配置”

这个问题的解决方案是:我对Paypal REST Api计费(定期付款)有问题。我的操作与paypal文档中的操作完全相同,但当我单击“付款”按钮时,它会打开空白页(错误日志中没有错误)

我也有类似的问题。请确认。我们如何获得paypal应用程序认证和设置配置

是这样的:“变量$apiContext应该包含paypal应用程序身份验证和设置配置”

这个问题的解决方案是:我对Paypal REST Api计费(定期付款)有问题。我的操作与paypal文档中的操作完全相同,但当我单击“付款”按钮时,它会打开空白页(错误日志中没有错误)


我也有类似的问题。请确认。我们如何获得paypal应用程序认证和设置配置

是的,就是这样!我没有注意这个变量,直到我理解它应该包含authentication&setConfig。但是用paypal代码扫描所有文件,你会看到很多次,你必须在这里传递paypal变量,这里是如何做的谢谢你。但是我们仍然在获取空白屏幕。检查所有与贝宝计费相关的文件中的所有APPECONTEXT变量。另外,检查PayPal日志和error.log以查看是否存在任何问题是的,就是这样!我没有注意这个变量,直到我理解它应该包含authentication&setConfig。但是用paypal代码扫描所有文件,你会看到很多次,你必须在这里传递paypal变量,这里是如何做的谢谢你。但是我们仍然在获取空白屏幕。检查所有与贝宝计费相关的文件中的所有APPECONTEXT变量。另外,检查PayPal日志和error.log以查看是否存在任何问题
<?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;

?>
<?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;

?>
<?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>';
}