-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #240 from Crowdtilt/user_per_payment
create CT API user per payment
- Loading branch information
Showing
8 changed files
with
47 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,18 +79,31 @@ Crowdhoster.campaigns = | |
|
||
errors = crowdtilt.card.validate(cardData) | ||
if !$.isEmptyObject(errors) | ||
$('#refresh-msg').hide() | ||
$.each errors, (index, value) -> | ||
$('#errors').append('<p>' + value + '</p>') | ||
$('#errors').show() | ||
$('.loader').hide() | ||
$button = $('button[type="submit"]') | ||
$button.attr('disabled', false).html('Confirm payment of $' + $button.attr('data-total')) | ||
$('#card_number').attr('name', 'card_number') | ||
$('#security_code').attr('name', 'security_code') | ||
Crowdhoster.campaigns.resetPaymentForm() | ||
else | ||
user_id = $form.find('#ct_user_id').val() | ||
crowdtilt.card.create(user_id, cardData, this.cardResponseHandler) | ||
$.post($form.attr('data-user-create-action'), { email: $(document.getElementById('email')).val() }) | ||
.done((user_id) -> | ||
$('#ct_user_id').val(user_id) | ||
crowdtilt.card.create(user_id, cardData, Crowdhoster.campaigns.cardResponseHandler) | ||
) | ||
.fail((jqXHR, textStatus) -> | ||
Crowdhoster.campaigns.resetPaymentForm() | ||
if jqXHR.status == 400 | ||
$('#errors').append('<p>Sorry, we weren\'t able to process your contribution. Please try again.</p><br><p>If you continue to experience issues, please <a href="mailto:[email protected]?subject=Support request for creating user payment">click here</a> to email support.</p>') | ||
else | ||
$('#errors').append('<p>Sorry, we weren\'t able to process your contribution. Please try again.</p><br><p>If you continue to experience issues, please <a href="mailto:[email protected]?subject=Unable to create user payment">click here</a> to email support.</p>') | ||
) | ||
|
||
resetPaymentForm: (with_errors = true) -> | ||
$('#refresh-msg').hide() | ||
$('#errors').show() if with_errors | ||
$('.loader').hide() | ||
$button = $('button[type="submit"]') | ||
$button.attr('disabled', false).html('Confirm payment of $' + $button.attr('data-total')) | ||
$('#card_number').attr('name', 'card_number') | ||
$('#security_code').attr('name', 'security_code') | ||
|
||
timeCheck: (element) -> | ||
expiration = $(element).attr("date-element") | ||
|
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
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddCtUserIdToPayments < ActiveRecord::Migration | ||
def change | ||
add_column :payments, :ct_user_id, :string | ||
end | ||
end |
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