Spreedly.php第139行的Spreedly-> validateConfig()中的Spreedly.php 139行的InvalidConfigException

时间:2019-02-12 06:34:59

标签: laravel payment lumen spreedly

public static void main(String[] args) { final int count = countXX("abcxx efjxx xyzxx xx xxxx xx","xx"); System.out.println(count); } static int countXX(final String text, final String occurrenceOf){ int count = 0; int fromIndex=0; for (int i = 0; i < text.length() - 1; i++) { int index = text.indexOf(occurrenceOf,fromIndex); if(index >-1) { count++; fromIndex=index+1; } } return count; } ----!isset条件即使在数组中包含数据后也会失败。默认情况下,写入了$ this-> config ['key'],但它给了我未定义的index:key。

我无法找到合适的文档。任何帮助将不胜感激。

注意:我已成功从curl中获取令牌,因此我认为我的密钥或机密没有任何问题。

services.php

$this->config['spreedly']['key']

Spreedly.php

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://core.spreedly.com/v1/gateways.json');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\n        \"gateway\": {\n          \"gateway_type\": \"test\"\n        }\n      }");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, 'key' . ':' . 'secret');

$headers = array();
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);

// print_r($result);
$token = json_decode($result,true);

$token = $token['gateway']['token'];
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close ($ch);

///////////CURL ENDS///////////

$config =  [

    'spreedly' => [
        'key' => 'added my key here', // (required) Environment key
        'secret' => 'secret here', // (required) Signing Secret
        'gateway' => $token, // (required) Default gateway
        'timeout' => '64', // (optional) Default 64 seconds (recommended by Spreedly)
        'connect_timeout' => '10', // (optional) Default 10 seconds
    ]

];

$spreedly = new Tuurbo\Spreedly\Spreedly($config);
?>

0 个答案:

没有答案