Created
August 16, 2020 17:27
-
-
Save sachaarbonel/bd806feaf40b2ba63114dcdeb4581ae2 to your computer and use it in GitHub Desktop.
Stripe complete payment cycle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h2> Purchasable APIs</h2> | |
<script> | |
window.onload = function() { | |
$.ajax({ | |
type: "GET", | |
url: "http://localhost:8080/public-apis/pub-catalogues", | |
beforeSend: function() | |
{ | |
$('html, body').animate({scrollTop: 0 | |
}, 'slow'); | |
$("#response").html('<img src="loading.gif" align="absmiddle" alt="Loading..."> Loading...<br clear="all" /><br clear="all" />'); | |
}, | |
success: function(response) | |
{ | |
var htmlResponse = '<table id=results>\ | |
<thead>\ | |
<tr>\ | |
<th>API Name</th>\ | |
<th>Auth Type</th>\ | |
<th>Documentation</th>\ | |
<th>Purchase</th>\ | |
</tr>\ | |
</thead>\ | |
<tbody id="myTable">' | |
JSON.parse(response).apis.forEach( item => { | |
htmlResponse += ' <tr>\ | |
<td>' + item.name + '</td>\ | |
<td>' + item.auth_type + '</td>\ | |
<td><button><a href="/portal/apis/' + item.documentation + '/documentation/">View</a></button></td>\ | |
<td><button><a href="/portal/member/policies/' + item.policy_id + '/request">Purchase</a></button></td>\ | |
</tr>' | |
}); | |
htmlResponse += "</tbody></table>" | |
$('#results')[0].innerHTML = htmlResponse; | |
} | |
}); | |
$("#myInput").on("keyup", function() { | |
var value = $(this).val().toLowerCase(); | |
$("#myTable tr").filter(function() { | |
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1) | |
}); | |
}); | |
} | |
</script> | |
<style> | |
table { | |
font-family: arial, sans-serif; | |
border-collapse: collapse; | |
width: 100%; | |
} | |
td, th { | |
border: 1px solid #dddddd; | |
text-align: left; | |
padding: 8px; | |
} | |
tr:nth-child(even) { | |
background-color: #dddddd; | |
} | |
</style> | |
<p>Type something in the input field to search the table for first names, last names or emails:</p> | |
<input id="myInput" type="text" placeholder="Search.."> | |
<br><br> | |
<div id=results> | |
</results> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Load Stripe.js on your website. --> | |
<script src="https://js.stripe.com/v3"></script> | |
<div id="error-message"></div> | |
<script> | |
(function() { | |
var stripe = Stripe('pk_test_5g4wAI1HJihkJGvaXtKNtlrR00gNwgXubC'); | |
// When the customer clicks on the button, redirect | |
// them to Checkout. | |
stripe.redirectToCheckout({ | |
items: [{sku: 'sku_Fv3BrX8w9kR2QK', quantity: 1}], | |
// Do not rely on the redirect to the successUrl for fulfilling | |
// purchases, customers may not always reach the success_url after | |
// a successful payment. | |
// Instead use one of the strategies described in | |
// https://stripe.com/docs/payments/checkout/fulfillment | |
clientReferenceId: new URLSearchParams(window.location.search).get('tyk_key_request_id'), | |
successUrl: 'http://www.tyk-portal-test.com:3000/portal/success', | |
cancelUrl: 'http://www.tyk-portal-test.com:3000/portal/fail', | |
}) | |
.then(function (result) { | |
if (result.error) { | |
// If `redirectToCheckout` fails due to a browser or network | |
// error, display the localized error message to your customer. | |
var displayError = document.getElementById('error-message'); | |
displayError.textContent = result.error.message; | |
} | |
}); | |
})(); | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"api_id": "8f6afaf66aa84da6517614897b8da5c3", | |
"jwt_issued_at_validation_skew": 0, | |
"upstream_certificates": {}, | |
"use_keyless": true, | |
"enable_coprocess_auth": false, | |
"base_identity_provided_by": "", | |
"custom_middleware": { | |
"pre": [], | |
"post": [], | |
"post_key_auth": [], | |
"auth_check": { | |
"name": "", | |
"path": "", | |
"require_session": false, | |
"raw_body_only": false | |
}, | |
"response": [], | |
"driver": "", | |
"id_extractor": { | |
"extract_from": "", | |
"extract_with": "", | |
"extractor_config": {} | |
} | |
}, | |
"disable_quota": false, | |
"custom_middleware_bundle": "", | |
"cache_options": { | |
"cache_timeout": 60, | |
"enable_cache": true, | |
"cache_all_safe_requests": false, | |
"cache_response_codes": [], | |
"enable_upstream_cache_control": false, | |
"cache_control_ttl_header": "", | |
"cache_by_headers": [] | |
}, | |
"enable_ip_blacklisting": false, | |
"tag_headers": [], | |
"jwt_scope_to_policy_mapping": {}, | |
"pinned_public_keys": {}, | |
"expire_analytics_after": 0, | |
"domain": "", | |
"openid_options": { | |
"providers": [], | |
"segregate_by_client": false | |
}, | |
"jwt_policy_field_name": "", | |
"enable_proxy_protocol": false, | |
"jwt_default_policies": [], | |
"active": true, | |
"jwt_expires_at_validation_skew": 0, | |
"config_data": {}, | |
"notifications": { | |
"shared_secret": "", | |
"oauth_on_keychange_url": "" | |
}, | |
"jwt_client_base_field": "", | |
"auth": { | |
"use_param": false, | |
"param_name": "", | |
"use_cookie": false, | |
"cookie_name": "", | |
"auth_header_name": "Authorization", | |
"use_certificate": false, | |
"validate_signature": false, | |
"signature": { | |
"algorithm": "", | |
"header": "", | |
"secret": "", | |
"allowed_clock_skew": 0, | |
"error_code": 0, | |
"error_message": "" | |
} | |
}, | |
"check_host_against_uptime_tests": false, | |
"auth_provider": { | |
"name": "", | |
"storage_engine": "", | |
"meta": {} | |
}, | |
"blacklisted_ips": [], | |
"hmac_allowed_clock_skew": -1, | |
"dont_set_quota_on_create": false, | |
"uptime_tests": { | |
"check_list": [], | |
"config": { | |
"expire_utime_after": 0, | |
"service_discovery": { | |
"use_discovery_service": false, | |
"query_endpoint": "", | |
"use_nested_query": false, | |
"parent_data_path": "", | |
"data_path": "", | |
"cache_timeout": 60 | |
}, | |
"recheck_wait": 0 | |
} | |
}, | |
"enable_jwt": false, | |
"do_not_track": false, | |
"name": "public-apis", | |
"slug": "public-apis", | |
"oauth_meta": { | |
"allowed_access_types": [], | |
"allowed_authorize_types": [], | |
"auth_login_redirect": "" | |
}, | |
"CORS": { | |
"enable": true, | |
"max_age": 24, | |
"allow_credentials": false, | |
"exposed_headers": [], | |
"allowed_headers": [ | |
"Access-Control-Allow-Origin" | |
], | |
"options_passthrough": true, | |
"debug": false, | |
"allowed_origins": [ | |
"*" | |
], | |
"allowed_methods": [ | |
"GET" | |
] | |
}, | |
"event_handlers": { | |
"events": {} | |
}, | |
"proxy": { | |
"target_url": "http://httpbin.org/", | |
"service_discovery": { | |
"endpoint_returns_list": false, | |
"cache_timeout": 0, | |
"parent_data_path": "", | |
"query_endpoint": "", | |
"use_discovery_service": false, | |
"_sd_show_port_path": false, | |
"target_path": "", | |
"use_target_list": false, | |
"use_nested_query": false, | |
"data_path": "", | |
"port_data_path": "" | |
}, | |
"check_host_against_uptime_tests": false, | |
"transport": { | |
"ssl_insecure_skip_verify": false, | |
"ssl_ciphers": [], | |
"ssl_min_version": 0, | |
"ssl_force_common_name_check": false, | |
"proxy_url": "" | |
}, | |
"target_list": [], | |
"preserve_host_header": false, | |
"strip_listen_path": true, | |
"enable_load_balancing": false, | |
"listen_path": "/public-apis/", | |
"disable_strip_slash": false | |
}, | |
"client_certificates": [], | |
"use_basic_auth": false, | |
"version_data": { | |
"not_versioned": true, | |
"default_version": "", | |
"versions": { | |
"Default": { | |
"name": "Default", | |
"expires": "", | |
"paths": { | |
"ignored": [], | |
"white_list": [], | |
"black_list": [] | |
}, | |
"use_extended_paths": true, | |
"global_headers": {}, | |
"global_headers_remove": [], | |
"ignore_endpoint_case": false, | |
"global_size_limit": 0, | |
"override_target": "", | |
"extended_paths": { | |
"virtual": [ | |
{ | |
"response_function_name": "fetchAPICatalogues", | |
"function_source_type": "blob", | |
"function_source_uri": "ZnVuY3Rpb24gZmV0Y2hBUElDYXRhbG9ndWVzKHJlcXVlc3QsIHNlc3Npb24sIGNvbmZpZykgewogICAgCiAgICAvL01ha2UgYXBpIGNhbGwgdG8gdXBzdHJlYW0gdGFyZ2V0CiAgICBuZXdSZXF1ZXN0ID0gewogICAgICAiTWV0aG9kIjogIkdFVCIsCiAgICAgICJEb21haW4iOiAiaHR0cDovL2hvc3QuZG9ja2VyLmludGVybmFsOjMwMDAiLAogICAgICAicmVzb3VyY2UiOiAiL2FwaS9wb3J0YWwvY2F0YWxvZ3VlIiwKICAgICAgIkhlYWRlcnMiOiB7CiAgICAgICAgICAiQXV0aG9yaXphdGlvbiI6ICJkYjUxOWFiNjMzMTk0YjNjNTg1NTM5MDRkMmU1M2FhYiIKICAgICAgfQogICAgfTsKICAgIAogICAgYXBpQ2F0YWxvZ3VlID0gSlNPTi5wYXJzZShKU09OLnBhcnNlKFR5a01ha2VIdHRwUmVxdWVzdChKU09OLnN0cmluZ2lmeShuZXdSZXF1ZXN0KSkpLmJvZHkpCiAgICAKICAgICAgdmFyIHJlc3BvbnNlT2JqZWN0ID0gewogICAgICAgIEJvZHk6IEpTT04uc3RyaW5naWZ5KGFwaUNhdGFsb2d1ZSksCiAgICAgICAgQ29kZTogMjAwIAogICAgICB9CiAgICAgIHJldHVybiBUeWtKc1Jlc3BvbnNlKHJlc3BvbnNlT2JqZWN0LCBzZXNzaW9uLm1ldGFfZGF0YSkKfQ==", | |
"path": "pub-catalogue", | |
"method": "GET", | |
"use_session": false, | |
"proxy_on_error": false | |
}, | |
{ | |
"response_function_name": "approveKeyRequest", | |
"function_source_type": "blob", | |
"function_source_uri": "ZnVuY3Rpb24gYXBwcm92ZUtleVJlcXVlc3QocmVxdWVzdCwgc2Vzc2lvbiwgY29uZmlnKSB7CiAgdmFyIHJlcXVlc3RCb2R5ID0gSlNPTi5wYXJzZShyZXF1ZXN0LkJvZHkpCiAgbG9nKHJlcXVlc3RCb2R5LmRhdGEub2JqZWN0LmNsaWVudF9yZWZlcmVuY2VfaWQpOwogIAogIHZhciBrZXlBcHByb3ZlUmVzb3VyY2UgPSAnL2FwaS9wb3J0YWwvcmVxdWVzdHMvYXBwcm92ZS8nICsgcmVxdWVzdEJvZHkuZGF0YS5vYmplY3QuY2xpZW50X3JlZmVyZW5jZV9pZCAKICAKICBuZXdSZXF1ZXN0ID0gewogICAgICAiSGVhZGVycyI6IHsiQXV0aG9yaXphdGlvbiI6ImRiNTE5YWI2MzMxOTRiM2M1ODU1MzkwNGQyZTUzYWFiIn0sCiAgICAgICJNZXRob2QiOiAiUFVUIiwKICAgICAgIkRvbWFpbiI6ICdodHRwOi8vaG9zdC5kb2NrZXIuaW50ZXJuYWw6MzAwMCcsCiAgICAgICJyZXNvdXJjZSI6IGtleUFwcHJvdmVSZXNvdXJjZSwKICAgIH07CgogcmVzcG9uc2UgPSBUeWtNYWtlSHR0cFJlcXVlc3QoSlNPTi5zdHJpbmdpZnkobmV3UmVxdWVzdCkpOyAKIGxvZyhKU09OLnN0cmluZ2lmeShyZXNwb25zZSkpCiAgCiAgdmFyIHJlc3BvbnNlT2JqZWN0ID0geyAKICAgIEJvZHk6ICJUSElTIElTIEEgIFZJUlRVQUwgUkVTUE9OU0UiLCAKICAgIENvZGU6IDIwMCAKICB9CiAgcmV0dXJuIFR5a0pzUmVzcG9uc2UocmVzcG9uc2VPYmplY3QsIHNlc3Npb24ubWV0YV9kYXRhKQp9", | |
"path": "success", | |
"method": "POST", | |
"use_session": false, | |
"proxy_on_error": false | |
} | |
] | |
} | |
} | |
} | |
}, | |
"jwt_scope_claim_name": "", | |
"use_standard_auth": false, | |
"session_lifetime": 0, | |
"hmac_allowed_algorithms": [], | |
"disable_rate_limit": false, | |
"definition": { | |
"location": "header", | |
"key": "x-api-version", | |
"strip_path": false | |
}, | |
"use_oauth2": false, | |
"jwt_source": "", | |
"jwt_signing_method": "", | |
"jwt_not_before_validation_skew": 0, | |
"use_go_plugin_auth": false, | |
"jwt_identity_base_field": "", | |
"allowed_ips": [], | |
"request_signing": { | |
"is_enabled": false, | |
"secret": "", | |
"key_id": "", | |
"algorithm": "", | |
"header_list": [], | |
"certificate_id": "", | |
"signature_header": "" | |
}, | |
"org_id": "5eb06f441fe4c4000147476e", | |
"enable_ip_whitelisting": false, | |
"global_rate_limit": { | |
"rate": 0, | |
"per": 0 | |
}, | |
"protocol": "", | |
"enable_context_vars": false, | |
"tags": [], | |
"basic_auth": { | |
"disable_caching": false, | |
"cache_ttl": 0, | |
"extract_from_body": false, | |
"body_user_regexp": "", | |
"body_password_regexp": "" | |
}, | |
"listen_port": 0, | |
"session_provider": { | |
"name": "", | |
"storage_engine": "", | |
"meta": {} | |
}, | |
"auth_configs": { | |
"authToken": { | |
"use_param": false, | |
"param_name": "", | |
"use_cookie": false, | |
"cookie_name": "", | |
"auth_header_name": "Authorization", | |
"use_certificate": false, | |
"validate_signature": false, | |
"signature": { | |
"algorithm": "", | |
"header": "", | |
"secret": "", | |
"allowed_clock_skew": 0, | |
"error_code": 0, | |
"error_message": "" | |
} | |
}, | |
"basic": { | |
"use_param": false, | |
"param_name": "", | |
"use_cookie": false, | |
"cookie_name": "", | |
"auth_header_name": "Authorization", | |
"use_certificate": false, | |
"validate_signature": false, | |
"signature": { | |
"algorithm": "", | |
"header": "", | |
"secret": "", | |
"allowed_clock_skew": 0, | |
"error_code": 0, | |
"error_message": "" | |
} | |
}, | |
"coprocess": { | |
"use_param": false, | |
"param_name": "", | |
"use_cookie": false, | |
"cookie_name": "", | |
"auth_header_name": "Authorization", | |
"use_certificate": false, | |
"validate_signature": false, | |
"signature": { | |
"algorithm": "", | |
"header": "", | |
"secret": "", | |
"allowed_clock_skew": 0, | |
"error_code": 0, | |
"error_message": "" | |
} | |
}, | |
"hmac": { | |
"use_param": false, | |
"param_name": "", | |
"use_cookie": false, | |
"cookie_name": "", | |
"auth_header_name": "Authorization", | |
"use_certificate": false, | |
"validate_signature": false, | |
"signature": { | |
"algorithm": "", | |
"header": "", | |
"secret": "", | |
"allowed_clock_skew": 0, | |
"error_code": 0, | |
"error_message": "" | |
} | |
}, | |
"jwt": { | |
"use_param": false, | |
"param_name": "", | |
"use_cookie": false, | |
"cookie_name": "", | |
"auth_header_name": "Authorization", | |
"use_certificate": false, | |
"validate_signature": false, | |
"signature": { | |
"algorithm": "", | |
"header": "", | |
"secret": "", | |
"allowed_clock_skew": 0, | |
"error_code": 0, | |
"error_message": "" | |
} | |
}, | |
"oauth": { | |
"use_param": false, | |
"param_name": "", | |
"use_cookie": false, | |
"cookie_name": "", | |
"auth_header_name": "Authorization", | |
"use_certificate": false, | |
"validate_signature": false, | |
"signature": { | |
"algorithm": "", | |
"header": "", | |
"secret": "", | |
"allowed_clock_skew": 0, | |
"error_code": 0, | |
"error_message": "" | |
} | |
}, | |
"oidc": { | |
"use_param": false, | |
"param_name": "", | |
"use_cookie": false, | |
"cookie_name": "", | |
"auth_header_name": "Authorization", | |
"use_certificate": false, | |
"validate_signature": false, | |
"signature": { | |
"algorithm": "", | |
"header": "", | |
"secret": "", | |
"allowed_clock_skew": 0, | |
"error_code": 0, | |
"error_message": "" | |
} | |
} | |
}, | |
"strip_auth_data": false, | |
"id": "5eb9be1500e56700018f213d", | |
"certificates": [], | |
"enable_signature_checking": false, | |
"use_openid": false, | |
"internal": false, | |
"jwt_skip_kid": false, | |
"enable_batch_request_support": false, | |
"enable_detailed_recording": false, | |
"response_processors": [], | |
"use_mutual_tls_auth": false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment