(MCH)生成支付JS请求对象

@param prepay_id
预支付订单号
@param appId
appId
@param key
商户支付密钥
@return json
195525
public static String generateMchPayJsRequestJson(String prepay_id, String appId, String key) {
		String package_ = "prepay_id=" + prepay_id;
		Map<String, String> map = new LinkedHashMap<String, String>();
		map.put("appId", appId);
		map.put("nonceStr", UUID.randomUUID().toString().replace("-", ""));
		map.put("package", package_);
		map.put("signType", "MD5");
		map.put("timeStamp", System.currentTimeMillis() / 1000 + "");
		String paySign = SignatureUtil.generateSign(map, key);
		map.put("paySign", paySign);
		return JsonUtil.toJSONString(map);
	}
326270
public static function getJsapiTicket($app_id, $app_secret) {
        $urlObj = array();
        $urlObj['appid'] = $app_id;
        $urlObj['secret'] = $app_secret;
        $urlObj['grant_type'] = 'client_credential';
        $queryStr = http_build_query($urlObj);
        $accessTokenUrl = 'https://api.weixin.qq.com/cgi-bin/token?' . $queryStr;
        $resp = self::_getRequest($accessTokenUrl);
        $resp = json_decode($resp, true);
        if (!is_array($resp) || isset($resp['errcode'])) {
            return $resp;
        }

        $urlObj = array();
        $urlObj['access_token'] = $resp['access_token'];
        $urlObj['type'] = 'jsapi';
        $queryStr = http_build_query($urlObj);
        $jsapiTicketUrl = 'https://api.weixin.qq.com/cgi-bin/ticket/getticket?' . $queryStr;
        $resp = self::_getRequest($jsapiTicketUrl);

        return json_decode($resp, true);
    }
376083
public static function getApiKeyByAppId($id)
    {
        if (!empty($id)) {
            // use local app caching
            $key = static::getCachedInfo($id, 'api_key', null);
            if (!is_null($key)) {
                static::setApiKeyToAppId($key, $id);

                return $key;
            }
        }

        return null;
    }
779595
public Optional<ApplicationInstance> show(long applicationId, long instanceId)
    {
        return HTTP.GET(String.format("/v2/applications/%d/instances/%d.json", applicationId, instanceId), APPLICATION_INSTANCE);
    }
564529
public static Map<String, String> buildShortUrlParasMap(String appid, String sub_appid, String mch_id,
			String sub_mch_id, String long_url, String paternerKey) {
		Map<String, String> params = new HashMap<String, String>();
		params.put("appid", appid);
		params.put("sub_appid", sub_appid);
		params.put("mch_id", mch_id);
		params.put("sub_mch_id", sub_mch_id);
		params.put("long_url", long_url);

		return buildSignAfterParasMap(params, paternerKey);

	}
1175909
public static function initialize($app_id, $app_key, $master_key)
    {
        AVUser::registerSubclass();
        AVRole::registerSubclass();
        AVInstallation::registerSubclass();
        self::$applicationId = $app_id;
        self::$appKey = $app_key;
        self::$masterKey = $master_key;;
        if (!static::$storage)
        {
            if (session_status() === PHP_SESSION_ACTIVE)
            {
                self::setStorage(new AVSessionStorage());
            } else
            {
                self::setStorage(new AVMemoryStorage());
            }
        }
    }
428912
function(req) {

    var pk = module.exports.parsePk(req);

    // Validate the required `id` parameter
    if (!pk) {

      var err = new Error(
        'No `id` parameter provided.' +
        '(Note: even if the model\'s primary key is not named `id`- ' +
        '`id` should be used as the name of the parameter- it will be ' +
        'mapped to the proper primary key name)'
      );
      err.status = 400;
      throw err;
    }

    return pk;
  }
110976
def get_prepare_by_id(
            self,
            prepare_id=None):
        

        if not prepare_id:
            log.error("missing prepare_id for get_prepare_by_id")
            return self.build_response(
                status=ERROR,
                error="missing prepare_id for get_prepare_by_id")

        if self.debug:
            log.info(("user={} getting prepare={}")
                     .format(
                        self.user,
                        prepare_id))

        url = "{}{}".format(
                self.api_urls["prepare"],
                prepare_id)

        not_done = True
        while not_done:

            if self.debug:
                log.info((
                    "JOB attempting to get={} to url={} "
                    "verify={} cert={}").format(
                        prepare_id,
                        url,
                        self.use_verify,
                        self.cert))

            response = requests.get(
                url,
                verify=self.use_verify,
                cert=self.cert,
                headers=self.get_auth_header())

            if self.debug:
                log.info(("JOB response status_code={} text={} reason={}")
                         .format(
                            response.status_code,
                            response.text,
                            response.reason))

            if response.status_code == 401:
                login_res = self.retry_login()
                if login_res["status"] != SUCCESS:
                    if self.verbose:
                        log.error(
                            "retry login attempts failed")
                    return self.build_response(
                        status=login_res["status"],
                        error=login_res["error"])
                # if able to log back in just retry the call
            elif response.status_code == 200:

                if self.verbose:
                    log.debug("deserializing")

                prepare_data = json.loads(
                    response.text)

                prepare_id = prepare_data.get(
                    "id",
                    None)

                if not prepare_id:
                    return self.build_response(
                        status=ERROR,
                        error="missing prepare.id",
                        data="text={} reason={}".format(
                            response.reason,
                            response.text))

                self.all_prepares[str(prepare_id)] = prepare_data

                if self.debug:
                    log.info(("added prepare={} all_prepares={}")
                             .format(
                                prepare_id,
                                len(self.all_prepares)))

                return self.build_response(
                    status=SUCCESS,
                    error="",
                    data=prepare_data)
            else:
                err_msg = ("failed with "
                           "status_code={} text={} reason={}").format(
                               response.status_code,
                               response.text,
                               response.reason)
                if self.verbose:
                    log.error(err_msg)
                return self.build_response(
                    status=ERROR,
                    error=err_msg)
