This repository has been archived by the owner on Mar 15, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create in-app payment keys (bug 834486)
- Loading branch information
Showing
8 changed files
with
238 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
CREATE TABLE `user_inapp_keys` ( | ||
`id` int(11) unsigned AUTO_INCREMENT NOT NULL PRIMARY KEY, | ||
`solitude_seller_id` int(11) unsigned NOT NULL, | ||
`seller_product_pk` int(11) unsigned NOT NULL UNIQUE, | ||
`created` datetime NOT NULL, | ||
`modified` datetime NOT NULL | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
ALTER TABLE `user_inapp_keys` ADD CONSTRAINT `solitude_seller_id_refs_id_cd630821` | ||
FOREIGN KEY (`solitude_seller_id`) REFERENCES `payments_seller` (`id`); | ||
CREATE INDEX `user_inapp_keys_613b0f94` ON `user_inapp_keys` (`solitude_seller_id`); | ||
|
||
INSERT INTO waffle_switch_mkt (name, active, created, modified, note) | ||
VALUES ('in-app-sandbox', 0, NOW(), NOW(), | ||
'Enable the in-app payment sandbox'); |
This file contains 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
This file contains 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
57 changes: 57 additions & 0 deletions
57
mkt/developers/templates/developers/payments/in-app-keys.html
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{% extends 'developers/base_impala.html' %} | ||
{% from 'developers/includes/macros.html' import required %} | ||
|
||
{% set title = _('In-App Payment Keys') %} | ||
{% block title %}{{ hub_page_title(title, addon) }}{% endblock %} | ||
|
||
{% block content %} | ||
<header> | ||
{{ hub_breadcrumbs(addon, items=[(None, title)]) }} | ||
<h1>{{ title }}</h1> | ||
</header> | ||
{{ disabled_payments_notice() }} | ||
<section class="island" role="main"> | ||
<div id="in-app-config" class="devhub-form"> | ||
<form class="item in-app-config" method="post" action="{{ request.path }}"> | ||
{{ csrf() }} | ||
<p class="learn-mdn active"><a href="https://developer.mozilla.org/en-US/docs/Apps/In-app_payments" target="_blank"> | ||
{% trans %}Learn more about <b>in-app payments</b> on MDN.{% endtrans -%} | ||
</a></p> | ||
<p class="preamble"> | ||
{% trans submit=url('submit.app') %} | ||
The following key/secret will only allow you to simulate in-app payments | ||
while you develop your app. To generate a key for real in-app payments | ||
you must <a href="{{ submit }}">submit</a> your app, set up your payment | ||
credentials, and generate a new key specifically for that app. | ||
{% endtrans %} | ||
</p> | ||
<table> | ||
<tr id="in-app-public-key"> | ||
<th class="label">{{ _('Application Key') }}</th> | ||
{% if key %} | ||
<td><input type="text" value="{{ key.public_id() }}" readonly></td> | ||
{% else %} | ||
<td class="not-generated">({{ _('Not yet generated.') }})</td> | ||
{% endif %} | ||
</tr> | ||
<tr id="in-app-private-key"> | ||
<th class="label">{{ _('Application Secret') }}</th> | ||
{% if key %} | ||
<td> | ||
<button data-url="{{ url('mkt.developers.apps.in_app_key_secret', | ||
key.pk) }}" | ||
class="generator">{{ _('Show secret') }}</button> | ||
<input type="text" class="secret" type="text" value="" readonly> | ||
</td> | ||
{% else %} | ||
<td class="not-generated">({{ _('Not yet generated.') }})</td> | ||
{% endif %} | ||
</tr> | ||
</table> | ||
<div class="listing-footer"> | ||
<button type="submit">{{ _('Reset secret') if key else _('Generate Keys') }}</button> | ||
</div> | ||
</form> | ||
</div> | ||
</section> | ||
{% endblock %} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -216,6 +216,42 @@ def payments_accounts_delete(request, id): | |
return http.HttpResponse('success') | ||
|
||
|
||
@login_required | ||
@waffle_switch('in-app-sandbox') | ||
def in_app_keys(request): | ||
keys = (models.UserInappKey.uncached | ||
.filter(solitude_seller__user=request.amo_user)) | ||
# TODO(Kumar) support multiple test keys. For now there's only one. | ||
if keys.count(): | ||
key = keys.get() | ||
else: | ||
key = None | ||
if request.method == 'POST': | ||
if key: | ||
key.reset() | ||
messages.success(request, _('Secret was reset successfully.')) | ||
else: | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
kumar303
Author
Contributor
|
||
key = models.UserInappKey.create(request.amo_user) | ||
messages.success(request, | ||
_('Key and secret were created successfully.')) | ||
return redirect(reverse('mkt.developers.apps.in_app_keys')) | ||
|
||
return jingo.render(request, 'developers/payments/in-app-keys.html', | ||
{'key': key}) | ||
|
||
|
||
@login_required | ||
@waffle_switch('in-app-sandbox') | ||
def in_app_key_secret(request, pk): | ||
key = (models.UserInappKey.uncached | ||
.filter(solitude_seller__user=request.amo_user, pk=pk)) | ||
if not key.count(): | ||
# Either the record does not exist or it's not owned by the | ||
# logged in user. | ||
return http.HttpResponseForbidden() | ||
return http.HttpResponse(key.get().secret()) | ||
|
||
|
||
@login_required | ||
@waffle_switch('in-app-payments') | ||
@dev_required(owner_for_post=True, webapp=True) | ||
|
key is unused