Laravel 6 Paypal Subscription srmklive / paypal проблема - PullRequest
1 голос
/ 16 января 2020

Я добавил пакет srmklive / paypal, хочу сделать подписку PayPal. но он выдает мне это сообщение об ошибке:

ErrorException
Undefined index: paypal_link

Я использую laravel 6 и srmklive / paypal Кто-нибудь может помочь мне решить эту проблему?

.env файл

PAYPAL_MODE=sandbox
PAYPAL_SANDBOX_API_USERNAME=sb-ig0ex880582_api1.business.example.com
PAYPAL_SANDBOX_API_PASSWORD=3PZ2E986EZWQN2PN
PAYPAL_SANDBOX_API_SECRET=AZ2CBQPbtotiGlFrm1tAtmH-bBO3AfpRNGWDT6e68-yh69V.BeCgl7W6
PAYPAL_CURRENCY=USD
PAYPAL_SANDBOX_API_CERTIFICATE=

PaypalController. php файл

public function payment(Request $request)
{
    $data = [];
    $data['items'] = [['name' => "Monthly Subscription", 'price' => 10, 'qty' => 1,],];
    $data['subscription_desc'] = "Monthly Subscription #1";
    $data['invoice_id'] = 1;
    $data['invoice_description'] = "Monthly Subscription #1";
    $data['return_url'] = url('/paypal/ec-checkout-success?mode=recurring');
    $data['cancel_url'] = url('/');
    $total = 0;
    foreach ($data['items'] as $item) {
        $total += $item['price'] * $item['qty'];
    }
    $data['total'] = $total;
    //give a discount of 10% of the order amount
    $data['shipping_discount'] = round((10 / 100) * $total, 2);
    $provider = new ExpressCheckout;
    // Use the following line when creating recurring payment profiles (subscriptions)
    $response = $provider->setExpressCheckout($data);
    $response = $provider->setExpressCheckout($data, true);
    // The $token is the value returned from SetExpressCheckout API call
    $startdate = Carbon::now()->toAtomString();
    $profile_desc = !empty($data['subscription_desc']) ? $data['subscription_desc'] :
    $data['invoice_description'];
    $data = [
        'PROFILESTARTDATE' => $startdate,
        'DESC' => $profile_desc,
        'BILLINGPERIOD' => 'Month', // Can be 'Day', 'Week', 'SemiMonth', 'Month', 'Year'
        'BILLINGFREQUENCY' => 1, //
        'AMT' => 10, // Billing amount for each billing cycle
        'CURRENCYCODE' => 'USD', // Currency code
        'TRIALBILLINGPERIOD' => 'Day', 
        'TRIALBILLINGFREQUENCY' => 10, // (Optional) set 12 for monthly, 52 for yearly
        'TRIALTOTALBILLINGCYCLES' => 1, // (Optional) Change it accordingly
        'TRIALAMT' => 0, // (Optional) Change it accordingly
    ];
    $response = $provider->createRecurringPaymentsProfile($data, $response['TOKEN']);
    // This will redirect user to PayPal
    return redirect($response['paypal_link']);
}
...