604360
function ( appRequest, appResponse ) {
    var cacheHtml = null,
        cacheJson = null,
        cacheName = null,
        slugged = slug( appRequest.params[ 0 ].replace( /\//g, "-" ).replace( /-$/g, "" ) ),
        reqSlug = ( slugged === "" ) ? "-homepage" : slugged,
        url = appRequest.params[ 0 ],
        qrs = {};

    cacheName = ("page" + reqSlug);

    // Querystring?
    for ( var i in appRequest.query ) {
        qrs[ i ] = appRequest.query[ i ];

        // Unique cache file name including queries
        if ( i !== "format" && i !== "password" && i !== "nocache" ) {
            cacheName += ("-" + i + "--" + qrs[ i ]);
        }
    }

    cacheHtml = sqsCache.get( (cacheName + ".html") );
    cacheJson = sqsCache.get( (cacheName + ".json") );

    // 404 JSON?
    if ( cacheJson && !pageNotFoundJson ) {
        setPageNotFoundJson( cacheJson );
    }

    // Nocache?
    if ( appRequest.query.nocache !== undefined ) {
        cacheJson = null;
        cacheHtml = null;

        sqsCache.remove( (cacheName + ".html") );
        sqsCache.remove( (cacheName + ".json") );
        sqsCache.remove( (cacheName + "-main-content.html") );
    }

    // Search?
    if ( slugged === "search" ) {
        if ( cacheHtml ) {
            appResponse.status( 200 ).send( cacheHtml );

        } else {
            sqsWare.getHtml( url, qrs, function ( error, data ) {
                if ( !error ) {
                    appResponse.status( 200 ).send( data.html );

                    sqsCache.set( (cacheName + ".html"), data.html );

                } else {
                    // Handle errors
                    nsl.log( "error", ("Error requesting system search page => " + error) );
                }
            });
        }

        return;
    }

    // Cache?
    if ( cacheJson && cacheHtml && !rJson.test( appRequest.query.format ) ) {
        sqsTemplate.renderTemplate( qrs, cacheJson, cacheHtml, function ( tpl ) {
            appResponse.status( 200 ).send( tpl );
        });

        return;
    }

    // JSON?
    // Supports `json` and `json-pretty`
    if ( rJson.test( appRequest.query.format ) ) {
        if ( cacheJson ) {
            cacheJson.nodeServer = true;

            appResponse.status( 200 ).json( cacheJson );

        } else {
            sqsWare.getJson( url, qrs, function ( error, json ) {
                if ( !error ) {
                    json.json.nodeServer = true;

                    sqsCache.set( (cacheName + ".json"), json.json );

                    appResponse.status( 200 ).json( json.json );

                } else {
                    // Handle errors
                    nsl.log( "error", ("Error requesting page json => " + error) );
                }
            });
        }

    // Main-Content
    } else if ( appRequest.query.format === "main-content" ) {
        cacheHtml = sqsCache.get( (cacheName + "-main-content.html") );

        if ( cacheHtml ) {
            appResponse.status( 200 ).send( cacheHtml );

        } else {
            sqsWare.getHtml( url, qrs, function ( error, data ) {
                if ( !error ) {
                    appResponse.status( 200 ).send( data.html );

                    sqsCache.set( (cacheName + "-main-content.html"), data.html );

                } else {
                    // Handle errors
                    nsl.log( "error", ("Error requesting main-content for page => " + error) );
                }
            });
        }

    // Request page?
    } else {
        sqsWare.getJsonAndHtml( url, qrs, function ( error, data ) {
            if ( !error ) {
                sqsCache.set( (cacheName + ".json"), data.json.json );
                sqsCache.set( (cacheName + ".html"), data.html.html );

                // 404 JSON?
                if ( !pageNotFoundJson ) {
                    setPageNotFoundJson( data.json.json );
                }

                sqsTemplate.renderTemplate( qrs, data.json.json, sqsCache.get( (cacheName + ".html") ), function ( tpl ) {
                    appResponse.status( 200 ).send( tpl );
                });

            } else {
                // Handle errors
                nsl.log( "error", ("Error requesting page => " + error) );

                // Could be a 404 though so serve it
                if ( data.html.status === 404 || data.json.status === 404 ) {
                    //appResponse.status( 200 ).send( data.html.html );
                    sqsTemplate.renderTemplate( qrs, pageNotFoundJson, data.html.html, function ( tpl ) {
                        appResponse.status( 404 ).send( tpl );
                    });

                    nsl.log( "warn", ("Request responded with server code 404 for => `" + url + "`") );

                    return;
                }
            }
        });
    }
}
1313939
@Action(name = "List Prepender",
            outputs = {
                    @Output(RESPONSE),
                    @Output(RETURN_RESULT),
                    @Output(RETURN_CODE)
            },
            responses = {
                    @Response(text = SUCCESS, field = RETURN_CODE, value = RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL),
                    @Response(text = FAILURE, field = RETURN_CODE, value = RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, isOnFail = true, isDefault = true)
            })
    public Map<String, String> prependElement(@Param(value = LIST, required = true) String list,
                                              @Param(value = ELEMENT, required = true) String element,
                                              @Param(value = DELIMITER) String delimiter) {
        Map<String, String> result = new HashMap<>();
        try {
            StringBuilder sb = new StringBuilder();
            sb = StringUtils.isEmpty(list) ? sb.append(element) : sb.append(element).append(delimiter).append(list);
            result.put(RESPONSE, SUCCESS);
            result.put(RETURN_RESULT, sb.toString());
            result.put(RETURN_CODE, RETURN_CODE_SUCCESS);
        } catch (Exception e) {
            result.put(RESPONSE, FAILURE);
            result.put(RETURN_RESULT, e.getMessage());
            result.put(RETURN_CODE, RETURN_CODE_FAILURE);
        }
        return result;
    }
579432
function prepXHR(method, url, headers, callback, withCredentials, type, manager) {
    var xhr = new XHR();
    var status;

    xhr.open(method, url, true);

    if (type) {
      xhr.type = type;
      headers['Content-Type'] = type;
    }

    angular.forEach(headers, function(value, key) {
      (value) ? xhr.setRequestHeader(key, value) : null;
    });

    manager.register(xhr);

    xhr.onreadystatechange = function() {
      if (xhr.readyState == 4) {
        manager.unregister(xhr);
        var response = xhr.response || xhr.responseText;
        callback(status = status || xhr.status, response, xhr.getAllResponseHeaders());
      }
    };

    if (withCredentials) {
      xhr.withCredentials = true;
    }
    return xhr;
  }
258617
protected void appendAppId(ApplicationId appId, Message m) {
    if (appId == null) {
      return;
    }

    // check if any application-id avp is already present.
    // we could use m.getApplicationIdAvps().size() > 0 but this should spare a few cpu cycles
    for (Avp avp : m.getAvps()) {
      int code = avp.getCode();
      if (code == Avp.ACCT_APPLICATION_ID || code == Avp.AUTH_APPLICATION_ID || code == Avp.VENDOR_SPECIFIC_APPLICATION_ID) {
        return;
      }
    }

    if (appId.getVendorId() == 0) {
      if (appId.getAcctAppId() != 0) {
        m.getAvps().addAvp(Avp.ACCT_APPLICATION_ID, appId.getAcctAppId(), true, false, true);
      }
      if (appId.getAuthAppId() != 0) {
        m.getAvps().addAvp(Avp.AUTH_APPLICATION_ID, appId.getAuthAppId(), true, false, true);
      }
    }
    else {
      AvpSet avp = m.getAvps().addGroupedAvp(Avp.VENDOR_SPECIFIC_APPLICATION_ID, true, false);
      avp.addAvp(Avp.VENDOR_ID, appId.getVendorId(), true, false, true);
      if (appId.getAuthAppId() != 0) {
        avp.addAvp(Avp.AUTH_APPLICATION_ID, appId.getAuthAppId(), true, false, true);
      }
      if (appId.getAcctAppId() != 0) {
        avp.addAvp(Avp.ACCT_APPLICATION_ID, appId.getAcctAppId(), true, false, true);
      }
    }
  }
169225
private String createRow(String key, String appid, Map<String, AttributeValue> row) {
		if (StringUtils.isBlank(key) || StringUtils.isBlank(appid) || row == null || row.isEmpty()) {
			return null;
		}
		try {
			key = getKeyForAppid(key, appid);
			setRowKey(key, row);
			PutItemRequest putItemRequest = new PutItemRequest(getTableNameForAppid(appid), row);
			client().putItem(putItemRequest);
		} catch (Exception e) {
			logger.error("Could not write row to DB - appid={}, key={}", appid, key, e);
			throwIfNecessary(e);
		}
		return key;
	}
1009580
public static Jscode2sessionResult jscode2session(String appid,String secret,String js_code){
		HttpUriRequest httpUriRequest = RequestBuilder.get()
			.setUri(BASE_URI + "/sns/jscode2session")
			.addParameter("appid",appid)
			.addParameter("secret",secret)
			.addParameter("js_code",js_code)
			.addParameter("grant_type","authorization_code")
			.build();
		return LocalHttpClient.executeJsonResult(httpUriRequest,Jscode2sessionResult.class);
	}
1366611
public static String buildRequestMysign(Map<String, String> params, String key, String signType) {
		String prestr = createLinkString(params); // 把数组所有元素，按照“参数=参数值”的模式用“&”字符拼接成字符串
		if (signType.equals("MD5")) {
			return HashKit.md5(prestr.concat(key));
		}
		return null;
	}
952073
public static String getKeyForAppid(String key, String appIdentifier) {
		if (StringUtils.isBlank(key) || StringUtils.isBlank(appIdentifier)) {
			return key;
		}
		if (isSharedAppid(appIdentifier)) {
			// app is sharing a table with other apps, key is composite "appid_key"
			return keyPrefix(appIdentifier) + key;
		} else {
			return key;
		}
	}
623463
@Override
    public InstanceInfo getInstanceByAppAndId(String appName, String id) {
        return this.getInstanceByAppAndId(appName, id, true);
    }