Version Description
Download this release
Release Info
Developer | cklosows |
Plugin | Easy Digital Downloads |
Version | 2.4.2 |
Comparing to | |
See all releases |
Code changes from version 2.4.1 to 2.4.2
- assets/js/admin-scripts.js +11 -1
- assets/js/admin-scripts.min.js +1 -1
- easy-digital-downloads.php +3 -3
- includes/admin/admin-actions.php +1 -1
- includes/admin/reporting/export/class-batch-export-customers.php +16 -3
- includes/admin/reporting/export/class-batch-export-file-downloads.php +7 -2
- includes/admin/reporting/export/class-batch-export-payments.php +14 -2
- includes/admin/reporting/export/class-batch-export.php +7 -6
- includes/admin/reporting/export/export-actions.php +169 -0
- includes/admin/reporting/export/export-functions.php +7 -83
- includes/admin/settings/register-settings.php +10 -6
- includes/admin/tracking.php +10 -4
- includes/admin/upgrades/upgrade-functions.php +0 -37
- includes/ajax-functions.php +1 -1
- includes/api/class-edd-api.php +1 -0
- includes/cart/actions.php +2 -2
- includes/cart/functions.php +6 -12
- includes/checkout/functions.php +2 -1
- includes/checkout/template.php +1 -1
- includes/class-edd-db-customers.php +8 -6
- includes/gateways/libs/amazon/Client.php +1395 -1392
- includes/gateways/libs/amazon/HttpCurl.php +25 -22
- includes/gateways/libs/amazon/Interface.php +93 -90
- includes/gateways/libs/amazon/IpnHandler.php +16 -13
- includes/gateways/libs/amazon/ResponseParser.php +21 -18
- includes/gateways/paypal-standard.php +2 -0
- includes/misc-functions.php +39 -2
- includes/template-functions.php +6 -6
- languages/edd.pot +54 -54
- readme.txt +20 -1
- templates/shortcode-login.php +1 -1
- templates/shortcode-profile-editor.php +1 -1
assets/js/admin-scripts.js
CHANGED
@@ -961,7 +961,8 @@ jQuery(document).ready(function ($) {
|
|
961 |
// Remove tax row
|
962 |
$('body').on('click', '#edd_tax_rates .edd_remove_tax_rate', function() {
|
963 |
if( confirm( edd_vars.delete_tax_rate ) ) {
|
964 |
-
var
|
|
|
965 |
|
966 |
if( count === 2 ) {
|
967 |
$('#edd_tax_rates select').val('');
|
@@ -971,6 +972,15 @@ jQuery(document).ready(function ($) {
|
|
971 |
} else {
|
972 |
$(this).closest('tr').remove();
|
973 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
974 |
}
|
975 |
return false;
|
976 |
});
|
961 |
// Remove tax row
|
962 |
$('body').on('click', '#edd_tax_rates .edd_remove_tax_rate', function() {
|
963 |
if( confirm( edd_vars.delete_tax_rate ) ) {
|
964 |
+
var tax_rates = $('#edd_tax_rates tr:visible');
|
965 |
+
var count = tax_rates.length;
|
966 |
|
967 |
if( count === 2 ) {
|
968 |
$('#edd_tax_rates select').val('');
|
972 |
} else {
|
973 |
$(this).closest('tr').remove();
|
974 |
}
|
975 |
+
|
976 |
+
/* re-index after deleting */
|
977 |
+
$('#edd_tax_rates tr').each( function( rowIndex ) {
|
978 |
+
$(this).children().find( 'input, select' ).each(function() {
|
979 |
+
var name = $( this ).attr( 'name' );
|
980 |
+
name = name.replace( /\[(\d+)\]/, '[' + ( rowIndex - 1 ) + ']');
|
981 |
+
$( this ).attr( 'name', name ).attr( 'id', name );
|
982 |
+
});
|
983 |
+
});
|
984 |
}
|
985 |
return false;
|
986 |
});
|
assets/js/admin-scripts.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
jQuery(document).ready(function(a){var b={init:function(){this.add(),this.move(),this.remove(),this.type(),this.prices(),this.files(),this.updatePrices()},clone_repeatable:function(b){var c=highest=1;return b.parent().find("tr.edd_repeatable_row").each(function(){var b=a(this).data("key");parseInt(b)>highest&&(highest=b)}),c=highest+=1,clone=b.clone(),clone.find("select").each(function(){a(this).val(b.find('select[name="'+a(this).attr("name")+'"]').val())}),clone.removeClass("edd_add_blank"),clone.attr("data-key",c),clone.find("td input, td select, textarea").val(""),clone.find("input, select, textarea").each(function(){var b=a(this).attr("name");b=b.replace(/\[(\d+)\]/,"["+parseInt(c)+"]"),a(this).attr("name",b).attr("id",b)}),clone.find("span.edd_price_id").each(function(){a(this).text(parseInt(c))}),clone.find(".edd_repeatable_default_input").each(function(){a(this).val(parseInt(c)).removeAttr("checked")}),clone},add:function(){a("body").on("click",".submit .edd_add_repeatable",function(c){c.preventDefault();var d=a(this),e=d.parent().parent().prev("tr"),f=b.clone_repeatable(e);f.insertAfter(e).find("input, textarea, select").filter(":visible").eq(0).focus()})},move:function(){a(".edd_repeatable_table tbody").sortable({handle:".edd_draghandle",items:".edd_repeatable_row",opacity:.6,cursor:"move",axis:"y",update:function(){var b=0;a(this).find("tr").each(function(){a(this).find("input.edd_repeatable_index").each(function(){a(this).val(b)}),b++})}})},remove:function(){a("body").on("click",".edd_remove_repeatable",function(b){b.preventDefault();var c=a(this).parent().parent("tr"),d=c.parent().find("tr").length-1,e=a(this).data("type"),f="tr.edd_repeatable_"+e+"s";if("price"===e){var g=c.data("key");a('.edd_repeatable_condition_field option[value="'+g+'"]').remove()}if(d>1)a("input, select",c).val(""),c.fadeOut("fast").remove();else switch(e){case"price":alert(edd_vars.one_price_min);break;case"file":a("input, select",c).val("");break;default:alert(edd_vars.one_field_min)}a(f).each(function(b){a(this).find("input, select").each(function(){var c=a(this).attr("name");c=c.replace(/\[(\d+)\]/,"["+b+"]"),a(this).attr("name",c).attr("id",c)})})})},type:function(){a("body").on("change","#_edd_product_type",function(){var c=a("#edd_products"),d=a("#edd_download_files"),e=a("#edd_download_limit_wrap");"bundle"===a(this).val()?(c.show(),d.hide(),e.hide()):(c.hide(),d.show(),e.show())})},prices:function(){a("body").on("change","#edd_variable_pricing",function(){a(".edd_pricing_fields,.edd_repeatable_table .pricing").toggle()})},files:function(){if("undefined"==typeof wp||"1"!==edd_vars.new_media_ui)a(".edd_upload_file_button").length>0&&(window.formfield="",a("body").on("click",".edd_upload_file_button",function(b){if(b.preventDefault(),window.formfield=a(this).parent().prev(),window.tbframe_interval=setInterval(function(){jQuery("#TB_iframeContent").contents().find(".savesend .button").val(edd_vars.use_this_file).end().find("#insert-gallery, .wp-post-thumbnail").hide()},2e3),null!=edd_vars.post_id)var c="post_id="+edd_vars.post_id+"&";tb_show(edd_vars.add_new_download,"media-upload.php?"+c+"TB_iframe=true")}),window.edd_send_to_editor=window.send_to_editor,window.send_to_editor=function(b){window.formfield?(imgurl=a("a","<div>"+b+"</div>").attr("href"),window.formfield.val(imgurl),window.clearInterval(window.tbframe_interval),tb_remove()):window.edd_send_to_editor(b),window.send_to_editor=window.edd_send_to_editor,window.formfield="",window.imagefield=!1});else{var c;window.formfield="",a("body").on("click",".edd_upload_file_button",function(d){d.preventDefault();var e=a(this);return window.formfield=a(this).closest(".edd_repeatable_upload_wrapper"),c?(c.open(),void 0):(c=wp.media.frames.file_frame=wp.media({frame:"post",state:"insert",title:e.data("uploader-title"),button:{text:e.data("uploader-button-text")},multiple:"0"==a(this).data("multiple")?!1:!0}),c.on("menu:render:default",function(a){var b={};a.unset("library-separator"),a.unset("gallery"),a.unset("featured-image"),a.unset("embed"),a.set(b)}),c.on("insert",function(){var a=c.state().get("selection");a.each(function(a,c){if(a=a.toJSON(),0===c)window.formfield.find(".edd_repeatable_attachment_id_field").val(a.id),window.formfield.find(".edd_repeatable_upload_field").val(a.url),window.formfield.find(".edd_repeatable_name_field").val(a.title);else{var d=window.formfield,e=b.clone_repeatable(d);e.find(".edd_repeatable_attachment_id_field").val(a.id),e.find(".edd_repeatable_upload_field").val(a.url),a.title.length>0?e.find(".edd_repeatable_name_field").val(a.title):e.find(".edd_repeatable_name_field").val(a.filename),e.insertAfter(d)}})}),c.open(),void 0)});var c;window.formfield=""}},updatePrices:function(){a("#edd_price_fields").on("keyup",".edd_variable_prices_name",function(){var b=a(this).parents("tr").data("key"),c=a(this).val(),d=a(".edd_repeatable_condition_field option[value="+b+"]");d.length>0?d.text(c):a(".edd_repeatable_condition_field").append(a("<option></option>").attr("value",b).text(c))})}};b.init();var c=a(".edd_datepicker");if(c.length>0){var d="mm/dd/yy";c.datepicker({dateFormat:d})}var e={init:function(){this.edit_address(),this.remove_download(),this.add_download(),this.new_customer(),this.recalculate_total(),this.variable_prices_check(),this.add_note(),this.remove_note(),this.resend_receipt(),this.copy_download_link()},edit_address:function(){a('select[name="edd-payment-address[0][country]"]').change(function(){var b=a(this);return data={action:"edd_get_shop_states",country:b.val(),field_name:"edd-payment-address[0][state]"},a.post(ajaxurl,data,function(b){var c=a("#edd-order-address-state-wrap select, #edd-order-address-state-wrap input");"nostates"==b?c.replaceWith('<input type="text" name="edd-payment-address[0][state]" value="" class="edd-edit-toggles medium-text"/>'):c.replaceWith(b)}),!1})},remove_download:function(){a("#edd-purchased-files").on("click",".edd-order-remove-download",function(){var b=a("body").find("#edd-purchased-files > .row").length;if(1===b)return alert(edd_vars.one_download_min),!1;if(confirm(edd_vars.delete_payment_download)){var c=a(this).data("key");a(".edd-payment-id").val();var e=a('input[name="edd-payment-details-downloads['+c+'][id]"]').val(),f=a('input[name="edd-payment-details-downloads['+c+'][price_id]"]').val(),g=a('input[name="edd-payment-details-downloads['+c+'][quantity]"]').val(),h=a('input[name="edd-payment-details-downloads['+c+'][amount]"]').val(),i=a('input[name="edd-payment-removed"]').val();i=a.parseJSON(i),i.length<1&&(i={});var j=[{id:e,price_id:f,quantity:g,amount:h}];i[c]=j,a('input[name="edd-payment-removed"]').val(JSON.stringify(i)),a(this).parent().parent().parent().remove(),a("#edd-payment-downloads-changed").val(1),a(".edd-order-payment-recalc-totals").show()}return!1})},new_customer:function(){a("#edd-customer-details").on("click",".edd-payment-new-customer, .edd-payment-new-customer-cancel",function(b){b.preventDefault(),a(".customer-info").toggle(),a(".new-customer").toggle();var c=a("#edd-new-customer");a(".new-customer").is(":visible")?c.val(1):c.val(0)})},add_download:function(){a("#edd-purchased-files").on("click","#edd-order-add-download",function(b){b.preventDefault();var c=a("#edd_order_download_select"),d=a("#edd-order-download-quantity"),e=a("#edd-order-download-amount"),f=a(".edd_price_options_select option:selected"),g=c.val(),h=c.find(":selected").text(),i=d.val(),j=e.val(),k=f.val(),l=f.text();if(1>g)return!1;if(j||(j=0),j=parseFloat(j),isNaN(j))return alert(edd_vars.numeric_item_price),!1;if("1"===edd_vars.quantities_enabled){if(isNaN(parseInt(i)))return alert(edd_vars.numeric_quantity),!1;j*=i}j=j.toFixed(edd_vars.currency_decimals);var m=j+edd_vars.currency_sign;"before"===edd_vars.currency_pos&&(m=edd_vars.currency_sign+j),l&&(h=h+" - "+l);var n=a("#edd-purchased-files div.row").length,o=a("#edd-purchased-files div.row:last").clone();o.find(".download span").html('<a href="post.php?post='+g+'&action=edit"></a>'),o.find(".download span a").text(h),o.find(".price-text").text(m),o.find(".item-quantity").text(i),o.find(".item-price").text(edd_vars.currency_sign+(j/i).toFixed(edd_vars.currency_decimals)),o.find("input.edd-payment-details-download-id").val(g),o.find("input.edd-payment-details-download-price-id").val(k),o.find("input.edd-payment-details-download-amount").val(j),o.find("input.edd-payment-details-download-quantity").val(i),o.find("input.edd-payment-details-download-has-log").val(0),o.find("input").each(function(){var b=a(this).attr("name");b=b.replace(/\[(\d+)\]/,"["+parseInt(n)+"]"),a(this).attr("name",b).attr("id",b)}),a("#edd-payment-downloads-changed").val(1),a(o).insertAfter("#edd-purchased-files div.row:last"),a(".edd-order-payment-recalc-totals").show()})},recalculate_total:function(){a("#edd-order-recalc-total").on("click",function(b){b.preventDefault();var c=0,d=a("#edd-purchased-files .row .edd-payment-details-download-amount");d.length&&d.each(function(){c+=parseFloat(a(this).val())}),a(".edd-payment-fees").length&&a(".edd-payment-fees span.fee-amount").each(function(){c+=parseFloat(a(this).data("fee"))}),a("input[name=edd-payment-total]").val(c)})},variable_prices_check:function(){a("#edd-purchased-files").on("change","select#edd_order_download_select",function(){var b=a(this),c=b.val();if(parseInt(c)>0){var d={action:"edd_check_for_download_price_variations",download_id:c};a.ajax({type:"POST",data:d,url:ajaxurl,success:function(c){a(".edd_price_options_select").remove(),a(c).insertAfter(b.next())}}).fail(function(a){window.console&&window.console.log&&console.log(a)})}})},add_note:function(){a("#edd-add-payment-note").on("click",function(b){b.preventDefault();var c={action:"edd_insert_payment_note",payment_id:a(this).data("payment-id"),note:a("#edd-payment-note").val()};if(c.note)a.ajax({type:"POST",data:c,url:ajaxurl,success:function(b){a("#edd-payment-notes-inner").append(b),a(".edd-no-payment-notes").hide(),a("#edd-payment-note").val("")}}).fail(function(a){window.console&&window.console.log&&console.log(a)});else{var d=a("#edd-payment-note").css("border-color");a("#edd-payment-note").css("border-color","red"),setTimeout(function(){a("#edd-payment-note").css("border-color",d)},500)}})},remove_note:function(){a("body").on("click",".edd-delete-payment-note",function(b){if(b.preventDefault(),confirm(edd_vars.delete_payment_note)){var c={action:"edd_delete_payment_note",payment_id:a(this).data("payment-id"),note_id:a(this).data("note-id")};return a.ajax({type:"POST",data:c,url:ajaxurl,success:function(){return a("#edd-payment-note-"+c.note_id).remove(),a(".edd-payment-note").length||a(".edd-no-payment-notes").show(),!1}}).fail(function(a){window.console&&window.console.log&&console.log(a)}),!0}})},resend_receipt:function(){a("body").on("click","#edd-resend-receipt",function(){return confirm(edd_vars.resend_receipt)})},copy_download_link:function(){a("body").on("click",".edd-copy-download-link",function(b){b.preventDefault();var c=a(this),d={action:"edd_get_file_download_link",payment_id:a('input[name="edd_payment_id"]').val(),download_id:c.data("download-id"),price_id:c.data("price-id")};a.ajax({type:"POST",data:d,url:ajaxurl,success:function(b){return a("#edd-download-link").dialog({width:400}).html('<textarea rows="10" cols="40" id="edd-download-link-textarea">'+b+"</textarea>"),a("#edd-download-link-textarea").focus().select(),!1}}).fail(function(a){window.console&&window.console.log&&console.log(a)})})}};e.init();var f={init:function(){this.type_select(),this.product_requirements()},type_select:function(){a("#edd-edit-discount #edd-type, #edd-add-discount #edd-type").change(function(){a(".edd-amount-description").toggle()})},product_requirements:function(){a("#products").change(function(){var b=a("#edd-discount-product-conditions");a(this).val()?b.show():b.hide()})}};f.init();var g={init:function(){this.date_options(),this.customers_export()},date_options:function(){a("#edd-graphs-date-options").change(function(){var b=a(this),c=a("#edd-date-range-options");"other"===b.val()?c.show():c.hide()})},customers_export:function(){a("#edd_customer_export_download").change(function(){var b=a(this),c=a("option:selected",b).val(),d=a("#edd_customer_export_option");if("0"===b.val()?d.show():d.hide(),0!=parseInt(c)){var e={action:"edd_check_for_download_price_variations",download_id:c},f=a(".edd_price_options_select");a.post(ajaxurl,e,function(a){f.remove(),b.after(a)})}else f.remove()})}};g.init();var h={init:function(){this.general(),this.taxes(),this.emails(),this.misc()},general:function(){var b=a(".edd-color-picker");if(b.length&&b.wpColorPicker(),"undefined"==typeof wp||"1"!==edd_vars.new_media_ui){var c=a(".edd_settings_upload_button");c.length>0&&(window.formfield="",a("body").on("click",c,function(b){b.preventDefault(),window.formfield=a(this).parent().prev(),window.tbframe_interval=setInterval(function(){jQuery("#TB_iframeContent").contents().find(".savesend .button").val(edd_vars.use_this_file).end().find("#insert-gallery, .wp-post-thumbnail").hide()},2e3),tb_show(edd_vars.add_new_download,"media-upload.php?TB_iframe=true")}),window.edd_send_to_editor=window.send_to_editor,window.send_to_editor=function(b){window.formfield?(imgurl=a("a","<div>"+b+"</div>").attr("href"),window.formfield.val(imgurl),window.clearInterval(window.tbframe_interval),tb_remove()):window.edd_send_to_editor(b),window.send_to_editor=window.edd_send_to_editor,window.formfield="",window.imagefield=!1})}else{var d;window.formfield="",a("body").on("click",".edd_settings_upload_button",function(b){b.preventDefault();var c=a(this);return window.formfield=a(this).parent().prev(),d?(d.open(),void 0):(d=wp.media.frames.file_frame=wp.media({frame:"post",state:"insert",title:c.data("uploader_title"),button:{text:c.data("uploader_button_text")},multiple:!1}),d.on("menu:render:default",function(a){var b={};a.unset("library-separator"),a.unset("gallery"),a.unset("featured-image"),a.unset("embed"),a.set(b)}),d.on("insert",function(){var a=d.state().get("selection");a.each(function(a){a=a.toJSON(),window.formfield.val(a.url)})}),d.open(),void 0)});var d;window.formfield=""}},taxes:function(){var b=a("select.edd-no-states");b.length&&b.closest("tr").hide(),a('select[name="edd_settings[base_country]"]').change(function(){var b=a(this),c=b.closest("tr");return data={action:"edd_get_shop_states",country:a(this).val(),field_name:"edd_settings[base_state]"},a.post(ajaxurl,data,function(a){"nostates"==a?c.next().hide():(c.next().show(),c.next().find("select").replaceWith(a))}),!1}),a("body").on("change","#edd_tax_rates select.edd-tax-country",function(){var b=a(this);return data={action:"edd_get_shop_states",country:a(this).val(),field_name:b.attr("name").replace("country","state")},a.post(ajaxurl,data,function(a){if("nostates"==a){var c='<input type="text" name="'+data.field_name+'" value=""/>';b.parent().next().find("select").replaceWith(c)}else b.parent().next().find("input,select").show(),b.parent().next().find("input,select").replaceWith(a)}),!1}),a("#edd_add_tax_rate").on("click",function(){var b=a("#edd_tax_rates tr:last"),c=b.clone(),d=b.parent().find("tr").length;return c.find("td input").not(":input[type=checkbox]").val(""),c.find('td [type="checkbox"]').attr("checked",!1),c.find("input, select").each(function(){var b=a(this).attr("name");b=b.replace(/\[(\d+)\]/,"["+parseInt(d)+"]"),a(this).attr("name",b).attr("id",b)}),c.find("label").each(function(){var b=a(this).attr("for");b=b.replace(/\[(\d+)\]/,"["+parseInt(d)+"]"),a(this).attr("for",b)}),c.insertAfter(b),!1}),a("body").on("click","#edd_tax_rates .edd_remove_tax_rate",function(){if(confirm(edd_vars.delete_tax_rate)){var b=a("#edd_tax_rates tr:visible").length;2===b?(a("#edd_tax_rates select").val(""),a('#edd_tax_rates input[type="text"]').val(""),a('#edd_tax_rates input[type="number"]').val(""),a('#edd_tax_rates input[type="checkbox"]').attr("checked",!1)):a(this).closest("tr").remove()}return!1})},emails:function(){var b=a("#email-preview-wrap");if(b.length){var c=a("#email-preview");b.colorbox({inline:!0,href:c,width:"80%",height:"auto"})}},misc:function(){var b=a('select[name="edd_settings[download_method]"]'),c=b.parent().parent().next();"direct"==b.val()&&(c.hide(),c.find("input").prop("checked",!1)),b.on("change",function(){"direct"==a(this).val()?(c.hide(),c.find("input").prop("checked",!1)):c.show()})}};h.init(),a(".download_page_edd-payment-history .row-actions .delete a").on("click",function(){return confirm(edd_vars.delete_payment)?!0:!1}),a("#the-list").on("click",".editinline",function(){inlineEditPost.revert();var b=a(this).closest("tr").attr("id");b=b.replace("post-","");var c=a("#post-"+b),d=c.find(".column-price .downloadprice-"+b).val();d!=a("#post-"+b+".column-price .downloadprice-"+b).val()?a(".regprice","#edd-download-data").val(d).attr("disabled",!1):a(".regprice","#edd-download-data").val(edd_vars.quick_edit_warning).attr("disabled","disabled")}),a("body").on("click","#bulk_edit",function(){var b=a("#bulk-edit"),c=new Array;b.find("#bulk-titles").children().each(function(){c.push(a(this).attr("id").replace(/^(ttle)/i,""))});var d=a('#edd-download-data input[name="_edd_regprice"]').val(),e={action:"edd_save_bulk_edit",edd_bulk_nonce:c,post_ids:c,price:d};a.post(ajaxurl,e)}),a(".edd-select-chosen").chosen({inherit_select_classes:!0,placeholder_text_single:edd_vars.one_option,placeholder_text_multiple:edd_vars.one_or_more_option}),a(".chosen-choices").on("click",function(){a(this).children("li").children("input").attr("placeholder",edd_vars.type_to_search)});var i,j=342;a(".edd-select.chosen-container .chosen-search input, .edd-select.chosen-container .search-field input").keyup(function(b){var c=a(this).val(),d=a(this).closest(".edd-select-chosen"),e=d.attr("id").replace("_chosen","");b.which;var g="edd_download_search";d.attr("id").indexOf("customer")>=0&&(g="edd_customer_search"),c.length<=3&&"edd_download_search"==g||16==b.which||13==b.which||91==b.which||17==b.which||37==b.which||38==b.which||39==b.which||40==b.which||(clearTimeout(i),i=setTimeout(function(){a.ajax({type:"GET",url:ajaxurl,data:{action:g,s:c,current_id:edd_vars.post_id},dataType:"json",beforeSend:function(){a("ul.chosen-results").empty()},success:function(b){a("#"+e+" option:not(:selected)").remove(),a.each(b,function(b,c){a("#"+e+' option[value="'+c.id+'"]').length||a("#"+e).prepend('<option value="'+c.id+'">'+c.name+"</option>")}),a(".edd-select-chosen").trigger("chosen:updated"),a("#"+e).next().find("input").val(c)}}).fail(function(a){window.console&&window.console.log&&console.log(a)}).done(function(){})},j))}),a("#post").on("click",".edd-thickbox",function(){a(".edd-select-chosen","#choose-download").css("width","100%")});var k={init:function(){this.revoke_api_key(),this.regenerate_api_key()},revoke_api_key:function(){a("body").on("click",".edd-revoke-api-key",function(){return confirm(edd_vars.revoke_api_key)})},regenerate_api_key:function(){a("body").on("click",".edd-regenerate-api-key",function(){return confirm(edd_vars.regenerate_api_key)})}};k.init();var l={init:function(){this.submit()},submit:function(){var b=this;a("body").on("submit",".edd-export-form",function(c){c.preventDefault();var d=a(this).serialize();a(this).append('<span class="spinner is-active"></span><div class="edd-progress"><div></div></div>'),b.process_step(1,d,b)})},process_step:function(b,c,d){a.ajax({type:"POST",url:ajaxurl,data:{form:c,action:"edd_do_ajax_export",step:b},dataType:"json",success:function(b){if("done"==b.step){var e=a(".edd-export-form");e.find(".spinner").remove(),e.find(".edd-progress").remove(),window.location=b.url}else a(".edd-progress div").animate({width:b.percentage+"%"},50,function(){}),d.process_step(parseInt(b.step),c,d)}}).fail(function(a){window.console&&window.console.log&&console.log(a)})}};l.init();var m={vars:{customer_card_wrap_editable:a("#edd-customer-card-wrapper .editable"),customer_card_wrap_edit_item:a("#edd-customer-card-wrapper .edit-item"),user_id:a('input[name="customerinfo[user_id]"]'),state_input:a(':input[name="customerinfo[state]"]'),note:a("#customer-note")},init:function(){this.edit_customer(),this.user_search(),this.remove_user(),this.cancel_edit(),this.change_country(),this.add_note(),this.delete_checked()},edit_customer:function(){a("body").on("click","#edit-customer",function(a){a.preventDefault(),m.vars.customer_card_wrap_editable.hide(),m.vars.customer_card_wrap_edit_item.fadeIn().css("display","block")})},user_search:function(){a("body").on("click.eddSelectUser",".edd_user_search_results a",function(b){b.preventDefault();var c=a(this).data("userid");m.vars.user_id.val(c)})},remove_user:function(){a("body").on("click","#disconnect-customer",function(b){b.preventDefault();var c=a('input[name="customerinfo[id]"]').val(),d={edd_action:"disconnect-userid",customer_id:c,_wpnonce:a("#edit-customer-info #_wpnonce").val()};a.post(ajaxurl,d,function(){window.location.href=window.location.href},"json")})},cancel_edit:function(){a("body").on("click","#edd-edit-customer-cancel",function(b){b.preventDefault(),m.vars.customer_card_wrap_edit_item.hide(),m.vars.customer_card_wrap_editable.show(),a(".edd_user_search_results").html("")})},change_country:function(){a('select[name="customerinfo[country]"]').change(function(){var b=a(this);return data={action:"edd_get_shop_states",country:b.val(),field_name:"customerinfo[state]"},a.post(ajaxurl,data,function(a){"nostates"==a?m.vars.state_input.replaceWith('<input type="text" name="'+data.field_name+'" value="" class="edd-edit-toggles medium-text"/>'):m.vars.state_input.replaceWith(a)}),!1})},add_note:function(){a("body").on("click","#add-customer-note",function(b){b.preventDefault();var c={edd_action:"add-customer-note",customer_id:a("#customer-id").val(),customer_note:m.vars.note.val(),add_customer_note_nonce:a("#add_customer_note_nonce").val()};if(c.customer_note)a.ajax({type:"POST",data:c,url:ajaxurl,success:function(b){a("#edd-customer-notes").prepend(b),a(".edd-no-customer-notes").hide(),m.vars.note.val("")}}).fail(function(a){window.console&&window.console.log&&console.log(a)});else{var d=m.vars.note.css("border-color");m.vars.note.css("border-color","red"),setTimeout(function(){m.vars.note.css("border-color",d)},500)}})},delete_checked:function(){a("#edd-customer-delete-confirm").change(function(){var b=a("#edd-customer-delete-records"),c=a("#edd-delete-customer");a(this).prop("checked")?(b.attr("disabled",!1),c.attr("disabled",!1)):(b.attr("disabled",!0),b.prop("checked",!1),c.attr("disabled",!0))})}};m.init(),a(".edd-ajax-user-search").keyup(function(){var b=a(this).val(),c="";a(this).data("exclude")&&(c=a(this).data("exclude")),a(".edd-ajax").show(),data={action:"edd_search_users",user_name:b,exclude:c},document.body.style.cursor="wait",a.ajax({type:"POST",data:data,dataType:"json",url:ajaxurl,success:function(b){a(".edd-ajax").hide(),a(".edd_user_search_results").removeClass("hidden"),a(".edd_user_search_results span").html(""),a(b.results).appendTo(".edd_user_search_results span"),document.body.style.cursor="default"}})}),a("body").on("click.eddSelectUser",".edd_user_search_results span a",function(b){b.preventDefault();var c=a(this).data("login");a(".edd-ajax-user-search").val(c),a(".edd_user_search_results").addClass("hidden"),a(".edd_user_search_results span").html("")}),a("body").on("click.eddCancelUserSearch",".edd_user_search_results a.edd-ajax-user-cancel",function(b){b.preventDefault(),a(".edd-ajax-user-search").val(""),a(".edd_user_search_results").addClass("hidden"),a(".edd_user_search_results span").html("")}),a.ajax({type:"GET",data:{action:"edd_load_dashboard_widget"},url:ajaxurl,success:function(b){a("#edd_dashboard_sales .inside").html(b)}}),a(document).on("keydown",".customer-note-input",function(b){13==b.keyCode&&(b.metaKey||b.ctrlKey)&&a("#add-customer-note").click()})});var eddFormatCurrency=function(a){var b=parseFloat(a),c=edd_vars.currency,d=edd_vars.currency_decimals;return b.toLocaleString(c,{style:"currency",currency:c,minimumFractionDigits:d,maximumFractionDigits:d})},eddFormatNumber=function(a){var b=parseFloat(a),c=edd_vars.currency;return edd_vars.currency_decimals,b.toLocaleString(c,{style:"decimal",minimumFractionDigits:0,maximumFractionDigits:0})},eddLabelFormatter=function(a){return'<div style="font-size:12px; text-align:center; padding:2px">'+a+"</div>"},eddLegendFormatterSales=function(a,b){var c=a.toLowerCase().replace(/\s/g,"-"),d='<div class="edd-legend-color" style="background-color: '+b.color+'"></div>',e='<div class="edd-pie-legend-item">'+a+": "+Math.round(b.percent)+"% ("+eddFormatNumber(b.data[0][1])+")</div>",f='<div id="'+b.edd_vars.id+c+'" class="edd-legend-item-wrapper">'+d+e+"</div>";return jQuery("#edd-pie-legend-"+b.edd_vars.id).append(f),f},eddLegendFormatterEarnings=function(a,b){var c=a.toLowerCase().replace(/\s/g,"-"),d='<div class="edd-legend-color" style="background-color: '+b.color+'"></div>',e='<div class="edd-pie-legend-item">'+a+": "+Math.round(b.percent)+"% ("+eddFormatCurrency(b.data[0][1])+")</div>",f='<div id="'+b.edd_vars.id+c+'" class="edd-legend-item-wrapper">'+d+e+"</div>";return jQuery("#edd-pie-legend-"+b.edd_vars.id).append(f),f};
|
1 |
+
jQuery(document).ready(function(e){var t={init:function(){this.add(),this.move(),this.remove(),this.type(),this.prices(),this.files(),this.updatePrices()},clone_repeatable:function(t){var d=highest=1;return t.parent().find("tr.edd_repeatable_row").each(function(){var t=e(this).data("key");parseInt(t)>highest&&(highest=t)}),d=highest+=1,clone=t.clone(),clone.find("select").each(function(){e(this).val(t.find('select[name="'+e(this).attr("name")+'"]').val())}),clone.removeClass("edd_add_blank"),clone.attr("data-key",d),clone.find("td input, td select, textarea").val(""),clone.find("input, select, textarea").each(function(){var t=e(this).attr("name");t=t.replace(/\[(\d+)\]/,"["+parseInt(d)+"]"),e(this).attr("name",t).attr("id",t)}),clone.find("span.edd_price_id").each(function(){e(this).text(parseInt(d))}),clone.find(".edd_repeatable_default_input").each(function(){e(this).val(parseInt(d)).removeAttr("checked")}),clone},add:function(){e("body").on("click",".submit .edd_add_repeatable",function(d){d.preventDefault();var n=e(this),a=n.parent().parent().prev("tr"),i=t.clone_repeatable(a);i.insertAfter(a).find("input, textarea, select").filter(":visible").eq(0).focus()})},move:function(){e(".edd_repeatable_table tbody").sortable({handle:".edd_draghandle",items:".edd_repeatable_row",opacity:.6,cursor:"move",axis:"y",update:function(){var t=0;e(this).find("tr").each(function(){e(this).find("input.edd_repeatable_index").each(function(){e(this).val(t)}),t++})}})},remove:function(){e("body").on("click",".edd_remove_repeatable",function(t){t.preventDefault();var d=e(this).parent().parent("tr"),n=d.parent().find("tr").length-1,a=e(this).data("type"),i="tr.edd_repeatable_"+a+"s";if("price"===a){var o=d.data("key");e('.edd_repeatable_condition_field option[value="'+o+'"]').remove()}if(n>1)e("input, select",d).val(""),d.fadeOut("fast").remove();else switch(a){case"price":alert(edd_vars.one_price_min);break;case"file":e("input, select",d).val("");break;default:alert(edd_vars.one_field_min)}e(i).each(function(t){e(this).find("input, select").each(function(){var d=e(this).attr("name");d=d.replace(/\[(\d+)\]/,"["+t+"]"),e(this).attr("name",d).attr("id",d)})})})},type:function(){e("body").on("change","#_edd_product_type",function(){var t=e("#edd_products"),d=e("#edd_download_files"),n=e("#edd_download_limit_wrap");"bundle"===e(this).val()?(t.show(),d.hide(),n.hide()):(t.hide(),d.show(),n.show())})},prices:function(){e("body").on("change","#edd_variable_pricing",function(){e(".edd_pricing_fields,.edd_repeatable_table .pricing").toggle()})},files:function(){if("undefined"==typeof wp||"1"!==edd_vars.new_media_ui)e(".edd_upload_file_button").length>0&&(window.formfield="",e("body").on("click",".edd_upload_file_button",function(t){if(t.preventDefault(),window.formfield=e(this).parent().prev(),window.tbframe_interval=setInterval(function(){jQuery("#TB_iframeContent").contents().find(".savesend .button").val(edd_vars.use_this_file).end().find("#insert-gallery, .wp-post-thumbnail").hide()},2e3),null!=edd_vars.post_id)var d="post_id="+edd_vars.post_id+"&";tb_show(edd_vars.add_new_download,"media-upload.php?"+d+"TB_iframe=true")}),window.edd_send_to_editor=window.send_to_editor,window.send_to_editor=function(t){window.formfield?(imgurl=e("a","<div>"+t+"</div>").attr("href"),window.formfield.val(imgurl),window.clearInterval(window.tbframe_interval),tb_remove()):window.edd_send_to_editor(t),window.send_to_editor=window.edd_send_to_editor,window.formfield="",window.imagefield=!1});else{var d;window.formfield="",e("body").on("click",".edd_upload_file_button",function(n){n.preventDefault();var a=e(this);return window.formfield=e(this).closest(".edd_repeatable_upload_wrapper"),d?void d.open():(d=wp.media.frames.file_frame=wp.media({frame:"post",state:"insert",title:a.data("uploader-title"),button:{text:a.data("uploader-button-text")},multiple:"0"==e(this).data("multiple")?!1:!0}),d.on("menu:render:default",function(e){var t={};e.unset("library-separator"),e.unset("gallery"),e.unset("featured-image"),e.unset("embed"),e.set(t)}),d.on("insert",function(){var e=d.state().get("selection");e.each(function(e,d){if(e=e.toJSON(),0===d)window.formfield.find(".edd_repeatable_attachment_id_field").val(e.id),window.formfield.find(".edd_repeatable_upload_field").val(e.url),window.formfield.find(".edd_repeatable_name_field").val(e.title);else{var n=window.formfield,a=t.clone_repeatable(n);a.find(".edd_repeatable_attachment_id_field").val(e.id),a.find(".edd_repeatable_upload_field").val(e.url),a.find(".edd_repeatable_name_field").val(e.title.length>0?e.title:e.filename),a.insertAfter(n)}})}),void d.open())});var d;window.formfield=""}},updatePrices:function(){e("#edd_price_fields").on("keyup",".edd_variable_prices_name",function(){var t=e(this).parents("tr").data("key"),d=e(this).val(),n=e(".edd_repeatable_condition_field option[value="+t+"]");n.length>0?n.text(d):e(".edd_repeatable_condition_field").append(e("<option></option>").attr("value",t).text(d))})}};t.init();var d=e(".edd_datepicker");if(d.length>0){var n="mm/dd/yy";d.datepicker({dateFormat:n})}var a={init:function(){this.edit_address(),this.remove_download(),this.add_download(),this.new_customer(),this.recalculate_total(),this.variable_prices_check(),this.add_note(),this.remove_note(),this.resend_receipt(),this.copy_download_link()},edit_address:function(){e('select[name="edd-payment-address[0][country]"]').change(function(){var t=e(this);return data={action:"edd_get_shop_states",country:t.val(),field_name:"edd-payment-address[0][state]"},e.post(ajaxurl,data,function(t){var d=e("#edd-order-address-state-wrap select, #edd-order-address-state-wrap input");d.replaceWith("nostates"==t?'<input type="text" name="edd-payment-address[0][state]" value="" class="edd-edit-toggles medium-text"/>':t)}),!1})},remove_download:function(){e("#edd-purchased-files").on("click",".edd-order-remove-download",function(){var t=e("body").find("#edd-purchased-files > .row").length;if(1===t)return alert(edd_vars.one_download_min),!1;if(confirm(edd_vars.delete_payment_download)){var d=e(this).data("key"),n=(e(".edd-payment-id").val(),e('input[name="edd-payment-details-downloads['+d+'][id]"]').val()),a=e('input[name="edd-payment-details-downloads['+d+'][price_id]"]').val(),i=e('input[name="edd-payment-details-downloads['+d+'][quantity]"]').val(),o=e('input[name="edd-payment-details-downloads['+d+'][amount]"]').val(),r=e('input[name="edd-payment-removed"]').val();r=e.parseJSON(r),r.length<1&&(r={});var s=[{id:n,price_id:a,quantity:i,amount:o}];r[d]=s,e('input[name="edd-payment-removed"]').val(JSON.stringify(r)),e(this).parent().parent().parent().remove(),e("#edd-payment-downloads-changed").val(1),e(".edd-order-payment-recalc-totals").show()}return!1})},new_customer:function(){e("#edd-customer-details").on("click",".edd-payment-new-customer, .edd-payment-new-customer-cancel",function(t){t.preventDefault(),e(".customer-info").toggle(),e(".new-customer").toggle();var d=e("#edd-new-customer");d.val(e(".new-customer").is(":visible")?1:0)})},add_download:function(){e("#edd-purchased-files").on("click","#edd-order-add-download",function(t){t.preventDefault();var d=e("#edd_order_download_select"),n=e("#edd-order-download-quantity"),a=e("#edd-order-download-amount"),i=e(".edd_price_options_select option:selected"),o=d.val(),r=d.find(":selected").text(),s=n.val(),c=a.val(),l=i.val(),u=i.text();if(1>o)return!1;if(c||(c=0),c=parseFloat(c),isNaN(c))return alert(edd_vars.numeric_item_price),!1;if("1"===edd_vars.quantities_enabled){if(isNaN(parseInt(s)))return alert(edd_vars.numeric_quantity),!1;c*=s}c=c.toFixed(edd_vars.currency_decimals);var _=c+edd_vars.currency_sign;"before"===edd_vars.currency_pos&&(_=edd_vars.currency_sign+c),u&&(r=r+" - "+u);var p=e("#edd-purchased-files div.row").length,f=e("#edd-purchased-files div.row:last").clone();f.find(".download span").html('<a href="post.php?post='+o+'&action=edit"></a>'),f.find(".download span a").text(r),f.find(".price-text").text(_),f.find(".item-quantity").text(s),f.find(".item-price").text(edd_vars.currency_sign+(c/s).toFixed(edd_vars.currency_decimals)),f.find("input.edd-payment-details-download-id").val(o),f.find("input.edd-payment-details-download-price-id").val(l),f.find("input.edd-payment-details-download-amount").val(c),f.find("input.edd-payment-details-download-quantity").val(s),f.find("input.edd-payment-details-download-has-log").val(0),f.find("input").each(function(){var t=e(this).attr("name");t=t.replace(/\[(\d+)\]/,"["+parseInt(p)+"]"),e(this).attr("name",t).attr("id",t)}),e("#edd-payment-downloads-changed").val(1),e(f).insertAfter("#edd-purchased-files div.row:last"),e(".edd-order-payment-recalc-totals").show()})},recalculate_total:function(){e("#edd-order-recalc-total").on("click",function(t){t.preventDefault();var d=0,n=e("#edd-purchased-files .row .edd-payment-details-download-amount");n.length&&n.each(function(){d+=parseFloat(e(this).val())}),e(".edd-payment-fees").length&&e(".edd-payment-fees span.fee-amount").each(function(){d+=parseFloat(e(this).data("fee"))}),e("input[name=edd-payment-total]").val(d)})},variable_prices_check:function(){e("#edd-purchased-files").on("change","select#edd_order_download_select",function(){var t=e(this),d=t.val();if(parseInt(d)>0){var n={action:"edd_check_for_download_price_variations",download_id:d};e.ajax({type:"POST",data:n,url:ajaxurl,success:function(d){e(".edd_price_options_select").remove(),e(d).insertAfter(t.next())}}).fail(function(e){window.console&&window.console.log&&console.log(e)})}})},add_note:function(){e("#edd-add-payment-note").on("click",function(t){t.preventDefault();var d={action:"edd_insert_payment_note",payment_id:e(this).data("payment-id"),note:e("#edd-payment-note").val()};if(d.note)e.ajax({type:"POST",data:d,url:ajaxurl,success:function(t){e("#edd-payment-notes-inner").append(t),e(".edd-no-payment-notes").hide(),e("#edd-payment-note").val("")}}).fail(function(e){window.console&&window.console.log&&console.log(e)});else{var n=e("#edd-payment-note").css("border-color");e("#edd-payment-note").css("border-color","red"),setTimeout(function(){e("#edd-payment-note").css("border-color",n)},500)}})},remove_note:function(){e("body").on("click",".edd-delete-payment-note",function(t){if(t.preventDefault(),confirm(edd_vars.delete_payment_note)){var d={action:"edd_delete_payment_note",payment_id:e(this).data("payment-id"),note_id:e(this).data("note-id")};return e.ajax({type:"POST",data:d,url:ajaxurl,success:function(){return e("#edd-payment-note-"+d.note_id).remove(),e(".edd-payment-note").length||e(".edd-no-payment-notes").show(),!1}}).fail(function(e){window.console&&window.console.log&&console.log(e)}),!0}})},resend_receipt:function(){e("body").on("click","#edd-resend-receipt",function(){return confirm(edd_vars.resend_receipt)})},copy_download_link:function(){e("body").on("click",".edd-copy-download-link",function(t){t.preventDefault();var d=e(this),n={action:"edd_get_file_download_link",payment_id:e('input[name="edd_payment_id"]').val(),download_id:d.data("download-id"),price_id:d.data("price-id")};e.ajax({type:"POST",data:n,url:ajaxurl,success:function(t){return e("#edd-download-link").dialog({width:400}).html('<textarea rows="10" cols="40" id="edd-download-link-textarea">'+t+"</textarea>"),e("#edd-download-link-textarea").focus().select(),!1}}).fail(function(e){window.console&&window.console.log&&console.log(e)})})}};a.init();var i={init:function(){this.type_select(),this.product_requirements()},type_select:function(){e("#edd-edit-discount #edd-type, #edd-add-discount #edd-type").change(function(){e(".edd-amount-description").toggle()})},product_requirements:function(){e("#products").change(function(){var t=e("#edd-discount-product-conditions");e(this).val()?t.show():t.hide()})}};i.init();var o={init:function(){this.date_options(),this.customers_export()},date_options:function(){e("#edd-graphs-date-options").change(function(){var t=e(this),d=e("#edd-date-range-options");"other"===t.val()?d.show():d.hide()})},customers_export:function(){e("#edd_customer_export_download").change(function(){var t=e(this),d=e("option:selected",t).val(),n=e("#edd_customer_export_option");if("0"===t.val()?n.show():n.hide(),0!=parseInt(d)){var a={action:"edd_check_for_download_price_variations",download_id:d},i=e(".edd_price_options_select");e.post(ajaxurl,a,function(e){i.remove(),t.after(e)})}else i.remove()})}};o.init();var r={init:function(){this.general(),this.taxes(),this.emails(),this.misc()},general:function(){var t=e(".edd-color-picker");if(t.length&&t.wpColorPicker(),"undefined"==typeof wp||"1"!==edd_vars.new_media_ui){var d=e(".edd_settings_upload_button");d.length>0&&(window.formfield="",e("body").on("click",d,function(t){t.preventDefault(),window.formfield=e(this).parent().prev(),window.tbframe_interval=setInterval(function(){jQuery("#TB_iframeContent").contents().find(".savesend .button").val(edd_vars.use_this_file).end().find("#insert-gallery, .wp-post-thumbnail").hide()},2e3),tb_show(edd_vars.add_new_download,"media-upload.php?TB_iframe=true")}),window.edd_send_to_editor=window.send_to_editor,window.send_to_editor=function(t){window.formfield?(imgurl=e("a","<div>"+t+"</div>").attr("href"),window.formfield.val(imgurl),window.clearInterval(window.tbframe_interval),tb_remove()):window.edd_send_to_editor(t),window.send_to_editor=window.edd_send_to_editor,window.formfield="",window.imagefield=!1})}else{var n;window.formfield="",e("body").on("click",".edd_settings_upload_button",function(t){t.preventDefault();var d=e(this);return window.formfield=e(this).parent().prev(),n?void n.open():(n=wp.media.frames.file_frame=wp.media({frame:"post",state:"insert",title:d.data("uploader_title"),button:{text:d.data("uploader_button_text")},multiple:!1}),n.on("menu:render:default",function(e){var t={};e.unset("library-separator"),e.unset("gallery"),e.unset("featured-image"),e.unset("embed"),e.set(t)}),n.on("insert",function(){var e=n.state().get("selection");e.each(function(e){e=e.toJSON(),window.formfield.val(e.url)})}),void n.open())});var n;window.formfield=""}},taxes:function(){var t=e("select.edd-no-states");t.length&&t.closest("tr").hide(),e('select[name="edd_settings[base_country]"]').change(function(){var t=e(this),d=t.closest("tr");return data={action:"edd_get_shop_states",country:e(this).val(),field_name:"edd_settings[base_state]"},e.post(ajaxurl,data,function(e){"nostates"==e?d.next().hide():(d.next().show(),d.next().find("select").replaceWith(e))}),!1}),e("body").on("change","#edd_tax_rates select.edd-tax-country",function(){var t=e(this);return data={action:"edd_get_shop_states",country:e(this).val(),field_name:t.attr("name").replace("country","state")},e.post(ajaxurl,data,function(e){if("nostates"==e){var d='<input type="text" name="'+data.field_name+'" value=""/>';t.parent().next().find("select").replaceWith(d)}else t.parent().next().find("input,select").show(),t.parent().next().find("input,select").replaceWith(e)}),!1}),e("#edd_add_tax_rate").on("click",function(){var t=e("#edd_tax_rates tr:last"),d=t.clone(),n=t.parent().find("tr").length;return d.find("td input").not(":input[type=checkbox]").val(""),d.find('td [type="checkbox"]').attr("checked",!1),d.find("input, select").each(function(){var t=e(this).attr("name");t=t.replace(/\[(\d+)\]/,"["+parseInt(n)+"]"),e(this).attr("name",t).attr("id",t)}),d.find("label").each(function(){var t=e(this).attr("for");t=t.replace(/\[(\d+)\]/,"["+parseInt(n)+"]"),e(this).attr("for",t)}),d.insertAfter(t),!1}),e("body").on("click","#edd_tax_rates .edd_remove_tax_rate",function(){if(confirm(edd_vars.delete_tax_rate)){var t=e("#edd_tax_rates tr:visible"),d=t.length;2===d?(e("#edd_tax_rates select").val(""),e('#edd_tax_rates input[type="text"]').val(""),e('#edd_tax_rates input[type="number"]').val(""),e('#edd_tax_rates input[type="checkbox"]').attr("checked",!1)):e(this).closest("tr").remove(),e("#edd_tax_rates tr").each(function(t){e(this).children().find("input, select").each(function(){var d=e(this).attr("name");d=d.replace(/\[(\d+)\]/,"["+(t-1)+"]"),e(this).attr("name",d).attr("id",d)})})}return!1})},emails:function(){var t=e("#email-preview-wrap");if(t.length){var d=e("#email-preview");t.colorbox({inline:!0,href:d,width:"80%",height:"auto"})}},misc:function(){var t=e('select[name="edd_settings[download_method]"]'),d=t.parent().parent().next();"direct"==t.val()&&(d.hide(),d.find("input").prop("checked",!1)),t.on("change",function(){"direct"==e(this).val()?(d.hide(),d.find("input").prop("checked",!1)):d.show()})}};r.init(),e(".download_page_edd-payment-history .row-actions .delete a").on("click",function(){return confirm(edd_vars.delete_payment)?!0:!1}),e("#the-list").on("click",".editinline",function(){inlineEditPost.revert();var t=e(this).closest("tr").attr("id");t=t.replace("post-","");var d=e("#post-"+t),n=d.find(".column-price .downloadprice-"+t).val();n!=e("#post-"+t+".column-price .downloadprice-"+t).val()?e(".regprice","#edd-download-data").val(n).attr("disabled",!1):e(".regprice","#edd-download-data").val(edd_vars.quick_edit_warning).attr("disabled","disabled")}),e("body").on("click","#bulk_edit",function(){var t=e("#bulk-edit"),d=new Array;t.find("#bulk-titles").children().each(function(){d.push(e(this).attr("id").replace(/^(ttle)/i,""))});var n=e('#edd-download-data input[name="_edd_regprice"]').val(),a={action:"edd_save_bulk_edit",edd_bulk_nonce:d,post_ids:d,price:n};e.post(ajaxurl,a)}),e(".edd-select-chosen").chosen({inherit_select_classes:!0,placeholder_text_single:edd_vars.one_option,placeholder_text_multiple:edd_vars.one_or_more_option}),e(".chosen-choices").on("click",function(){e(this).children("li").children("input").attr("placeholder",edd_vars.type_to_search)});var s,c=342;e(".edd-select.chosen-container .chosen-search input, .edd-select.chosen-container .search-field input").keyup(function(t){var d=e(this).val(),n=e(this).closest(".edd-select-chosen"),a=n.attr("id").replace("_chosen",""),i=(t.which,"edd_download_search");n.attr("id").indexOf("customer")>=0&&(i="edd_customer_search"),d.length<=3&&"edd_download_search"==i||16==t.which||13==t.which||91==t.which||17==t.which||37==t.which||38==t.which||39==t.which||40==t.which||(clearTimeout(s),s=setTimeout(function(){e.ajax({type:"GET",url:ajaxurl,data:{action:i,s:d,current_id:edd_vars.post_id},dataType:"json",beforeSend:function(){e("ul.chosen-results").empty()},success:function(t){e("#"+a+" option:not(:selected)").remove(),e.each(t,function(t,d){e("#"+a+' option[value="'+d.id+'"]').length||e("#"+a).prepend('<option value="'+d.id+'">'+d.name+"</option>")}),e(".edd-select-chosen").trigger("chosen:updated"),e("#"+a).next().find("input").val(d)}}).fail(function(e){window.console&&window.console.log&&console.log(e)}).done(function(){})},c))}),e("#post").on("click",".edd-thickbox",function(){e(".edd-select-chosen","#choose-download").css("width","100%")});var l={init:function(){this.revoke_api_key(),this.regenerate_api_key()},revoke_api_key:function(){e("body").on("click",".edd-revoke-api-key",function(){return confirm(edd_vars.revoke_api_key)})},regenerate_api_key:function(){e("body").on("click",".edd-regenerate-api-key",function(){return confirm(edd_vars.regenerate_api_key)})}};l.init();var u={init:function(){this.submit()},submit:function(){var t=this;e("body").on("submit",".edd-export-form",function(d){d.preventDefault();var n=e(this).serialize();e(this).append('<span class="spinner is-active"></span><div class="edd-progress"><div></div></div>'),t.process_step(1,n,t)})},process_step:function(t,d,n){e.ajax({type:"POST",url:ajaxurl,data:{form:d,action:"edd_do_ajax_export",step:t},dataType:"json",success:function(t){if("done"==t.step){var a=e(".edd-export-form");a.find(".spinner").remove(),a.find(".edd-progress").remove(),window.location=t.url}else e(".edd-progress div").animate({width:t.percentage+"%"},50,function(){}),n.process_step(parseInt(t.step),d,n)}}).fail(function(e){window.console&&window.console.log&&console.log(e)})}};u.init();var _={vars:{customer_card_wrap_editable:e("#edd-customer-card-wrapper .editable"),customer_card_wrap_edit_item:e("#edd-customer-card-wrapper .edit-item"),user_id:e('input[name="customerinfo[user_id]"]'),state_input:e(':input[name="customerinfo[state]"]'),note:e("#customer-note")},init:function(){this.edit_customer(),this.user_search(),this.remove_user(),this.cancel_edit(),this.change_country(),this.add_note(),this.delete_checked()},edit_customer:function(){e("body").on("click","#edit-customer",function(e){e.preventDefault(),_.vars.customer_card_wrap_editable.hide(),_.vars.customer_card_wrap_edit_item.fadeIn().css("display","block")})},user_search:function(){e("body").on("click.eddSelectUser",".edd_user_search_results a",function(t){t.preventDefault();var d=e(this).data("userid");_.vars.user_id.val(d)})},remove_user:function(){e("body").on("click","#disconnect-customer",function(t){t.preventDefault();var d=e('input[name="customerinfo[id]"]').val(),n={edd_action:"disconnect-userid",customer_id:d,_wpnonce:e("#edit-customer-info #_wpnonce").val()};e.post(ajaxurl,n,function(){window.location.href=window.location.href},"json")})},cancel_edit:function(){e("body").on("click","#edd-edit-customer-cancel",function(t){t.preventDefault(),_.vars.customer_card_wrap_edit_item.hide(),_.vars.customer_card_wrap_editable.show(),e(".edd_user_search_results").html("")})},change_country:function(){e('select[name="customerinfo[country]"]').change(function(){var t=e(this);return data={action:"edd_get_shop_states",country:t.val(),field_name:"customerinfo[state]"},e.post(ajaxurl,data,function(e){_.vars.state_input.replaceWith("nostates"==e?'<input type="text" name="'+data.field_name+'" value="" class="edd-edit-toggles medium-text"/>':e)}),!1})},add_note:function(){e("body").on("click","#add-customer-note",function(t){t.preventDefault();var d={edd_action:"add-customer-note",customer_id:e("#customer-id").val(),customer_note:_.vars.note.val(),add_customer_note_nonce:e("#add_customer_note_nonce").val()};if(d.customer_note)e.ajax({type:"POST",data:d,url:ajaxurl,success:function(t){e("#edd-customer-notes").prepend(t),e(".edd-no-customer-notes").hide(),_.vars.note.val("")}}).fail(function(e){window.console&&window.console.log&&console.log(e)});else{var n=_.vars.note.css("border-color");_.vars.note.css("border-color","red"),setTimeout(function(){_.vars.note.css("border-color",n)},500)}})},delete_checked:function(){e("#edd-customer-delete-confirm").change(function(){var t=e("#edd-customer-delete-records"),d=e("#edd-delete-customer");e(this).prop("checked")?(t.attr("disabled",!1),d.attr("disabled",!1)):(t.attr("disabled",!0),t.prop("checked",!1),d.attr("disabled",!0))})}};_.init(),e(".edd-ajax-user-search").keyup(function(){var t=e(this).val(),d="";e(this).data("exclude")&&(d=e(this).data("exclude")),e(".edd-ajax").show(),data={action:"edd_search_users",user_name:t,exclude:d},document.body.style.cursor="wait",e.ajax({type:"POST",data:data,dataType:"json",url:ajaxurl,success:function(t){e(".edd-ajax").hide(),e(".edd_user_search_results").removeClass("hidden"),e(".edd_user_search_results span").html(""),e(t.results).appendTo(".edd_user_search_results span"),document.body.style.cursor="default"}})}),e("body").on("click.eddSelectUser",".edd_user_search_results span a",function(t){t.preventDefault();var d=e(this).data("login");e(".edd-ajax-user-search").val(d),e(".edd_user_search_results").addClass("hidden"),e(".edd_user_search_results span").html("")}),e("body").on("click.eddCancelUserSearch",".edd_user_search_results a.edd-ajax-user-cancel",function(t){t.preventDefault(),e(".edd-ajax-user-search").val(""),e(".edd_user_search_results").addClass("hidden"),e(".edd_user_search_results span").html("")}),e.ajax({type:"GET",data:{action:"edd_load_dashboard_widget"},url:ajaxurl,success:function(t){e("#edd_dashboard_sales .inside").html(t)}}),e(document).on("keydown",".customer-note-input",function(t){13==t.keyCode&&(t.metaKey||t.ctrlKey)&&e("#add-customer-note").click()})});var eddFormatCurrency=function(e){var t=parseFloat(e),d=edd_vars.currency,n=edd_vars.currency_decimals;return t.toLocaleString(d,{style:"currency",currency:d,minimumFractionDigits:n,maximumFractionDigits:n})},eddFormatNumber=function(e){{var t=parseFloat(e),d=edd_vars.currency;edd_vars.currency_decimals}return t.toLocaleString(d,{style:"decimal",minimumFractionDigits:0,maximumFractionDigits:0})},eddLabelFormatter=function(e){return'<div style="font-size:12px; text-align:center; padding:2px">'+e+"</div>"},eddLegendFormatterSales=function(e,t){var d=e.toLowerCase().replace(/\s/g,"-"),n='<div class="edd-legend-color" style="background-color: '+t.color+'"></div>',a='<div class="edd-pie-legend-item">'+e+": "+Math.round(t.percent)+"% ("+eddFormatNumber(t.data[0][1])+")</div>",i='<div id="'+t.edd_vars.id+d+'" class="edd-legend-item-wrapper">'+n+a+"</div>";return jQuery("#edd-pie-legend-"+t.edd_vars.id).append(i),i},eddLegendFormatterEarnings=function(e,t){var d=e.toLowerCase().replace(/\s/g,"-"),n='<div class="edd-legend-color" style="background-color: '+t.color+'"></div>',a='<div class="edd-pie-legend-item">'+e+": "+Math.round(t.percent)+"% ("+eddFormatCurrency(t.data[0][1])+")</div>",i='<div id="'+t.edd_vars.id+d+'" class="edd-legend-item-wrapper">'+n+a+"</div>";return jQuery("#edd-pie-legend-"+t.edd_vars.id).append(i),i};
|
easy-digital-downloads.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* Description: Serve Digital Downloads Through WordPress
|
6 |
* Author: Pippin Williamson
|
7 |
* Author URI: https://pippinsplugins.com
|
8 |
-
* Version: 2.4.
|
9 |
* Text Domain: edd
|
10 |
* Domain Path: languages
|
11 |
*
|
@@ -25,7 +25,7 @@
|
|
25 |
* @package EDD
|
26 |
* @category Core
|
27 |
* @author Pippin Williamson
|
28 |
-
* @version 2.4.
|
29 |
*/
|
30 |
|
31 |
// Exit if accessed directly
|
@@ -187,7 +187,7 @@ final class Easy_Digital_Downloads {
|
|
187 |
|
188 |
// Plugin version
|
189 |
if ( ! defined( 'EDD_VERSION' ) ) {
|
190 |
-
define( 'EDD_VERSION', '2.4.
|
191 |
}
|
192 |
|
193 |
// Plugin Folder Path
|
5 |
* Description: Serve Digital Downloads Through WordPress
|
6 |
* Author: Pippin Williamson
|
7 |
* Author URI: https://pippinsplugins.com
|
8 |
+
* Version: 2.4.2
|
9 |
* Text Domain: edd
|
10 |
* Domain Path: languages
|
11 |
*
|
25 |
* @package EDD
|
26 |
* @category Core
|
27 |
* @author Pippin Williamson
|
28 |
+
* @version 2.4.2
|
29 |
*/
|
30 |
|
31 |
// Exit if accessed directly
|
187 |
|
188 |
// Plugin version
|
189 |
if ( ! defined( 'EDD_VERSION' ) ) {
|
190 |
+
define( 'EDD_VERSION', '2.4.2' );
|
191 |
}
|
192 |
|
193 |
// Plugin Folder Path
|
includes/admin/admin-actions.php
CHANGED
@@ -28,4 +28,4 @@ function edd_process_actions() {
|
|
28 |
do_action( 'edd_' . $_GET['edd-action'], $_GET );
|
29 |
}
|
30 |
}
|
31 |
-
add_action( 'admin_init', 'edd_process_actions' );
|
28 |
do_action( 'edd_' . $_GET['edd-action'], $_GET );
|
29 |
}
|
30 |
}
|
31 |
+
add_action( 'admin_init', 'edd_process_actions' );
|
includes/admin/reporting/export/class-batch-export-customers.php
CHANGED
@@ -37,7 +37,7 @@ class EDD_Batch_Customers_Export extends EDD_Batch_Export {
|
|
37 |
* @return array $cols All the columns
|
38 |
*/
|
39 |
public function csv_cols() {
|
40 |
-
|
41 |
$cols = array(
|
42 |
'id' => __( 'ID', 'edd' ),
|
43 |
'name' => __( 'Name', 'edd' ),
|
@@ -87,7 +87,7 @@ class EDD_Batch_Customers_Export extends EDD_Batch_Export {
|
|
87 |
|
88 |
if ( $logs ) {
|
89 |
foreach ( $logs as $log ) {
|
90 |
-
|
91 |
$payment_id = get_post_meta( $log->ID, '_edd_log_payment_id', true );
|
92 |
$customer_id = edd_get_payment_customer_id( $payment_id );
|
93 |
$customer = new EDD_Customer( $customer_id );
|
@@ -157,4 +157,17 @@ class EDD_Batch_Customers_Export extends EDD_Batch_Export {
|
|
157 |
|
158 |
return $percentage;
|
159 |
}
|
160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
* @return array $cols All the columns
|
38 |
*/
|
39 |
public function csv_cols() {
|
40 |
+
|
41 |
$cols = array(
|
42 |
'id' => __( 'ID', 'edd' ),
|
43 |
'name' => __( 'Name', 'edd' ),
|
87 |
|
88 |
if ( $logs ) {
|
89 |
foreach ( $logs as $log ) {
|
90 |
+
|
91 |
$payment_id = get_post_meta( $log->ID, '_edd_log_payment_id', true );
|
92 |
$customer_id = edd_get_payment_customer_id( $payment_id );
|
93 |
$customer = new EDD_Customer( $customer_id );
|
157 |
|
158 |
return $percentage;
|
159 |
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Set the properties specific to the Customers export
|
163 |
+
*
|
164 |
+
* @since 2.4.2
|
165 |
+
* @param array $request The Form Data passed into the batch processing
|
166 |
+
*/
|
167 |
+
public function set_properties( $request ) {
|
168 |
+
$this->start = isset( $request['start'] ) ? sanitize_text_field( $request['start'] ) : '';
|
169 |
+
$this->end = isset( $request['end'] ) ? sanitize_text_field( $request['end'] ) : '';
|
170 |
+
$this->download = isset( $request['download'] ) ? absint( $request['download'] ) : null;
|
171 |
+
$this->price_id = isset( $request['edd_price_option'] ) ? absint( $request['edd_price_option'] ) : null;
|
172 |
+
}
|
173 |
+
}
|
includes/admin/reporting/export/class-batch-export-file-downloads.php
CHANGED
@@ -37,7 +37,7 @@ class EDD_Batch_File_Downloads_Export extends EDD_Batch_Export {
|
|
37 |
* @return array $cols All the columns
|
38 |
*/
|
39 |
public function csv_cols() {
|
40 |
-
|
41 |
$cols = array(
|
42 |
'date' => __( 'Date', 'edd' ),
|
43 |
'user' => __( 'Downloaded by', 'edd' ),
|
@@ -156,4 +156,9 @@ class EDD_Batch_File_Downloads_Export extends EDD_Batch_Export {
|
|
156 |
|
157 |
return $percentage;
|
158 |
}
|
159 |
-
|
|
|
|
|
|
|
|
|
|
37 |
* @return array $cols All the columns
|
38 |
*/
|
39 |
public function csv_cols() {
|
40 |
+
|
41 |
$cols = array(
|
42 |
'date' => __( 'Date', 'edd' ),
|
43 |
'user' => __( 'Downloaded by', 'edd' ),
|
156 |
|
157 |
return $percentage;
|
158 |
}
|
159 |
+
|
160 |
+
public function set_properties( $request ) {
|
161 |
+
$this->start = isset( $request['start'] ) ? sanitize_text_field( $request['start'] ) : '';
|
162 |
+
$this->end = isset( $request['end'] ) ? sanitize_text_field( $request['end'] ) : '';
|
163 |
+
}
|
164 |
+
}
|
includes/admin/reporting/export/class-batch-export-payments.php
CHANGED
@@ -207,7 +207,7 @@ class EDD_Batch_Payments_Export extends EDD_Batch_Export {
|
|
207 |
* @return int
|
208 |
*/
|
209 |
public function get_percentage_complete() {
|
210 |
-
|
211 |
$status = $this->status;
|
212 |
$args = array(
|
213 |
'start-date' => date( 'Y-n-d H:i:s', strtotime( $this->start ) ),
|
@@ -221,7 +221,7 @@ class EDD_Batch_Payments_Export extends EDD_Batch_Export {
|
|
221 |
} else {
|
222 |
|
223 |
$total = edd_count_payments( $args )->$status;
|
224 |
-
|
225 |
}
|
226 |
|
227 |
$percentage = 100;
|
@@ -236,4 +236,16 @@ class EDD_Batch_Payments_Export extends EDD_Batch_Export {
|
|
236 |
|
237 |
return $percentage;
|
238 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
}
|
207 |
* @return int
|
208 |
*/
|
209 |
public function get_percentage_complete() {
|
210 |
+
|
211 |
$status = $this->status;
|
212 |
$args = array(
|
213 |
'start-date' => date( 'Y-n-d H:i:s', strtotime( $this->start ) ),
|
221 |
} else {
|
222 |
|
223 |
$total = edd_count_payments( $args )->$status;
|
224 |
+
|
225 |
}
|
226 |
|
227 |
$percentage = 100;
|
236 |
|
237 |
return $percentage;
|
238 |
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* Set the properties specific to the payments export
|
242 |
+
*
|
243 |
+
* @since 2.4.2
|
244 |
+
* @param array $request The Form Data passed into the batch processing
|
245 |
+
*/
|
246 |
+
public function set_properties( $request ) {
|
247 |
+
$this->start = isset( $request['start'] ) ? sanitize_text_field( $request['start'] ) : '';
|
248 |
+
$this->end = isset( $request['end'] ) ? sanitize_text_field( $request['end'] ) : '';
|
249 |
+
$this->status = isset( $request['status'] ) ? sanitize_text_field( $request['status'] ) : 'complete';
|
250 |
+
}
|
251 |
}
|
includes/admin/reporting/export/class-batch-export.php
CHANGED
@@ -137,7 +137,7 @@ class EDD_Batch_Export extends EDD_Export {
|
|
137 |
* @return string
|
138 |
*/
|
139 |
public function print_csv_cols() {
|
140 |
-
|
141 |
$col_data = '';
|
142 |
$cols = $this->get_csv_cols();
|
143 |
$i = 1;
|
@@ -147,7 +147,7 @@ class EDD_Batch_Export extends EDD_Export {
|
|
147 |
$i++;
|
148 |
}
|
149 |
$col_data .= "\r\n";
|
150 |
-
|
151 |
$this->stash_step_data( $col_data );
|
152 |
|
153 |
return $col_data;
|
@@ -162,7 +162,7 @@ class EDD_Batch_Export extends EDD_Export {
|
|
162 |
* @return string|false
|
163 |
*/
|
164 |
public function print_csv_rows() {
|
165 |
-
|
166 |
$row_data = '';
|
167 |
$data = $this->get_data();
|
168 |
$cols = $this->get_csv_cols();
|
@@ -207,7 +207,7 @@ class EDD_Batch_Export extends EDD_Export {
|
|
207 |
* @since 2.4
|
208 |
* @return string
|
209 |
*/
|
210 |
-
|
211 |
$file = @file_get_contents( $this->file );
|
212 |
if( ! $file ) {
|
213 |
@file_put_contents( $this->file, '' );
|
@@ -219,10 +219,10 @@ class EDD_Batch_Export extends EDD_Export {
|
|
219 |
* Append data to export file
|
220 |
*
|
221 |
* @since 2.4
|
222 |
-
* @param $data string The data to add to the file
|
223 |
* @return void
|
224 |
*/
|
225 |
-
|
226 |
|
227 |
$file = $this->get_file();
|
228 |
$file .= $data;
|
@@ -250,4 +250,5 @@ class EDD_Batch_Export extends EDD_Export {
|
|
250 |
|
251 |
edd_die();
|
252 |
}
|
|
|
253 |
}
|
137 |
* @return string
|
138 |
*/
|
139 |
public function print_csv_cols() {
|
140 |
+
|
141 |
$col_data = '';
|
142 |
$cols = $this->get_csv_cols();
|
143 |
$i = 1;
|
147 |
$i++;
|
148 |
}
|
149 |
$col_data .= "\r\n";
|
150 |
+
|
151 |
$this->stash_step_data( $col_data );
|
152 |
|
153 |
return $col_data;
|
162 |
* @return string|false
|
163 |
*/
|
164 |
public function print_csv_rows() {
|
165 |
+
|
166 |
$row_data = '';
|
167 |
$data = $this->get_data();
|
168 |
$cols = $this->get_csv_cols();
|
207 |
* @since 2.4
|
208 |
* @return string
|
209 |
*/
|
210 |
+
protected function get_file() {
|
211 |
$file = @file_get_contents( $this->file );
|
212 |
if( ! $file ) {
|
213 |
@file_put_contents( $this->file, '' );
|
219 |
* Append data to export file
|
220 |
*
|
221 |
* @since 2.4
|
222 |
+
* @param $data string The data to add to the file
|
223 |
* @return void
|
224 |
*/
|
225 |
+
protected function stash_step_data( $data = '' ) {
|
226 |
|
227 |
$file = $this->get_file();
|
228 |
$file .= $data;
|
250 |
|
251 |
edd_die();
|
252 |
}
|
253 |
+
|
254 |
}
|
includes/admin/reporting/export/export-actions.php
ADDED
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Exports ACtions
|
4 |
+
*
|
5 |
+
* These are actions related to exporting data from Easy Digital Downloads.
|
6 |
+
*
|
7 |
+
* @package EDD
|
8 |
+
* @subpackage Admin/Export
|
9 |
+
* @copyright Copyright (c) 2015, Pippin Williamson
|
10 |
+
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
11 |
+
*/
|
12 |
+
if ( ! defined( 'ABSPATH' ) ) { exit; }
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Process the download file generated by a batch export
|
16 |
+
*
|
17 |
+
* @since 2.4
|
18 |
+
* @return void
|
19 |
+
*/
|
20 |
+
function edd_process_batch_export_download() {
|
21 |
+
|
22 |
+
if( ! wp_verify_nonce( $_REQUEST['nonce'], 'edd-batch-export' ) ) {
|
23 |
+
wp_die( __( 'Nonce verification failed', 'edd' ), __( 'Error', 'edd' ), array( 'response' => 403 ) );
|
24 |
+
}
|
25 |
+
|
26 |
+
require_once EDD_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export.php';
|
27 |
+
|
28 |
+
do_action( 'edd_batch_export_class_include', $_REQUEST['class'] );
|
29 |
+
|
30 |
+
$export = new $_REQUEST['class'];
|
31 |
+
$export->export();
|
32 |
+
|
33 |
+
}
|
34 |
+
add_action( 'edd_download_batch_export', 'edd_process_batch_export_download' );
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Exports earnings for a specified time period
|
38 |
+
* EDD_Earnings_Export class.
|
39 |
+
*
|
40 |
+
* @since 2.0
|
41 |
+
* @return void
|
42 |
+
*/
|
43 |
+
function edd_export_earnings() {
|
44 |
+
require_once EDD_PLUGIN_DIR . 'includes/admin/reporting/class-export-earnings.php';
|
45 |
+
|
46 |
+
$earnings_export = new EDD_Earnings_Export();
|
47 |
+
|
48 |
+
$earnings_export->export();
|
49 |
+
}
|
50 |
+
add_action( 'edd_earnings_export', 'edd_export_earnings' );
|
51 |
+
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Export all the customers to a CSV file.
|
55 |
+
*
|
56 |
+
* Note: The WordPress Database API is being used directly for performance
|
57 |
+
* reasons (workaround of calling all posts and fetch data respectively)
|
58 |
+
*
|
59 |
+
* @since 1.4.4
|
60 |
+
* @return void
|
61 |
+
*/
|
62 |
+
function edd_export_all_customers() {
|
63 |
+
require_once EDD_PLUGIN_DIR . 'includes/admin/reporting/class-export-customers.php';
|
64 |
+
|
65 |
+
$customer_export = new EDD_Customers_Export();
|
66 |
+
|
67 |
+
$customer_export->export();
|
68 |
+
}
|
69 |
+
add_action( 'edd_email_export', 'edd_export_all_customers' );
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Exports all the downloads to a CSV file using the EDD_Export class.
|
73 |
+
*
|
74 |
+
* @since 1.4.4
|
75 |
+
* @return void
|
76 |
+
*/
|
77 |
+
function edd_export_all_downloads_history() {
|
78 |
+
require_once EDD_PLUGIN_DIR . 'includes/admin/reporting/class-export-download-history.php';
|
79 |
+
|
80 |
+
$file_download_export = new EDD_Download_History_Export();
|
81 |
+
|
82 |
+
$file_download_export->export();
|
83 |
+
}
|
84 |
+
add_action( 'edd_downloads_history_export', 'edd_export_all_downloads_history' );
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Add a hook allowing extensions to register a hook on the batch export process
|
88 |
+
*
|
89 |
+
* @since 2.4.2
|
90 |
+
* @return void
|
91 |
+
*/
|
92 |
+
function edd_register_batch_exporters() {
|
93 |
+
if ( is_admin() ) {
|
94 |
+
do_action( 'edd_register_batch_exporter' );
|
95 |
+
}
|
96 |
+
}
|
97 |
+
add_action( 'plugins_loaded', 'edd_register_batch_exporters' );
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Register the payments batch exporter
|
101 |
+
* @since 2.4.2
|
102 |
+
*/
|
103 |
+
function edd_register_payments_batch_export() {
|
104 |
+
add_action( 'edd_batch_export_class_include', 'edd_include_payments_batch_processer', 10, 1 );
|
105 |
+
}
|
106 |
+
add_action( 'edd_register_batch_exporter', 'edd_register_payments_batch_export', 10 );
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Loads the payments batch process if needed
|
110 |
+
*
|
111 |
+
* @since 2.4.2
|
112 |
+
* @param string $class The class being requested to run for the batch export
|
113 |
+
* @return void
|
114 |
+
*/
|
115 |
+
function edd_include_payments_batch_processer( $class ) {
|
116 |
+
|
117 |
+
if ( 'EDD_Batch_Payments_Export' === $class ) {
|
118 |
+
require_once EDD_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-payments.php';
|
119 |
+
}
|
120 |
+
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Register the customers batch exporter
|
125 |
+
* @since 2.4.2
|
126 |
+
*/
|
127 |
+
function edd_register_customers_batch_export() {
|
128 |
+
add_action( 'edd_batch_export_class_include', 'edd_include_customers_batch_processer', 10, 1 );
|
129 |
+
}
|
130 |
+
add_action( 'edd_register_batch_exporter', 'edd_register_customers_batch_export', 10 );
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Loads the customers batch process if needed
|
134 |
+
*
|
135 |
+
* @since 2.4.2
|
136 |
+
* @param string $class The class being requested to run for the batch export
|
137 |
+
* @return void
|
138 |
+
*/
|
139 |
+
function edd_include_customers_batch_processer( $class ) {
|
140 |
+
|
141 |
+
if ( 'EDD_Batch_Customers_Export' === $class ) {
|
142 |
+
require_once EDD_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-customers.php';
|
143 |
+
}
|
144 |
+
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Register the file downloads batch exporter
|
149 |
+
* @since 2.4.2
|
150 |
+
*/
|
151 |
+
function edd_register_file_downloads_batch_export() {
|
152 |
+
add_action( 'edd_batch_export_class_include', 'edd_include_file_downloads_batch_processer', 10, 1 );
|
153 |
+
}
|
154 |
+
add_action( 'edd_register_batch_exporter', 'edd_register_file_downloads_batch_export', 10 );
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Loads the file downloads batch process if needed
|
158 |
+
*
|
159 |
+
* @since 2.4.2
|
160 |
+
* @param string $class The class being requested to run for the batch export
|
161 |
+
* @return void
|
162 |
+
*/
|
163 |
+
function edd_include_file_downloads_batch_processer( $class ) {
|
164 |
+
|
165 |
+
if ( 'EDD_Batch_File_Downloads_Export' === $class ) {
|
166 |
+
require_once EDD_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-file-downloads.php';
|
167 |
+
}
|
168 |
+
|
169 |
+
}
|
includes/admin/reporting/export/export-functions.php
CHANGED
@@ -14,6 +14,7 @@
|
|
14 |
if ( ! defined( 'ABSPATH' ) ) exit;
|
15 |
|
16 |
require_once EDD_PLUGIN_DIR . 'includes/admin/reporting/class-export.php';
|
|
|
17 |
|
18 |
/**
|
19 |
* Process batch exports via ajax
|
@@ -24,18 +25,18 @@ require_once EDD_PLUGIN_DIR . 'includes/admin/reporting/class-export.php';
|
|
24 |
function edd_do_ajax_export() {
|
25 |
|
26 |
require_once EDD_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export.php';
|
27 |
-
require_once EDD_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-payments.php';
|
28 |
-
require_once EDD_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-customers.php';
|
29 |
-
require_once EDD_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-file-downloads.php';
|
30 |
|
31 |
parse_str( $_POST['form'], $form );
|
32 |
|
33 |
$_REQUEST = $form = (array) $form;
|
34 |
|
|
|
35 |
if( ! wp_verify_nonce( $_REQUEST['edd_ajax_export'], 'edd_ajax_export' ) ) {
|
36 |
die( '-2' );
|
37 |
}
|
38 |
-
|
|
|
|
|
39 |
$step = absint( $_POST['step'] );
|
40 |
$class = $form['edd-export-class'];
|
41 |
$export = new $class( $step );
|
@@ -44,11 +45,7 @@ function edd_do_ajax_export() {
|
|
44 |
die( '-1' );
|
45 |
}
|
46 |
|
47 |
-
$export->
|
48 |
-
$export->end = isset( $_REQUEST['end'] ) ? sanitize_text_field( $_REQUEST['end'] ) : '';
|
49 |
-
$export->status = isset( $_REQUEST['status'] ) ? sanitize_text_field( $_REQUEST['status'] ) : 'complete';
|
50 |
-
$export->download = isset( $_REQUEST['download'] ) ? absint( $_REQUEST['download'] ) : null;
|
51 |
-
$export->price_id = isset( $_REQUEST['edd_price_option'] ) ? absint( $_REQUEST['edd_price_option'] ) : null;
|
52 |
|
53 |
$ret = $export->process_step( $step );
|
54 |
|
@@ -74,77 +71,4 @@ function edd_do_ajax_export() {
|
|
74 |
|
75 |
}
|
76 |
}
|
77 |
-
add_action( 'wp_ajax_edd_do_ajax_export', 'edd_do_ajax_export' );
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Process the download file generated by a batch export
|
81 |
-
*
|
82 |
-
* @since 2.4
|
83 |
-
* @return void
|
84 |
-
*/
|
85 |
-
function edd_process_batch_export_download() {
|
86 |
-
|
87 |
-
if( ! wp_verify_nonce( $_REQUEST['nonce'], 'edd-batch-export' ) ) {
|
88 |
-
wp_die( __( 'Nonce verification failed', 'edd' ), __( 'Error', 'edd' ), array( 'response' => 403 ) );
|
89 |
-
}
|
90 |
-
|
91 |
-
require_once EDD_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export.php';
|
92 |
-
require_once EDD_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-payments.php';
|
93 |
-
require_once EDD_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-customers.php';
|
94 |
-
require_once EDD_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-file-downloads.php';
|
95 |
-
|
96 |
-
$export = new $_REQUEST['class'];
|
97 |
-
$export->export();
|
98 |
-
|
99 |
-
}
|
100 |
-
add_action( 'edd_download_batch_export', 'edd_process_batch_export_download' );
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Exports earnings for a specified time period
|
104 |
-
* EDD_Earnings_Export class.
|
105 |
-
*
|
106 |
-
* @since 2.0
|
107 |
-
* @return void
|
108 |
-
*/
|
109 |
-
function edd_export_earnings() {
|
110 |
-
require_once EDD_PLUGIN_DIR . 'includes/admin/reporting/class-export-earnings.php';
|
111 |
-
|
112 |
-
$earnings_export = new EDD_Earnings_Export();
|
113 |
-
|
114 |
-
$earnings_export->export();
|
115 |
-
}
|
116 |
-
add_action( 'edd_earnings_export', 'edd_export_earnings' );
|
117 |
-
|
118 |
-
|
119 |
-
/**
|
120 |
-
* Export all the customers to a CSV file.
|
121 |
-
*
|
122 |
-
* Note: The WordPress Database API is being used directly for performance
|
123 |
-
* reasons (workaround of calling all posts and fetch data respectively)
|
124 |
-
*
|
125 |
-
* @since 1.4.4
|
126 |
-
* @return void
|
127 |
-
*/
|
128 |
-
function edd_export_all_customers() {
|
129 |
-
require_once EDD_PLUGIN_DIR . 'includes/admin/reporting/class-export-customers.php';
|
130 |
-
|
131 |
-
$customer_export = new EDD_Customers_Export();
|
132 |
-
|
133 |
-
$customer_export->export();
|
134 |
-
}
|
135 |
-
add_action( 'edd_email_export', 'edd_export_all_customers' );
|
136 |
-
|
137 |
-
/**
|
138 |
-
* Exports all the downloads to a CSV file using the EDD_Export class.
|
139 |
-
*
|
140 |
-
* @since 1.4.4
|
141 |
-
* @return void
|
142 |
-
*/
|
143 |
-
function edd_export_all_downloads_history() {
|
144 |
-
require_once EDD_PLUGIN_DIR . 'includes/admin/reporting/class-export-download-history.php';
|
145 |
-
|
146 |
-
$file_download_export = new EDD_Download_History_Export();
|
147 |
-
|
148 |
-
$file_download_export->export();
|
149 |
-
}
|
150 |
-
add_action( 'edd_downloads_history_export', 'edd_export_all_downloads_history' );
|
14 |
if ( ! defined( 'ABSPATH' ) ) exit;
|
15 |
|
16 |
require_once EDD_PLUGIN_DIR . 'includes/admin/reporting/class-export.php';
|
17 |
+
require_once EDD_PLUGIN_DIR . 'includes/admin/reporting/export/export-actions.php';
|
18 |
|
19 |
/**
|
20 |
* Process batch exports via ajax
|
25 |
function edd_do_ajax_export() {
|
26 |
|
27 |
require_once EDD_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export.php';
|
|
|
|
|
|
|
28 |
|
29 |
parse_str( $_POST['form'], $form );
|
30 |
|
31 |
$_REQUEST = $form = (array) $form;
|
32 |
|
33 |
+
|
34 |
if( ! wp_verify_nonce( $_REQUEST['edd_ajax_export'], 'edd_ajax_export' ) ) {
|
35 |
die( '-2' );
|
36 |
}
|
37 |
+
|
38 |
+
do_action( 'edd_batch_export_class_include', $form['edd-export-class'] );
|
39 |
+
|
40 |
$step = absint( $_POST['step'] );
|
41 |
$class = $form['edd-export-class'];
|
42 |
$export = new $class( $step );
|
45 |
die( '-1' );
|
46 |
}
|
47 |
|
48 |
+
$export->set_properties( $_REQUEST );
|
|
|
|
|
|
|
|
|
49 |
|
50 |
$ret = $export->process_step( $step );
|
51 |
|
71 |
|
72 |
}
|
73 |
}
|
74 |
+
add_action( 'wp_ajax_edd_do_ajax_export', 'edd_do_ajax_export' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/admin/settings/register-settings.php
CHANGED
@@ -331,7 +331,10 @@ function edd_get_registered_settings() {
|
|
331 |
'allow_tracking' => array(
|
332 |
'id' => 'allow_tracking',
|
333 |
'name' => __( 'Allow Usage Tracking?', 'edd' ),
|
334 |
-
'desc' =>
|
|
|
|
|
|
|
335 |
'type' => 'checkbox'
|
336 |
),
|
337 |
'uninstall_on_delete' => array(
|
@@ -1556,7 +1559,7 @@ function edd_tax_rates_callback($args) {
|
|
1556 |
'show_option_none' => false,
|
1557 |
'class' => 'edd-select edd-tax-country',
|
1558 |
'chosen' => false,
|
1559 |
-
'placeholder'
|
1560 |
) );
|
1561 |
?>
|
1562 |
</td>
|
@@ -1571,11 +1574,12 @@ function edd_tax_rates_callback($args) {
|
|
1571 |
'show_option_all' => false,
|
1572 |
'show_option_none' => false,
|
1573 |
'chosen' => false,
|
1574 |
-
'placeholder'
|
1575 |
) );
|
1576 |
} else {
|
1577 |
echo EDD()->html->text( array(
|
1578 |
-
'name'
|
|
|
1579 |
) );
|
1580 |
}
|
1581 |
?>
|
@@ -1599,12 +1603,12 @@ function edd_tax_rates_callback($args) {
|
|
1599 |
'show_option_none' => false,
|
1600 |
'class' => 'edd-select edd-tax-country',
|
1601 |
'chosen' => false,
|
1602 |
-
'placeholder'
|
1603 |
) ); ?>
|
1604 |
</td>
|
1605 |
<td class="edd_tax_state">
|
1606 |
<?php echo EDD()->html->text( array(
|
1607 |
-
'name'
|
1608 |
) ); ?>
|
1609 |
</td>
|
1610 |
<td class="edd_tax_global">
|
331 |
'allow_tracking' => array(
|
332 |
'id' => 'allow_tracking',
|
333 |
'name' => __( 'Allow Usage Tracking?', 'edd' ),
|
334 |
+
'desc' => sprintf(
|
335 |
+
__( 'Allow Easy Digital Downloads to anonymously track how this plugin is used and help us make the plugin better. Opt-in to tracking and our newsletter and immediately be emailed a 20%% discount to the EDD shop, valid twoards the <a href="%s" target="_blank">purchase of extensions</a>. No sensitive data is tracked.', 'edd' ),
|
336 |
+
'https://easydigitaldownloads.com/extensions?utm_source=' . substr( md5( get_bloginfo( 'name' ) ), 0, 10 ) . '&utm_medium=admin&utm_term=settings&utm_campaign=EDDUsageTracking'
|
337 |
+
),
|
338 |
'type' => 'checkbox'
|
339 |
),
|
340 |
'uninstall_on_delete' => array(
|
1559 |
'show_option_none' => false,
|
1560 |
'class' => 'edd-select edd-tax-country',
|
1561 |
'chosen' => false,
|
1562 |
+
'placeholder' => __( 'Choose a country', 'edd' )
|
1563 |
) );
|
1564 |
?>
|
1565 |
</td>
|
1574 |
'show_option_all' => false,
|
1575 |
'show_option_none' => false,
|
1576 |
'chosen' => false,
|
1577 |
+
'placeholder' => __( 'Choose a state', 'edd' )
|
1578 |
) );
|
1579 |
} else {
|
1580 |
echo EDD()->html->text( array(
|
1581 |
+
'name' => 'tax_rates[' . $key . '][state]', $rate['state'],
|
1582 |
+
'value' => ! empty( $rate['state'] ) ? $rate['state'] : '',
|
1583 |
) );
|
1584 |
}
|
1585 |
?>
|
1603 |
'show_option_none' => false,
|
1604 |
'class' => 'edd-select edd-tax-country',
|
1605 |
'chosen' => false,
|
1606 |
+
'placeholder' => __( 'Choose a country', 'edd' )
|
1607 |
) ); ?>
|
1608 |
</td>
|
1609 |
<td class="edd_tax_state">
|
1610 |
<?php echo EDD()->html->text( array(
|
1611 |
+
'name' => 'tax_rates[0][state]'
|
1612 |
) ); ?>
|
1613 |
</td>
|
1614 |
<td class="edd_tax_global">
|
includes/admin/tracking.php
CHANGED
@@ -220,16 +220,20 @@ class EDD_Tracking {
|
|
220 |
* @return void
|
221 |
*/
|
222 |
public function admin_notice() {
|
|
|
223 |
$hide_notice = get_option( 'edd_tracking_notice' );
|
224 |
|
225 |
-
if( $hide_notice )
|
226 |
return;
|
|
|
227 |
|
228 |
-
if( edd_get_option( 'allow_tracking', false ) )
|
229 |
return;
|
|
|
230 |
|
231 |
-
if( ! current_user_can( 'manage_options' ) )
|
232 |
return;
|
|
|
233 |
|
234 |
if(
|
235 |
stristr( network_site_url( '/' ), 'dev' ) !== false ||
|
@@ -241,8 +245,10 @@ class EDD_Tracking {
|
|
241 |
$optin_url = add_query_arg( 'edd_action', 'opt_into_tracking' );
|
242 |
$optout_url = add_query_arg( 'edd_action', 'opt_out_of_tracking' );
|
243 |
|
|
|
|
|
244 |
echo '<div class="updated"><p>';
|
245 |
-
echo __( 'Allow Easy Digital Downloads to track plugin usage? Opt-in to tracking and our newsletter and immediately be emailed a 20
|
246 |
echo ' <a href="' . esc_url( $optin_url ) . '" class="button-secondary">' . __( 'Allow', 'edd' ) . '</a>';
|
247 |
echo ' <a href="' . esc_url( $optout_url ) . '" class="button-secondary">' . __( 'Do not allow', 'edd' ) . '</a>';
|
248 |
echo '</p></div>';
|
220 |
* @return void
|
221 |
*/
|
222 |
public function admin_notice() {
|
223 |
+
|
224 |
$hide_notice = get_option( 'edd_tracking_notice' );
|
225 |
|
226 |
+
if( $hide_notice ) {
|
227 |
return;
|
228 |
+
}
|
229 |
|
230 |
+
if( edd_get_option( 'allow_tracking', false ) ) {
|
231 |
return;
|
232 |
+
}
|
233 |
|
234 |
+
if( ! current_user_can( 'manage_options' ) ) {
|
235 |
return;
|
236 |
+
}
|
237 |
|
238 |
if(
|
239 |
stristr( network_site_url( '/' ), 'dev' ) !== false ||
|
245 |
$optin_url = add_query_arg( 'edd_action', 'opt_into_tracking' );
|
246 |
$optout_url = add_query_arg( 'edd_action', 'opt_out_of_tracking' );
|
247 |
|
248 |
+
$source = substr( md5( get_bloginfo( 'name' ) ), 0, 10 );
|
249 |
+
$extensions_url = 'https://easydigitaldownloads.com/extensions?utm_source=' . $source . '&utm_medium=admin&utm_term=notice&utm_campaign=EDDUsageTracking';
|
250 |
echo '<div class="updated"><p>';
|
251 |
+
echo sprintf( __( 'Allow Easy Digital Downloads to track plugin usage? Opt-in to tracking and our newsletter and immediately be emailed a 20%% discount to the EDD shop, valid twoards the <a href="%s" target="_blank">purchase of extensions</a>. No sensitive data is tracked.', 'edd' ), $extensions_url );
|
252 |
echo ' <a href="' . esc_url( $optin_url ) . '" class="button-secondary">' . __( 'Allow', 'edd' ) . '</a>';
|
253 |
echo ' <a href="' . esc_url( $optout_url ) . '" class="button-secondary">' . __( 'Do not allow', 'edd' ) . '</a>';
|
254 |
echo '</p></div>';
|
includes/admin/upgrades/upgrade-functions.php
CHANGED
@@ -212,25 +212,6 @@ function edd_maybe_resume_upgrade() {
|
|
212 |
|
213 |
}
|
214 |
|
215 |
-
/**
|
216 |
-
* Check if the upgrade routine has been run for a specific action
|
217 |
-
*
|
218 |
-
* @since 2.3
|
219 |
-
* @param string $upgrade_action The upgrade action to check completion for
|
220 |
-
* @return bool If the action has been added to the copmleted actions array
|
221 |
-
*/
|
222 |
-
function edd_has_upgrade_completed( $upgrade_action = '' ) {
|
223 |
-
|
224 |
-
if ( empty( $upgrade_action ) ) {
|
225 |
-
return false;
|
226 |
-
}
|
227 |
-
|
228 |
-
$completed_upgrades = edd_get_completed_upgrades();
|
229 |
-
|
230 |
-
return in_array( $upgrade_action, $completed_upgrades );
|
231 |
-
|
232 |
-
}
|
233 |
-
|
234 |
/**
|
235 |
* Adds an upgrade action to the completed upgrades array
|
236 |
*
|
@@ -253,24 +234,6 @@ function edd_set_upgrade_complete( $upgrade_action = '' ) {
|
|
253 |
return update_option( 'edd_completed_upgrades', $completed_upgrades );
|
254 |
}
|
255 |
|
256 |
-
/**
|
257 |
-
* Get's the array of completed upgrade actions
|
258 |
-
*
|
259 |
-
* @since 2.3
|
260 |
-
* @return array The array of completed upgrades
|
261 |
-
*/
|
262 |
-
function edd_get_completed_upgrades() {
|
263 |
-
|
264 |
-
$completed_upgrades = get_option( 'edd_completed_upgrades' );
|
265 |
-
|
266 |
-
if ( false === $completed_upgrades ) {
|
267 |
-
$completed_upgrades = array();
|
268 |
-
}
|
269 |
-
|
270 |
-
return $completed_upgrades;
|
271 |
-
|
272 |
-
}
|
273 |
-
|
274 |
/**
|
275 |
* Converts old sale and file download logs to new logging system
|
276 |
*
|
212 |
|
213 |
}
|
214 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
/**
|
216 |
* Adds an upgrade action to the completed upgrades array
|
217 |
*
|
234 |
return update_option( 'edd_completed_upgrades', $completed_upgrades );
|
235 |
}
|
236 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
237 |
/**
|
238 |
* Converts old sale and file download logs to new logging system
|
239 |
*
|
includes/ajax-functions.php
CHANGED
@@ -671,7 +671,7 @@ function edd_ajax_search_users() {
|
|
671 |
|
672 |
$get_users_args = apply_filters( 'edd_search_users_args', $get_users_args );
|
673 |
|
674 |
-
$found_users = get_users( $get_users_args );
|
675 |
|
676 |
$user_list = '<ul>';
|
677 |
if( $found_users ) {
|
671 |
|
672 |
$get_users_args = apply_filters( 'edd_search_users_args', $get_users_args );
|
673 |
|
674 |
+
$found_users = apply_filters( 'edd_ajax_found_users', get_users( $get_users_args ), $search_query );
|
675 |
|
676 |
$user_list = '<ul>';
|
677 |
if( $found_users ) {
|
includes/api/class-edd-api.php
CHANGED
@@ -1016,6 +1016,7 @@ class EDD_API {
|
|
1016 |
$product['info']['status'] = $product_info->post_status;
|
1017 |
$product['info']['link'] = html_entity_decode( $product_info->guid );
|
1018 |
$product['info']['content'] = $product_info->post_content;
|
|
|
1019 |
$product['info']['thumbnail'] = wp_get_attachment_url( get_post_thumbnail_id( $product_info->ID ) );
|
1020 |
$product['info']['category'] = get_the_terms( $product_info, 'download_category' );
|
1021 |
$product['info']['tags'] = get_the_terms( $product_info, 'download_tag' );
|
1016 |
$product['info']['status'] = $product_info->post_status;
|
1017 |
$product['info']['link'] = html_entity_decode( $product_info->guid );
|
1018 |
$product['info']['content'] = $product_info->post_content;
|
1019 |
+
$product['info']['excerpt'] = $product_info->post_excerpt;
|
1020 |
$product['info']['thumbnail'] = wp_get_attachment_url( get_post_thumbnail_id( $product_info->ID ) );
|
1021 |
$product['info']['category'] = get_the_terms( $product_info, 'download_category' );
|
1022 |
$product['info']['tags'] = get_the_terms( $product_info, 'download_tag' );
|
includes/cart/actions.php
CHANGED
@@ -87,7 +87,7 @@ add_action( 'edd_add_to_cart', 'edd_process_add_to_cart' );
|
|
87 |
function edd_process_remove_from_cart( $data ) {
|
88 |
$cart_key = absint( $_GET['cart_item'] );
|
89 |
edd_remove_from_cart( $cart_key );
|
90 |
-
wp_redirect( remove_query_arg( array( 'edd_action', 'cart_item' ) ) ); edd_die();
|
91 |
}
|
92 |
add_action( 'edd_remove', 'edd_process_remove_from_cart' );
|
93 |
|
@@ -101,7 +101,7 @@ add_action( 'edd_remove', 'edd_process_remove_from_cart' );
|
|
101 |
function edd_process_remove_fee_from_cart( $data ) {
|
102 |
$fee = sanitize_text_field( $data['fee'] );
|
103 |
EDD()->fees->remove_fee( $fee );
|
104 |
-
wp_redirect( remove_query_arg( array( 'edd_action', 'fee' ) ) ); edd_die();
|
105 |
}
|
106 |
add_action( 'edd_remove_fee', 'edd_process_remove_fee_from_cart' );
|
107 |
|
87 |
function edd_process_remove_from_cart( $data ) {
|
88 |
$cart_key = absint( $_GET['cart_item'] );
|
89 |
edd_remove_from_cart( $cart_key );
|
90 |
+
wp_redirect( remove_query_arg( array( 'edd_action', 'cart_item', 'nocache' ) ) ); edd_die();
|
91 |
}
|
92 |
add_action( 'edd_remove', 'edd_process_remove_from_cart' );
|
93 |
|
101 |
function edd_process_remove_fee_from_cart( $data ) {
|
102 |
$fee = sanitize_text_field( $data['fee'] );
|
103 |
EDD()->fees->remove_fee( $fee );
|
104 |
+
wp_redirect( remove_query_arg( array( 'edd_action', 'fee', 'nocache' ) ) ); edd_die();
|
105 |
}
|
106 |
add_action( 'edd_remove_fee', 'edd_process_remove_fee_from_cart' );
|
107 |
|
includes/cart/functions.php
CHANGED
@@ -852,16 +852,13 @@ function edd_remove_item_url( $cart_key ) {
|
|
852 |
|
853 |
global $wp_query;
|
854 |
|
855 |
-
if ( defined('DOING_AJAX') ){
|
856 |
$current_page = edd_get_checkout_uri();
|
857 |
-
} else if( is_page() ) {
|
858 |
-
$current_page = add_query_arg( 'page_id', $wp_query->queried_object_id, home_url( 'index.php' ) );
|
859 |
-
} else if( is_singular() ) {
|
860 |
-
$current_page = add_query_arg( 'p', $wp_query->queried_object_id, home_url( 'index.php' ) );
|
861 |
} else {
|
862 |
$current_page = edd_get_current_page_url();
|
863 |
}
|
864 |
-
|
|
|
865 |
|
866 |
return apply_filters( 'edd_remove_item_url', $remove_url );
|
867 |
}
|
@@ -877,16 +874,13 @@ function edd_remove_item_url( $cart_key ) {
|
|
877 |
function edd_remove_cart_fee_url( $fee_id = '') {
|
878 |
global $post;
|
879 |
|
880 |
-
if ( defined('DOING_AJAX') ){
|
881 |
$current_page = edd_get_checkout_uri();
|
882 |
-
} else if( is_page() ) {
|
883 |
-
$current_page = add_query_arg( 'page_id', $post->ID, home_url( 'index.php' ) );
|
884 |
-
} else if( is_singular() ) {
|
885 |
-
$current_page = add_query_arg( 'p', $post->ID, home_url( 'index.php' ) );
|
886 |
} else {
|
887 |
$current_page = edd_get_current_page_url();
|
888 |
}
|
889 |
-
|
|
|
890 |
|
891 |
return apply_filters( 'edd_remove_fee_url', $remove_url );
|
892 |
}
|
852 |
|
853 |
global $wp_query;
|
854 |
|
855 |
+
if ( defined('DOING_AJAX') ) {
|
856 |
$current_page = edd_get_checkout_uri();
|
|
|
|
|
|
|
|
|
857 |
} else {
|
858 |
$current_page = edd_get_current_page_url();
|
859 |
}
|
860 |
+
|
861 |
+
$remove_url = add_query_arg( array( 'cart_item' => $cart_key, 'edd_action' => 'remove', 'nocache' => current_time( 'timestamp' ) ), $current_page );
|
862 |
|
863 |
return apply_filters( 'edd_remove_item_url', $remove_url );
|
864 |
}
|
874 |
function edd_remove_cart_fee_url( $fee_id = '') {
|
875 |
global $post;
|
876 |
|
877 |
+
if ( defined('DOING_AJAX') ) {
|
878 |
$current_page = edd_get_checkout_uri();
|
|
|
|
|
|
|
|
|
879 |
} else {
|
880 |
$current_page = edd_get_current_page_url();
|
881 |
}
|
882 |
+
|
883 |
+
$remove_url = add_query_arg( array( 'fee' => $fee_id, 'edd_action' => 'remove_fee', 'nocache' => current_time( 'timestamp' ) ), $current_page );
|
884 |
|
885 |
return apply_filters( 'edd_remove_fee_url', $remove_url );
|
886 |
}
|
includes/checkout/functions.php
CHANGED
@@ -229,7 +229,8 @@ function edd_listen_for_failed_payments() {
|
|
229 |
if( ! empty( $failed_page ) && is_page( $failed_page ) && ! empty( $_GET['payment-id'] ) ) {
|
230 |
|
231 |
$payment_id = absint( $_GET['payment-id'] );
|
232 |
-
$
|
|
|
233 |
|
234 |
if( $status && 'pending' === strtolower( $status ) ) {
|
235 |
|
229 |
if( ! empty( $failed_page ) && is_page( $failed_page ) && ! empty( $_GET['payment-id'] ) ) {
|
230 |
|
231 |
$payment_id = absint( $_GET['payment-id'] );
|
232 |
+
$payment = get_post( $payment_id );
|
233 |
+
$status = edd_get_payment_status( $payment );
|
234 |
|
235 |
if( $status && 'pending' === strtolower( $status ) ) {
|
236 |
|
includes/checkout/template.php
CHANGED
@@ -897,7 +897,7 @@ function edd_filter_success_page_content( $content ) {
|
|
897 |
|
898 |
return $content;
|
899 |
}
|
900 |
-
add_filter( 'the_content', 'edd_filter_success_page_content' );
|
901 |
|
902 |
/**
|
903 |
* Show a download's files in the purchase receipt
|
897 |
|
898 |
return $content;
|
899 |
}
|
900 |
+
add_filter( 'the_content', 'edd_filter_success_page_content', 99999 );
|
901 |
|
902 |
/**
|
903 |
* Show a download's files in the purchase receipt
|
includes/class-edd-db-customers.php
CHANGED
@@ -424,18 +424,20 @@ class EDD_DB_Customers extends EDD_DB {
|
|
424 |
if( ! empty( $args['email'] ) ) {
|
425 |
|
426 |
if( is_array( $args['email'] ) ) {
|
427 |
-
$emails = "'" . implode( "', '", $args['email'] ) . "'";
|
428 |
-
} else {
|
429 |
-
$emails = "'" . $args['email'] . "'";
|
430 |
-
}
|
431 |
|
432 |
-
|
|
|
|
|
433 |
|
|
|
|
|
|
|
|
|
434 |
}
|
435 |
|
436 |
// specific customers by name
|
437 |
if( ! empty( $args['name'] ) ) {
|
438 |
-
$where .= $wpdb->prepare( " AND `name` LIKE '
|
439 |
}
|
440 |
|
441 |
// Customers created for a specific date or in a date range
|
424 |
if( ! empty( $args['email'] ) ) {
|
425 |
|
426 |
if( is_array( $args['email'] ) ) {
|
|
|
|
|
|
|
|
|
427 |
|
428 |
+
$emails_count = count( $args['email'] );
|
429 |
+
$emails_placeholder = array_fill( 0, $emails_count, '%s' );
|
430 |
+
$emails = implode( ', ', $emails_placeholder );
|
431 |
|
432 |
+
$where .= $wpdb->prepare( " AND `email` IN( $emails ) ", $args['email'] );
|
433 |
+
} else {
|
434 |
+
$where .= $wpdb->prepare( " AND `email` = %s ", $args['email'] );
|
435 |
+
}
|
436 |
}
|
437 |
|
438 |
// specific customers by name
|
439 |
if( ! empty( $args['name'] ) ) {
|
440 |
+
$where .= $wpdb->prepare( " AND `name` LIKE '%%%%" . '%s' . "%%%%' ", $args['name'] );
|
441 |
}
|
442 |
|
443 |
// Customers created for a specific date or in a date range
|
includes/gateways/libs/amazon/Client.php
CHANGED
@@ -1,6 +1,9 @@
|
|
1 |
<?php
|
2 |
namespace PayWithAmazon;
|
3 |
|
|
|
|
|
|
|
4 |
/* Class Client
|
5 |
* Takes configuration information
|
6 |
* Makes API calls to MWS for Pay With Amazon
|
@@ -13,1567 +16,1567 @@ require_once 'Interface.php';
|
|
13 |
|
14 |
class Client implements ClientInterface
|
15 |
{
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
'us' => 'https://api.amazon.com',
|
56 |
'de' => 'https://api.amazon.de',
|
57 |
'jp' => 'https://api.amazon.co.jp');
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
|
70 |
-
|
71 |
-
|
72 |
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
$configArray = $this->checkIfFileExists($config);
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
|
|
95 |
}
|
96 |
-
}
|
97 |
|
98 |
-
|
99 |
|
100 |
-
|
101 |
-
|
102 |
if(file_exists($config))
|
103 |
{
|
104 |
-
|
105 |
-
|
106 |
|
107 |
-
|
108 |
|
109 |
-
|
110 |
$errorMsg = "Error with message - content is not in json format" . $this->getErrorMessageForJsonError($jsonError) . " " . $configArray;
|
111 |
throw new \Exception($errorMsg);
|
112 |
-
|
113 |
} else {
|
114 |
-
|
115 |
-
|
116 |
}
|
117 |
return $configArray;
|
118 |
-
|
119 |
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
$config = $this->trimArray($config);
|
129 |
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
check the config array key names to match your key names of your config array', 1);
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
$proxy = $this->trimArray($proxy);
|
205 |
-
|
206 |
-
if (!empty($proxy['proxy_user_host']))
|
207 |
-
$this->config['proxy_user_host'] = $proxy['proxy_user_host'];
|
208 |
|
209 |
-
|
210 |
-
|
|
|
|
|
|
|
211 |
|
212 |
-
|
213 |
-
|
214 |
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
|
223 |
-
|
224 |
-
|
225 |
$this->mwsServiceUrl = $url;
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
return trim($this->parameters);
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
foreach ($array as $key => $value)
|
255 |
{
|
256 |
-
|
257 |
}
|
258 |
return $array;
|
259 |
-
|
260 |
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
|
280 |
-
|
281 |
|
282 |
-
|
283 |
-
|
284 |
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
|
307 |
-
|
308 |
-
|
309 |
/* For loop to take all the non empty parameters in the $requestParameters and add it into the $parameters array,
|
310 |
* if the keys are matched from $requestParameters array with the $fieldMappings array
|
311 |
*/
|
312 |
-
|
313 |
|
314 |
-
|
315 |
$value = trim($value);
|
316 |
-
|
317 |
|
318 |
-
|
319 |
|
320 |
if(is_array($value)) {
|
321 |
-
|
322 |
-
|
323 |
$parameters = $this->setProviderCreditDetails($parameters,$value);
|
324 |
-
|
325 |
$parameters = $this->setProviderCreditReversalDetails($parameters,$value);
|
326 |
-
|
327 |
|
328 |
} else{
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
$value = strtolower($value);
|
333 |
-
|
334 |
|
335 |
-
|
|
|
|
|
336 |
}
|
337 |
-
}
|
338 |
-
}
|
339 |
|
340 |
-
|
341 |
$responseObject = $this->calculateSignatureAndPost($parameters);
|
342 |
|
343 |
return $responseObject;
|
344 |
-
|
345 |
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
$string = strtolower($string);
|
351 |
return in_array($string, array('true', 'false'));
|
352 |
-
|
353 |
|
354 |
-
|
355 |
|
356 |
-
|
357 |
-
|
358 |
// Call the signature and Post function to perform the actions. Returns XML in array format
|
359 |
-
|
360 |
|
361 |
// POST using curl the String converted Parameters
|
362 |
$response = $this->invokePost($parametersString);
|
363 |
|
364 |
// Send this response as args to ResponseParser class which will return the object of the class.
|
365 |
-
|
366 |
-
|
367 |
-
}
|
368 |
-
|
369 |
-
/* If merchant_id is not set via the requestParameters array then it's taken from the config array
|
370 |
-
*
|
371 |
-
* Set the platform_id if set in the config['platform_id'] array
|
372 |
-
*
|
373 |
-
* If currency_code is set in the $requestParameters and it exists in the $fieldMappings array, strtoupper it
|
374 |
-
* else take the value from config array if set
|
375 |
-
*/
|
376 |
-
|
377 |
-
private function setDefaultValues($parameters, $fieldMappings, $requestParameters)
|
378 |
-
{
|
379 |
-
if (empty($requestParameters['merchant_id']))
|
380 |
-
$parameters['SellerId'] = $this->config['merchant_id'];
|
381 |
-
|
382 |
-
if (array_key_exists('platform_id', $fieldMappings)) {
|
383 |
-
if (empty($requestParameters['platform_id']) && !empty($this->config['platform_id']))
|
384 |
-
$parameters[$fieldMappings['platform_id']] = $this->config['platform_id'];
|
385 |
}
|
386 |
|
387 |
-
|
388 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
389 |
$parameters[$fieldMappings['currency_code']] = strtoupper($requestParameters['currency_code']);
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
$providerIndex = 0;
|
407 |
$providerString = 'ProviderCreditList.member.';
|
408 |
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
|
415 |
foreach ($providerCreditInfo as $key => $value)
|
416 |
{
|
417 |
-
|
418 |
-
|
419 |
|
420 |
-
|
421 |
-
|
422 |
if (array_key_exists($param, $fieldMappings) && trim($val)!='') {
|
423 |
-
|
|
|
424 |
}
|
425 |
-
}
|
426 |
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
$parameters[$providerString.$providerIndex. '.' .$fieldMappings['currency_code']] = strtoupper($this->config['currency_code']);
|
431 |
-
|
432 |
}
|
433 |
|
434 |
return $parameters;
|
435 |
-
|
436 |
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
|
443 |
-
|
444 |
-
|
445 |
$providerIndex = 0;
|
446 |
$providerString = 'ProviderCreditReversalList.member.';
|
447 |
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
|
454 |
foreach ($providerCreditInfo as $key => $value)
|
455 |
{
|
456 |
-
|
457 |
-
|
458 |
|
459 |
-
|
460 |
-
|
461 |
if (array_key_exists($param, $fieldMappings) && trim($val)!='') {
|
462 |
-
|
|
|
463 |
}
|
464 |
-
}
|
465 |
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
$parameters[$providerString.$providerIndex. '.' .$fieldMappings['currency_code']] = strtoupper($this->config['currency_code']);
|
470 |
-
|
471 |
}
|
472 |
|
473 |
return $parameters;
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
|
538 |
return ($responseObject);
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
|
590 |
return ($responseObject);
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
|
748 |
return ($responseObject);
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
|
862 |
return ($responseObject);
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
|
931 |
return ($responseObject);
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
|
1069 |
return ($responseObject);
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
|
1124 |
$requestParameters = array_change_key_case($requestParameters, CASE_LOWER);
|
1125 |
$requestParameters= $this->trimArray($requestParameters);
|
1126 |
|
1127 |
$setParameters = $authorizeParameters = $confirmParameters = $requestParameters;
|
1128 |
|
1129 |
-
|
1130 |
-
|
1131 |
if (!empty($requestParameters['amazon_order_reference_id']))
|
1132 |
{
|
1133 |
-
|
1134 |
-
|
1135 |
} elseif(!empty($requestParameters['amazon_billing_agreement_id'])) {
|
1136 |
-
|
1137 |
-
|
1138 |
} elseif (!empty($requestParameters['amazon_reference_id'])) {
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
|
1161 |
// Set the other parameters if the values are present
|
1162 |
-
|
1163 |
-
|
1164 |
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
|
1173 |
-
|
1174 |
|
1175 |
$response = $this->makeChargeCalls($chargeType, $setParameters, $confirmParameters, $authorizeParameters);
|
1176 |
return $response;
|
1177 |
-
|
1178 |
|
1179 |
-
|
1180 |
|
1181 |
-
|
1182 |
-
|
1183 |
switch ($chargeType) {
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
$parameters = array();
|
1225 |
-
|
1226 |
-
|
1227 |
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
|
1234 |
-
|
1235 |
|
1236 |
-
|
1237 |
-
|
1238 |
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
|
1246 |
-
|
1247 |
-
|
1248 |
$parameters = array();
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
$parameters = array();
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
|
1319 |
// Save these parameters in the parameters variable so that it can be returned for unit testing.
|
1320 |
$this->parameters = $parameters;
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
|
1437 |
// Submit the request and read response body
|
1438 |
try {
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
|
1445 |
-
|
1446 |
-
|
1447 |
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
|
1458 |
-
|
1459 |
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
|
1465 |
$shouldRetry = true;
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
1473 |
-
|
1474 |
-
|
1475 |
-
|
1476 |
-
|
1477 |
-
|
1478 |
-
|
1479 |
-
|
1480 |
-
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
|
1502 |
-
|
1503 |
-
|
1504 |
-
|
1505 |
-
|
1506 |
-
|
1507 |
-
|
1508 |
-
|
1509 |
-
|
1510 |
-
|
1511 |
-
|
1512 |
-
|
1513 |
-
|
1514 |
-
|
1515 |
-
|
1516 |
-
|
1517 |
-
|
1518 |
-
|
1519 |
-
|
1520 |
-
|
1521 |
-
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
|
1526 |
-
|
1527 |
-
|
1528 |
$this->profileEndpoint = $this->liveProfileEndpoint[$region];
|
1529 |
-
|
1530 |
throw new \Exception($region . ' is not a valid region');
|
1531 |
-
|
1532 |
} else {
|
1533 |
-
|
1534 |
-
|
1535 |
-
|
1536 |
-
|
1537 |
-
|
1538 |
-
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
|
1548 |
-
|
1549 |
-
|
1550 |
-
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
|
1559 |
-
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
1578 |
-
|
1579 |
}
|
1 |
<?php
|
2 |
namespace PayWithAmazon;
|
3 |
|
4 |
+
// Exit if accessed directly
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
/* Class Client
|
8 |
* Takes configuration information
|
9 |
* Makes API calls to MWS for Pay With Amazon
|
16 |
|
17 |
class Client implements ClientInterface
|
18 |
{
|
19 |
+
const MWS_CLIENT_VERSION = '1.0.0';
|
20 |
+
const SERVICE_VERSION = '2013-01-01';
|
21 |
+
const MAX_ERROR_RETRY = 3;
|
22 |
+
|
23 |
+
// Construct User agent string based off of the application_name, application_version, PHP platform
|
24 |
+
private $userAgent = null;
|
25 |
+
private $parameters = null;
|
26 |
+
private $mwsEndpointPath = null;
|
27 |
+
private $mwsEndpointUrl = null;
|
28 |
+
private $profileEndpoint = null;
|
29 |
+
private $config = array('merchant_id' => null,
|
30 |
+
'secret_key' => null,
|
31 |
+
'access_key' => null,
|
32 |
+
'region' => null,
|
33 |
+
'currency_code' => null,
|
34 |
+
'sandbox' => false,
|
35 |
+
'platform_id' => null,
|
36 |
+
'cabundle_file' => null,
|
37 |
+
'application_name' => null,
|
38 |
+
'application_version' => null,
|
39 |
+
'proxy_host' => null,
|
40 |
+
'proxy_port' => -1,
|
41 |
+
'proxy_username' => null,
|
42 |
+
'proxy_password' => null,
|
43 |
+
'client_id' => null,
|
44 |
+
'handle_throttle' => true
|
45 |
+
);
|
46 |
+
|
47 |
+
private $modePath = null;
|
48 |
+
|
49 |
+
// Final URL to where the API parameters POST done, based off the config['region'] and respective $mwsServiceUrls
|
50 |
+
private $mwsServiceUrl = null;
|
51 |
+
|
52 |
+
private $mwsServiceUrls = array('eu' => 'mws-eu.amazonservices.com',
|
53 |
+
'na' => 'mws.amazonservices.com',
|
54 |
+
'jp' => 'mws.amazonservices.jp');
|
55 |
+
|
56 |
+
// Production profile end points to get the user information
|
57 |
+
private $liveProfileEndpoint = array('uk' => 'https://api.amazon.co.uk',
|
58 |
'us' => 'https://api.amazon.com',
|
59 |
'de' => 'https://api.amazon.de',
|
60 |
'jp' => 'https://api.amazon.co.jp');
|
61 |
|
62 |
+
// Sandbox profile end points to get the user information
|
63 |
+
private $sandboxProfileEndpoint = array('uk' => 'https://api.sandbox.amazon.co.uk',
|
64 |
+
'us' => 'https://api.sandbox.amazon.com',
|
65 |
+
'de' => 'https://api.sandbox.amazon.de',
|
66 |
+
'jp' => 'https://api.sandbox.amazon.co.jp');
|
67 |
|
68 |
+
private $regionMappings = array('de' => 'eu',
|
69 |
+
'uk' => 'eu',
|
70 |
+
'us' => 'na',
|
71 |
+
'jp' => 'jp');
|
72 |
|
73 |
+
// Boolean variable to check if the API call was a success
|
74 |
+
public $success = false;
|
75 |
|
76 |
+
/* Takes user configuration array from the user as input
|
77 |
+
* Takes JSON file path with configuration information as input
|
78 |
+
* Validates the user configuration array against existing config array
|
79 |
+
*/
|
80 |
|
81 |
+
public function __construct($config = null)
|
82 |
+
{
|
83 |
+
if (!is_null($config)) {
|
84 |
|
85 |
+
if (is_array($config)) {
|
86 |
+
$configArray = $config;
|
87 |
+
} elseif (!is_array($config)) {
|
88 |
$configArray = $this->checkIfFileExists($config);
|
89 |
+
}
|
90 |
+
|
91 |
+
if (is_array($configArray)) {
|
92 |
+
$this->checkConfigKeys($configArray);
|
93 |
+
} else {
|
94 |
+
throw new \Exception('$config is of the incorrect type ' . gettype($configArray) . ' and should be of the type array');
|
95 |
+
}
|
96 |
+
} else {
|
97 |
+
throw new \Exception('$config cannot be null.');
|
98 |
+
}
|
99 |
}
|
|
|
100 |
|
101 |
+
/* checkIfFileExists - check if the JSON file exists in the path provided */
|
102 |
|
103 |
+
private function checkIfFileExists($config)
|
104 |
+
{
|
105 |
if(file_exists($config))
|
106 |
{
|
107 |
+
$jsonString = file_get_contents($config);
|
108 |
+
$configArray = json_decode($jsonString, true);
|
109 |
|
110 |
+
$jsonError = json_last_error();
|
111 |
|
112 |
+
if ($jsonError != 0) {
|
113 |
$errorMsg = "Error with message - content is not in json format" . $this->getErrorMessageForJsonError($jsonError) . " " . $configArray;
|
114 |
throw new \Exception($errorMsg);
|
115 |
+
}
|
116 |
} else {
|
117 |
+
$errorMsg ='$config is not a Json File path or the Json File was not found in the path provided';
|
118 |
+
throw new \Exception($errorMsg);
|
119 |
}
|
120 |
return $configArray;
|
121 |
+
}
|
122 |
|
123 |
+
/* Checks if the keys of the input configuration matches the keys in the config array
|
124 |
+
* if they match the values are taken else throws exception
|
125 |
+
* strict case match is not performed
|
126 |
+
*/
|
127 |
|
128 |
+
private function checkConfigKeys($config)
|
129 |
+
{
|
130 |
+
$config = array_change_key_case($config, CASE_LOWER);
|
131 |
$config = $this->trimArray($config);
|
132 |
|
133 |
+
foreach ($config as $key => $value) {
|
134 |
+
if (array_key_exists($key, $this->config)) {
|
135 |
+
$this->config[$key] = $value;
|
136 |
+
} else {
|
137 |
+
throw new \Exception('Key ' . $key . ' is either not part of the configuration or has incorrect Key name.
|
138 |
check the config array key names to match your key names of your config array', 1);
|
139 |
+
}
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
/* Convert a json error code to a descriptive error message
|
144 |
+
*
|
145 |
+
* @param int $jsonError message code
|
146 |
+
*
|
147 |
+
* @return string error message
|
148 |
+
*/
|
149 |
+
|
150 |
+
private function getErrorMessageForJsonError($jsonError)
|
151 |
+
{
|
152 |
+
switch ($jsonError) {
|
153 |
+
case JSON_ERROR_DEPTH:
|
154 |
+
return " - maximum stack depth exceeded.";
|
155 |
+
break;
|
156 |
+
case JSON_ERROR_STATE_MISMATCH:
|
157 |
+
return " - invalid or malformed JSON.";
|
158 |
+
break;
|
159 |
+
case JSON_ERROR_CTRL_CHAR:
|
160 |
+
return " - control character error.";
|
161 |
+
break;
|
162 |
+
case JSON_ERROR_SYNTAX:
|
163 |
+
return " - syntax error.";
|
164 |
+
break;
|
165 |
+
default:
|
166 |
+
return ".";
|
167 |
+
break;
|
168 |
+
}
|
169 |
+
}
|
170 |
+
|
171 |
+
/* Setter for sandbox
|
172 |
+
* Sets the Boolean value for config['sandbox'] variable
|
173 |
+
*/
|
174 |
+
|
175 |
+
public function setSandbox($value)
|
176 |
+
{
|
177 |
+
if (is_bool($value)) {
|
178 |
+
$this->config['sandbox'] = $value;
|
179 |
+
} else {
|
180 |
+
throw new \Exception($value . ' is of type ' . gettype($value) . ' and should be a boolean value');
|
181 |
+
}
|
182 |
+
}
|
183 |
+
|
184 |
+
/* Setter for config['client_id']
|
185 |
+
* Sets the value for config['client_id'] variable
|
186 |
+
*/
|
187 |
+
|
188 |
+
public function setClientId($value)
|
189 |
+
{
|
190 |
+
if (!empty($value)) {
|
191 |
+
$this->config['client_id'] = $value;
|
192 |
+
} else {
|
193 |
+
throw new \Exception('setter value for client ID provided is empty');
|
194 |
+
}
|
195 |
+
}
|
196 |
+
|
197 |
+
/* Setter for Proxy
|
198 |
+
* input $proxy [array]
|
199 |
+
* @param $proxy['proxy_user_host'] - hostname for the proxy
|
200 |
+
* @param $proxy['proxy_user_port'] - hostname for the proxy
|
201 |
+
* @param $proxy['proxy_user_name'] - if your proxy required a username
|
202 |
+
* @param $proxy['proxy_user_password'] - if your proxy required a password
|
203 |
+
*/
|
204 |
+
|
205 |
+
public function setProxy($proxy)
|
206 |
+
{
|
207 |
$proxy = $this->trimArray($proxy);
|
|
|
|
|
|
|
208 |
|
209 |
+
if (!empty($proxy['proxy_user_host']))
|
210 |
+
$this->config['proxy_user_host'] = $proxy['proxy_user_host'];
|
211 |
+
|
212 |
+
if (!empty($proxy['proxy_user_port']))
|
213 |
+
$this->config['proxy_user_port'] = $proxy['proxy_user_port'];
|
214 |
|
215 |
+
if (!empty($proxy['proxy_user_name']))
|
216 |
+
$this->config['proxy_user_name'] = $proxy['proxy_user_name'];
|
217 |
|
218 |
+
if (!empty($proxy['proxy_user_password']))
|
219 |
+
$this->config['proxy_user_password'] = $proxy['proxy_user_password'];
|
220 |
+
}
|
221 |
|
222 |
+
/* Setter for $mwsServiceUrl
|
223 |
+
* Set the URL to which the post request has to be made for unit testing
|
224 |
+
*/
|
225 |
|
226 |
+
public function setMwsServiceUrl($url)
|
227 |
+
{
|
228 |
$this->mwsServiceUrl = $url;
|
229 |
+
}
|
230 |
+
|
231 |
+
/* Getter
|
232 |
+
* Gets the value for the key if the key exists in config
|
233 |
+
*/
|
234 |
+
|
235 |
+
public function __get($name)
|
236 |
+
{
|
237 |
+
if (array_key_exists(strtolower($name), $this->config)) {
|
238 |
+
return $this->config[strtolower($name)];
|
239 |
+
} else {
|
240 |
+
throw new \Exception('Key ' . $name . ' is either not a part of the configuration array config or the' . $name . 'does not match the key name in the config array', 1);
|
241 |
+
}
|
242 |
+
}
|
243 |
+
|
244 |
+
/* Getter for parameters string
|
245 |
+
* Gets the value for the parameters string for unit testing
|
246 |
+
*/
|
247 |
+
|
248 |
+
public function getParameters()
|
249 |
+
{
|
250 |
return trim($this->parameters);
|
251 |
+
}
|
252 |
+
|
253 |
+
/* Trim the input Array key values */
|
254 |
+
|
255 |
+
private function trimArray($array)
|
256 |
+
{
|
257 |
foreach ($array as $key => $value)
|
258 |
{
|
259 |
+
$array[$key] = trim($value);
|
260 |
}
|
261 |
return $array;
|
262 |
+
}
|
263 |
|
264 |
+
/* GetUserInfo convenience function - Returns user's profile information from Amazon using the access token returned by the Button widget.
|
265 |
+
*
|
266 |
+
* @see http://login.amazon.com/website Step 4
|
267 |
+
* @param $accessToken [String]
|
268 |
+
*/
|
269 |
|
270 |
+
public function getUserInfo($accessToken)
|
271 |
+
{
|
272 |
+
// Get the correct Profile Endpoint URL based off the country/region provided in the config['region']
|
273 |
+
$this->profileEndpointUrl();
|
274 |
|
275 |
+
if (empty($accessToken)) {
|
276 |
+
throw new \InvalidArgumentException('Access Token is a required parameter and is not set');
|
277 |
+
}
|
278 |
|
279 |
+
// To make sure double encoding doesn't occur decode first and encode again.
|
280 |
+
$accessToken = urldecode($accessToken);
|
281 |
+
$url = $this->profileEndpoint . '/auth/o2/tokeninfo?access_token=' . urlEncode($accessToken);
|
282 |
|
283 |
+
$httpCurlRequest = new HttpCurl();
|
284 |
|
285 |
+
$response = $httpCurlRequest->httpGet($url);
|
286 |
+
$data = json_decode($response);
|
287 |
|
288 |
+
if ($data->aud != $this->config['client_id']) {
|
289 |
+
// The access token does not belong to us
|
290 |
+
throw new \Exception('The Access token entered is incorrect');
|
291 |
+
}
|
292 |
|
293 |
+
// Exchange the access token for user profile
|
294 |
+
$url = $this->profileEndpoint . '/user/profile';
|
295 |
+
$httpCurlRequest = new HttpCurl();
|
296 |
|
297 |
+
$httpCurlRequest->setAccessToken($accessToken);
|
298 |
+
$httpCurlRequest->setHttpHeader(true);
|
299 |
+
$response = $httpCurlRequest->httpGet($url);
|
300 |
|
301 |
+
$userInfo = json_decode($response, true);
|
302 |
+
return $userInfo;
|
303 |
+
}
|
304 |
|
305 |
+
/* setParametersAndPost - sets the parameters array with non empty values from the requestParameters array sent to API calls.
|
306 |
+
* If Provider Credit Details is present, values are set by setProviderCreditDetails
|
307 |
+
* If Provider Credit Reversal Details is present, values are set by setProviderCreditDetails
|
308 |
+
*/
|
309 |
|
310 |
+
private function setParametersAndPost($parameters, $fieldMappings, $requestParameters)
|
311 |
+
{
|
312 |
/* For loop to take all the non empty parameters in the $requestParameters and add it into the $parameters array,
|
313 |
* if the keys are matched from $requestParameters array with the $fieldMappings array
|
314 |
*/
|
315 |
+
foreach ($requestParameters as $param => $value) {
|
316 |
|
317 |
+
if(!is_array($value)) {
|
318 |
$value = trim($value);
|
319 |
+
}
|
320 |
|
321 |
+
if (array_key_exists($param, $fieldMappings) && $value!='') {
|
322 |
|
323 |
if(is_array($value)) {
|
324 |
+
// If the parameter is a provider_credit_details or provider_credit_reversal_details, call the respective functions to set the values
|
325 |
+
if($param === 'provider_credit_details') {
|
326 |
$parameters = $this->setProviderCreditDetails($parameters,$value);
|
327 |
+
} elseif ($param === 'provider_credit_reversal_details') {
|
328 |
$parameters = $this->setProviderCreditReversalDetails($parameters,$value);
|
329 |
+
}
|
330 |
|
331 |
} else{
|
332 |
+
// For variables that are boolean values, strtolower them
|
333 |
+
if($this->checkIfBool($value))
|
334 |
+
{
|
335 |
$value = strtolower($value);
|
336 |
+
}
|
337 |
|
338 |
+
$parameters[$fieldMappings[$param]] = $value;
|
339 |
+
}
|
340 |
+
}
|
341 |
}
|
|
|
|
|
342 |
|
343 |
+
$parameters = $this->setDefaultValues($parameters, $fieldMappings, $requestParameters);
|
344 |
$responseObject = $this->calculateSignatureAndPost($parameters);
|
345 |
|
346 |
return $responseObject;
|
347 |
+
}
|
348 |
|
349 |
+
/* checkIfBool - checks if the input is a boolean */
|
350 |
+
|
351 |
+
private function checkIfBool($string)
|
352 |
+
{
|
353 |
$string = strtolower($string);
|
354 |
return in_array($string, array('true', 'false'));
|
355 |
+
}
|
356 |
|
357 |
+
/* calculateSignatureAndPost - convert the Parameters array to string and curl POST the parameters to MWS */
|
358 |
|
359 |
+
private function calculateSignatureAndPost($parameters)
|
360 |
+
{
|
361 |
// Call the signature and Post function to perform the actions. Returns XML in array format
|
362 |
+
$parametersString = $this->calculateSignatureAndParametersToString($parameters);
|
363 |
|
364 |
// POST using curl the String converted Parameters
|
365 |
$response = $this->invokePost($parametersString);
|
366 |
|
367 |
// Send this response as args to ResponseParser class which will return the object of the class.
|
368 |
+
$responseObject = new ResponseParser($response);
|
369 |
+
return $responseObject;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
370 |
}
|
371 |
|
372 |
+
/* If merchant_id is not set via the requestParameters array then it's taken from the config array
|
373 |
+
*
|
374 |
+
* Set the platform_id if set in the config['platform_id'] array
|
375 |
+
*
|
376 |
+
* If currency_code is set in the $requestParameters and it exists in the $fieldMappings array, strtoupper it
|
377 |
+
* else take the value from config array if set
|
378 |
+
*/
|
379 |
+
|
380 |
+
private function setDefaultValues($parameters, $fieldMappings, $requestParameters)
|
381 |
+
{
|
382 |
+
if (empty($requestParameters['merchant_id']))
|
383 |
+
$parameters['SellerId'] = $this->config['merchant_id'];
|
384 |
+
|
385 |
+
if (array_key_exists('platform_id', $fieldMappings)) {
|
386 |
+
if (empty($requestParameters['platform_id']) && !empty($this->config['platform_id']))
|
387 |
+
$parameters[$fieldMappings['platform_id']] = $this->config['platform_id'];
|
388 |
+
}
|
389 |
+
|
390 |
+
if (array_key_exists('currency_code', $fieldMappings)) {
|
391 |
+
if (!empty($requestParameters['currency_code'])) {
|
392 |
$parameters[$fieldMappings['currency_code']] = strtoupper($requestParameters['currency_code']);
|
393 |
+
} else {
|
394 |
+
$parameters[$fieldMappings['currency_code']] = strtoupper($this->config['currency_code']);
|
395 |
+
}
|
396 |
+
}
|
397 |
+
|
398 |
+
return $parameters;
|
399 |
+
}
|
400 |
+
|
401 |
+
/* setProviderCreditDetails - sets the provider credit details sent via the Capture or Authorize API calls
|
402 |
+
* @param provider_id - [String]
|
403 |
+
* @param credit_amount - [String]
|
404 |
+
* @optional currency_code - [String]
|
405 |
+
*/
|
406 |
+
|
407 |
+
private function setProviderCreditDetails($parameters, $providerCreditInfo)
|
408 |
+
{
|
409 |
$providerIndex = 0;
|
410 |
$providerString = 'ProviderCreditList.member.';
|
411 |
|
412 |
+
$fieldMappings = array(
|
413 |
+
'provider_id' => 'ProviderId',
|
414 |
+
'credit_amount' => 'CreditAmount.Amount',
|
415 |
+
'currency_code' => 'CreditAmount.CurrencyCode'
|
416 |
+
);
|
417 |
|
418 |
foreach ($providerCreditInfo as $key => $value)
|
419 |
{
|
420 |
+
$value = array_change_key_case($value, CASE_LOWER);
|
421 |
+
$providerIndex = $providerIndex + 1;
|
422 |
|
423 |
+
foreach ($value as $param => $val)
|
424 |
+
{
|
425 |
if (array_key_exists($param, $fieldMappings) && trim($val)!='') {
|
426 |
+
$parameters[$providerString.$providerIndex. '.' .$fieldMappings[$param]] = $val;
|
427 |
+
}
|
428 |
}
|
|
|
429 |
|
430 |
+
// If currency code is not entered take it from the config array
|
431 |
+
if(empty($parameters[$providerString.$providerIndex. '.' .$fieldMappings['currency_code']]))
|
432 |
+
{
|
433 |
$parameters[$providerString.$providerIndex. '.' .$fieldMappings['currency_code']] = strtoupper($this->config['currency_code']);
|
434 |
+
}
|
435 |
}
|
436 |
|
437 |
return $parameters;
|
438 |
+
}
|
439 |
|
440 |
+
/* setProviderCreditReversalDetails - sets the reverse provider credit details sent via the Refund API call.
|
441 |
+
* @param provider_id - [String]
|
442 |
+
* @param credit_amount - [String]
|
443 |
+
* @optional currency_code - [String]
|
444 |
+
*/
|
445 |
|
446 |
+
private function setProviderCreditReversalDetails($parameters, $providerCreditInfo)
|
447 |
+
{
|
448 |
$providerIndex = 0;
|
449 |
$providerString = 'ProviderCreditReversalList.member.';
|
450 |
|
451 |
+
$fieldMappings = array(
|
452 |
+
'provider_id' => 'ProviderId',
|
453 |
+
'credit_reversal_amount' => 'CreditReversalAmount.Amount',
|
454 |
+
'currency_code' => 'CreditReversalAmount.CurrencyCode'
|
455 |
+
);
|
456 |
|
457 |
foreach ($providerCreditInfo as $key => $value)
|
458 |
{
|
459 |
+
$value = array_change_key_case($value, CASE_LOWER);
|
460 |
+
$providerIndex = $providerIndex + 1;
|
461 |
|
462 |
+
foreach ($value as $param => $val)
|
463 |
+
{
|
464 |
if (array_key_exists($param, $fieldMappings) && trim($val)!='') {
|
465 |
+
$parameters[$providerString.$providerIndex. '.' .$fieldMappings[$param]] = $val;
|
466 |
+
}
|
467 |
}
|
|
|
468 |
|
469 |
+
// If currency code is not entered take it from the config array
|
470 |
+
if(empty($parameters[$providerString.$providerIndex. '.' .$fieldMappings['currency_code']]))
|
471 |
+
{
|
472 |
$parameters[$providerString.$providerIndex. '.' .$fieldMappings['currency_code']] = strtoupper($this->config['currency_code']);
|
473 |
+
}
|
474 |
}
|
475 |
|
476 |
return $parameters;
|
477 |
+
}
|
478 |
+
|
479 |
+
/* GetOrderReferenceDetails API call - Returns details about the Order Reference object and its current state.
|
480 |
+
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetOrderReferenceDetails.html
|
481 |
+
*
|
482 |
+
* @param requestParameters['merchant_id'] - [String]
|
483 |
+
* @param requestParameters['amazon_order_reference_id'] - [String]
|
484 |
+
* @optional requestParameters['address_consent_token'] - [String]
|
485 |
+
* @optional requestParameters['mws_auth_token'] - [String]
|
486 |
+
*/
|
487 |
+
|
488 |
+
public function getOrderReferenceDetails($requestParameters = array())
|
489 |
+
{
|
490 |
+
|
491 |
+
$parameters['Action'] = 'GetOrderReferenceDetails';
|
492 |
+
$requestParameters = array_change_key_case($requestParameters, CASE_LOWER);
|
493 |
+
|
494 |
+
$fieldMappings = array(
|
495 |
+
'merchant_id' => 'SellerId',
|
496 |
+
'amazon_order_reference_id' => 'AmazonOrderReferenceId',
|
497 |
+
'address_consent_token' => 'AddressConsentToken',
|
498 |
+
'mws_auth_token' => 'MWSAuthToken'
|
499 |
+
);
|
500 |
+
|
501 |
+
$responseObject = $this->setParametersAndPost($parameters, $fieldMappings, $requestParameters);
|
502 |
+
return ($responseObject);
|
503 |
+
}
|
504 |
+
|
505 |
+
/* SetOrderReferenceDetails API call - Sets order reference details such as the order total and a description for the order.
|
506 |
+
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_SetOrderReferenceDetails.html
|
507 |
+
*
|
508 |
+
* @param requestParameters['merchant_id'] - [String]
|
509 |
+
* @param requestParameters['amazon_order_reference_id'] - [String]
|
510 |
+
* @param requestParameters['amount'] - [String]
|
511 |
+
* @param requestParameters['currency_code'] - [String]
|
512 |
+
* @optional requestParameters['platform_id'] - [String]
|
513 |
+
* @optional requestParameters['seller_note'] - [String]
|
514 |
+
* @optional requestParameters['seller_order_id'] - [String]
|
515 |
+
* @optional requestParameters['store_name'] - [String]
|
516 |
+
* @optional requestParameters['custom_information'] - [String]
|
517 |
+
* @optional requestParameters['mws_auth_token'] - [String]
|
518 |
+
*/
|
519 |
+
|
520 |
+
public function setOrderReferenceDetails($requestParameters = array())
|
521 |
+
{
|
522 |
+
$parameters = array();
|
523 |
+
$parameters['Action'] = 'SetOrderReferenceDetails';
|
524 |
+
$requestParameters = array_change_key_case($requestParameters, CASE_LOWER);
|
525 |
+
|
526 |
+
$fieldMappings = array(
|
527 |
+
'merchant_id' => 'SellerId',
|
528 |
+
'amazon_order_reference_id' => 'AmazonOrderReferenceId',
|
529 |
+
'amount' => 'OrderReferenceAttributes.OrderTotal.Amount',
|
530 |
+
'currency_code' => 'OrderReferenceAttributes.OrderTotal.CurrencyCode',
|
531 |
+
'platform_id' => 'OrderReferenceAttributes.PlatformId',
|
532 |
+
'seller_note' => 'OrderReferenceAttributes.SellerNote',
|
533 |
+
'seller_order_id' => 'OrderReferenceAttributes.SellerOrderAttributes.SellerOrderId',
|
534 |
+
'store_name' => 'OrderReferenceAttributes.SellerOrderAttributes.StoreName',
|
535 |
+
'custom_information' => 'OrderReferenceAttributes.SellerOrderAttributes.CustomInformation',
|
536 |
+
'mws_auth_token' => 'MWSAuthToken'
|
537 |
+
);
|
538 |
+
|
539 |
+
$responseObject = $this->setParametersAndPost($parameters, $fieldMappings, $requestParameters);
|
540 |
|
541 |
return ($responseObject);
|
542 |
+
}
|
543 |
+
|
544 |
+
/* ConfirmOrderReferenceDetails API call - Confirms that the order reference is free of constraints and all required information has been set on the order reference.
|
545 |
+
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_ConfirmOrderReference.html
|
546 |
+
|
547 |
+
* @param requestParameters['merchant_id'] - [String]
|
548 |
+
* @param requestParameters['amazon_order_reference_id'] - [String]
|
549 |
+
* @optional requestParameters['mws_auth_token'] - [String]
|
550 |
+
*/
|
551 |
+
|
552 |
+
public function confirmOrderReference($requestParameters = array())
|
553 |
+
{
|
554 |
+
$parameters = array();
|
555 |
+
$parameters['Action'] = 'ConfirmOrderReference';
|
556 |
+
$requestParameters = array_change_key_case($requestParameters, CASE_LOWER);
|
557 |
+
|
558 |
+
$fieldMappings = array(
|
559 |
+
'merchant_id' => 'SellerId',
|
560 |
+
'amazon_order_reference_id' => 'AmazonOrderReferenceId',
|
561 |
+
'mws_auth_token' => 'MWSAuthToken'
|
562 |
+
);
|
563 |
+
|
564 |
+
$responseObject = $this->setParametersAndPost($parameters, $fieldMappings, $requestParameters);
|
565 |
+
|
566 |
+
return ($responseObject);
|
567 |
+
}
|
568 |
+
|
569 |
+
/* CancelOrderReferenceDetails API call - Cancels a previously confirmed order reference.
|
570 |
+
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_CancelOrderReference.html
|
571 |
+
*
|
572 |
+
* @param requestParameters['merchant_id'] - [String]
|
573 |
+
* @param requestParameters['amazon_order_reference_id'] - [String]
|
574 |
+
* @optional requestParameters['cancelation_reason'] [String]
|
575 |
+
* @optional requestParameters['mws_auth_token'] - [String]
|
576 |
+
*/
|
577 |
+
|
578 |
+
public function cancelOrderReference($requestParameters = array())
|
579 |
+
{
|
580 |
+
$parameters = array();
|
581 |
+
$parameters['Action'] = 'CancelOrderReference';
|
582 |
+
$requestParameters = array_change_key_case($requestParameters, CASE_LOWER);
|
583 |
+
|
584 |
+
$fieldMappings = array(
|
585 |
+
'merchant_id' => 'SellerId',
|
586 |
+
'amazon_order_reference_id' => 'AmazonOrderReferenceId',
|
587 |
+
'cancelation_reason' => 'CancelationReason',
|
588 |
+
'mws_auth_token' => 'MWSAuthToken'
|
589 |
+
);
|
590 |
+
|
591 |
+
$responseObject = $this->setParametersAndPost($parameters, $fieldMappings, $requestParameters);
|
592 |
|
593 |
return ($responseObject);
|
594 |
+
}
|
595 |
+
|
596 |
+
/* CloseOrderReferenceDetails API call - Confirms that an order reference has been fulfilled (fully or partially)
|
597 |
+
* and that you do not expect to create any new authorizations on this order reference.
|
598 |
+
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_CloseOrderReference.html
|
599 |
+
*
|
600 |
+
* @param requestParameters['merchant_id'] - [String]
|
601 |
+
* @param requestParameters['amazon_order_reference_id'] - [String]
|
602 |
+
* @optional requestParameters['closure_reason'] [String]
|
603 |
+
* @optional requestParameters['mws_auth_token'] - [String]
|
604 |
+
*/
|
605 |
+
|
606 |
+
public function closeOrderReference($requestParameters = array())
|
607 |
+
{
|
608 |
+
$parameters = array();
|
609 |
+
$parameters['Action'] = 'CloseOrderReference';
|
610 |
+
$requestParameters = array_change_key_case($requestParameters, CASE_LOWER);
|
611 |
+
|
612 |
+
$fieldMappings = array(
|
613 |
+
'merchant_id' => 'SellerId',
|
614 |
+
'amazon_order_reference_id' => 'AmazonOrderReferenceId',
|
615 |
+
'closure_reason' => 'ClosureReason',
|
616 |
+
'mws_auth_token' => 'MWSAuthToken'
|
617 |
+
);
|
618 |
+
|
619 |
+
$responseObject = $this->setParametersAndPost($parameters, $fieldMappings, $requestParameters);
|
620 |
+
|
621 |
+
return ($responseObject);
|
622 |
+
}
|
623 |
+
|
624 |
+
/* CloseAuthorization API call - Closes an authorization.
|
625 |
+
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_CloseOrderReference.html
|
626 |
+
*
|
627 |
+
* @param requestParameters['merchant_id'] - [String]
|
628 |
+
* @param requestParameters['amazon_authorization_id'] - [String]
|
629 |
+
* @optional requestParameters['closure_reason'] [String]
|
630 |
+
* @optional requestParameters['mws_auth_token'] - [String]
|
631 |
+
*/
|
632 |
+
|
633 |
+
public function closeAuthorization($requestParameters = array())
|
634 |
+
{
|
635 |
+
$parameters = array();
|
636 |
+
$parameters['Action'] = 'CloseAuthorization';
|
637 |
+
$requestParameters = array_change_key_case($requestParameters, CASE_LOWER);
|
638 |
+
|
639 |
+
$fieldMappings = array(
|
640 |
+
'merchant_id' => 'SellerId',
|
641 |
+
'amazon_authorization_id' => 'AmazonAuthorizationId',
|
642 |
+
'closure_reason' => 'ClosureReason',
|
643 |
+
'mws_auth_token' => 'MWSAuthToken'
|
644 |
+
);
|
645 |
+
|
646 |
+
$responseObject = $this->setParametersAndPost($parameters, $fieldMappings, $requestParameters);
|
647 |
+
|
648 |
+
return ($responseObject);
|
649 |
+
}
|
650 |
+
|
651 |
+
/* Authorize API call - Reserves a specified amount against the payment method(s) stored in the order reference.
|
652 |
+
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_Authorize.html
|
653 |
+
*
|
654 |
+
* @param requestParameters['merchant_id'] - [String]
|
655 |
+
* @param requestParameters['amazon_order_reference_id'] - [String]
|
656 |
+
* @param requestParameters['authorization_amount'] [String]
|
657 |
+
* @param requestParameters['currency_code'] - [String]
|
658 |
+
* @param requestParameters['authorization_reference_id'] [String]
|
659 |
+
* @optional requestParameters['capture_now'] [String]
|
660 |
+
* @optional requestParameters['provider_credit_details'] - [array (array())]
|
661 |
+
* @optional requestParameters['seller_authorization_note'] [String]
|
662 |
+
* @optional requestParameters['transaction_timeout'] [String] - Defaults to 1440 minutes
|
663 |
+
* @optional requestParameters['soft_descriptor'] - [String]
|
664 |
+
* @optional requestParameters['mws_auth_token'] - [String]
|
665 |
+
*/
|
666 |
+
|
667 |
+
public function authorize($requestParameters = array())
|
668 |
+
{
|
669 |
+
$parameters = array();
|
670 |
+
$parameters['Action'] = 'Authorize';
|
671 |
+
$requestParameters = array_change_key_case($requestParameters, CASE_LOWER);
|
672 |
+
|
673 |
+
$fieldMappings = array(
|
674 |
+
'merchant_id' => 'SellerId',
|
675 |
+
'amazon_order_reference_id' => 'AmazonOrderReferenceId',
|
676 |
+
'authorization_amount' => 'AuthorizationAmount.Amount',
|
677 |
+
'currency_code' => 'AuthorizationAmount.CurrencyCode',
|
678 |
+
'authorization_reference_id' => 'AuthorizationReferenceId',
|
679 |
+
'capture_now' => 'CaptureNow',
|
680 |
+
'provider_credit_details' => array(),
|
681 |
+
'seller_authorization_note' => 'SellerAuthorizationNote',
|
682 |
+
'transaction_timeout' => 'TransactionTimeout',
|
683 |
+
'soft_descriptor' => 'SoftDescriptor',
|
684 |
+
'mws_auth_token' => 'MWSAuthToken'
|
685 |
+
);
|
686 |
+
|
687 |
+
$responseObject = $this->setParametersAndPost($parameters, $fieldMappings, $requestParameters);
|
688 |
+
|
689 |
+
return ($responseObject);
|
690 |
+
}
|
691 |
+
|
692 |
+
/* GetAuthorizationDetails API call - Returns the status of a particular authorization and the total amount captured on the authorization.
|
693 |
+
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetAuthorizationDetails.html
|
694 |
+
*
|
695 |
+
* @param requestParameters['merchant_id'] - [String]
|
696 |
+
* @param requestParameters['amazon_authorization_id'] [String]
|
697 |
+
* @optional requestParameters['mws_auth_token'] - [String]
|
698 |
+
*/
|
699 |
+
|
700 |
+
public function getAuthorizationDetails($requestParameters = array())
|
701 |
+
{
|
702 |
+
$parameters = array();
|
703 |
+
$parameters['Action'] = 'GetAuthorizationDetails';
|
704 |
+
$requestParameters = array_change_key_case($requestParameters, CASE_LOWER);
|
705 |
+
|
706 |
+
$fieldMappings = array(
|
707 |
+
'merchant_id' => 'SellerId',
|
708 |
+
'amazon_authorization_id' => 'AmazonAuthorizationId',
|
709 |
+
'mws_auth_token' => 'MWSAuthToken'
|
710 |
+
);
|
711 |
+
|
712 |
+
$responseObject = $this->setParametersAndPost($parameters, $fieldMappings, $requestParameters);
|
713 |
+
|
714 |
+
return ($responseObject);
|
715 |
+
}
|
716 |
+
|
717 |
+
/* Capture API call - Captures funds from an authorized payment instrument.
|
718 |
+
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_Capture.html
|
719 |
+
*
|
720 |
+
* @param requestParameters['merchant_id'] - [String]
|
721 |
+
* @param requestParameters['amazon_authorization_id'] - [String]
|
722 |
+
* @param requestParameters['capture_amount'] - [String]
|
723 |
+
* @param requestParameters['currency_code'] - [String]
|
724 |
+
* @param requestParameters['capture_reference_id'] - [String]
|
725 |
+
* @optional requestParameters['provider_credit_details'] - [array (array())]
|
726 |
+
* @optional requestParameters['seller_capture_note'] - [String]
|
727 |
+
* @optional requestParameters['soft_descriptor'] - [String]
|
728 |
+
* @optional requestParameters['mws_auth_token'] - [String]
|
729 |
+
*/
|
730 |
+
|
731 |
+
public function capture($requestParameters = array())
|
732 |
+
{
|
733 |
+
$parameters = array();
|
734 |
+
$parameters['Action'] = 'Capture';
|
735 |
+
$requestParameters = array_change_key_case($requestParameters, CASE_LOWER);
|
736 |
+
|
737 |
+
$fieldMappings = array(
|
738 |
+
'merchant_id' => 'SellerId',
|
739 |
+
'amazon_authorization_id' => 'AmazonAuthorizationId',
|
740 |
+
'capture_amount' => 'CaptureAmount.Amount',
|
741 |
+
'currency_code' => 'CaptureAmount.CurrencyCode',
|
742 |
+
'capture_reference_id' => 'CaptureReferenceId',
|
743 |
+
'provider_credit_details' => array(),
|
744 |
+
'seller_capture_note' => 'SellerCaptureNote',
|
745 |
+
'soft_descriptor' => 'SoftDescriptor',
|
746 |
+
'mws_auth_token' => 'MWSAuthToken'
|
747 |
+
);
|
748 |
+
|
749 |
+
$responseObject = $this->setParametersAndPost($parameters, $fieldMappings, $requestParameters);
|
750 |
|
751 |
return ($responseObject);
|
752 |
+
}
|
753 |
+
|
754 |
+
/* GetCaptureDetails API call - Returns the status of a particular capture and the total amount refunded on the capture.
|
755 |
+
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetCaptureDetails.html
|
756 |
+
*
|
757 |
+
* @param requestParameters['merchant_id'] - [String]
|
758 |
+
* @param requestParameters['amazon_capture_id'] - [String]
|
759 |
+
* @optional requestParameters['mws_auth_token'] - [String]
|
760 |
+
*/
|
761 |
+
|
762 |
+
public function getCaptureDetails($requestParameters = array())
|
763 |
+
{
|
764 |
+
$parameters = array();
|
765 |
+
$parameters['Action'] = 'GetCaptureDetails';
|
766 |
+
$requestParameters = array_change_key_case($requestParameters, CASE_LOWER);
|
767 |
+
|
768 |
+
$fieldMappings = array(
|
769 |
+
'merchant_id' => 'SellerId',
|
770 |
+
'amazon_capture_id' => 'AmazonCaptureId',
|
771 |
+
'mws_auth_token' => 'MWSAuthToken'
|
772 |
+
);
|
773 |
+
|
774 |
+
$responseObject = $this->setParametersAndPost($parameters, $fieldMappings, $requestParameters);
|
775 |
+
|
776 |
+
return ($responseObject);
|
777 |
+
}
|
778 |
+
|
779 |
+
/* Refund API call - Refunds a previously captured amount.
|
780 |
+
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_Refund.html
|
781 |
+
*
|
782 |
+
* @param requestParameters['merchant_id'] - [String]
|
783 |
+
* @param requestParameters['amazon_capture_id'] - [String]
|
784 |
+
* @param requestParameters['refund_reference_id'] - [String]
|
785 |
+
* @param requestParameters['refund_amount'] - [String]
|
786 |
+
* @param requestParameters['currency_code'] - [String]
|
787 |
+
* @optional requestParameters['provider_credit_reversal_details'] - [array(array())]
|
788 |
+
* @optional requestParameters['seller_refund_note'] [String]
|
789 |
+
* @optional requestParameters['soft_descriptor'] - [String]
|
790 |
+
* @optional requestParameters['mws_auth_token'] - [String]
|
791 |
+
*/
|
792 |
+
|
793 |
+
public function refund($requestParameters = array())
|
794 |
+
{
|
795 |
+
$parameters = array();
|
796 |
+
$parameters['Action'] = 'Refund';
|
797 |
+
$requestParameters = array_change_key_case($requestParameters, CASE_LOWER);
|
798 |
+
|
799 |
+
$fieldMappings = array(
|
800 |
+
'merchant_id' => 'SellerId',
|
801 |
+
'amazon_capture_id' => 'AmazonCaptureId',
|
802 |
+
'refund_reference_id' => 'RefundReferenceId',
|
803 |
+
'refund_amount' => 'RefundAmount.Amount',
|
804 |
+
'currency_code' => 'RefundAmount.CurrencyCode',
|
805 |
+
'provider_credit_reversal_details' => array(),
|
806 |
+
'seller_refund_note' => 'SellerRefundNote',
|
807 |
+
'soft_descriptor' => 'SoftDescriptor',
|
808 |
+
'mws_auth_token' => 'MWSAuthToken'
|
809 |
+
);
|
810 |
+
|
811 |
+
$responseObject = $this->setParametersAndPost($parameters, $fieldMappings, $requestParameters);
|
812 |
+
|
813 |
+
return ($responseObject);
|
814 |
+
}
|
815 |
+
|
816 |
+
/* GetRefundDetails API call - Returns the status of a particular refund.
|
817 |
+
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetRefundDetails.html
|
818 |
+
*
|
819 |
+
* @param requestParameters['merchant_id'] - [String]
|
820 |
+
* @param requestParameters['amazon_refund_id'] - [String]
|
821 |
+
* @optional requestParameters['mws_auth_token'] - [String]
|
822 |
+
*/
|
823 |
+
|
824 |
+
public function getRefundDetails($requestParameters = array())
|
825 |
+
{
|
826 |
+
$parameters = array();
|
827 |
+
$parameters['Action'] = 'GetRefundDetails';
|
828 |
+
$requestParameters = array_change_key_case($requestParameters, CASE_LOWER);
|
829 |
+
|
830 |
+
$fieldMappings = array(
|
831 |
+
'merchant_id' => 'SellerId',
|
832 |
+
'amazon_refund_id' => 'AmazonRefundId',
|
833 |
+
'mws_auth_token' => 'MWSAuthToken'
|
834 |
+
);
|
835 |
+
|
836 |
+
$responseObject = $this->setParametersAndPost($parameters, $fieldMappings, $requestParameters);
|
837 |
+
|
838 |
+
return ($responseObject);
|
839 |
+
}
|
840 |
+
|
841 |
+
/* GetServiceStatus API Call - Returns the operational status of the Off-Amazon Payments API section
|
842 |
+
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetServiceStatus.html
|
843 |
+
*
|
844 |
+
* The GetServiceStatus operation returns the operational status of the Off-Amazon Payments API
|
845 |
+
* section of Amazon Marketplace Web Service (Amazon MWS).
|
846 |
+
* Status values are GREEN, GREEN_I, YELLOW, and RED.
|
847 |
+
*
|
848 |
+
* @param requestParameters['merchant_id'] - [String]
|
849 |
+
* @optional requestParameters['mws_auth_token'] - [String]
|
850 |
+
*/
|
851 |
+
|
852 |
+
public function getServiceStatus($requestParameters = array())
|
853 |
+
{
|
854 |
+
$parameters = array();
|
855 |
+
$parameters['Action'] = 'GetServiceStatus';
|
856 |
+
$requestParameters = array_change_key_case($requestParameters, CASE_LOWER);
|
857 |
+
|
858 |
+
$fieldMappings = array(
|
859 |
+
'merchant_id' => 'SellerId',
|
860 |
+
'mws_auth_token' => 'MWSAuthToken'
|
861 |
+
);
|
862 |
+
|
863 |
+
$responseObject = $this->setParametersAndPost($parameters, $fieldMappings, $requestParameters);
|
864 |
|
865 |
return ($responseObject);
|
866 |
+
}
|
867 |
+
|
868 |
+
/* CreateOrderReferenceForId API Call - Creates an order reference for the given object
|
869 |
+
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_CreateOrderReferenceForId.html
|
870 |
+
*
|
871 |
+
* @param requestParameters['merchant_id'] - [String]
|
872 |
+
* @param requestParameters['Id'] - [String]
|
873 |
+
* @optional requestParameters['inherit_shipping_address'] [Boolean]
|
874 |
+
* @optional requestParameters['ConfirmNow'] - [Boolean]
|
875 |
+
* @optional Amount (required when confirm_now is set to true) [String]
|
876 |
+
* @optional requestParameters['currency_code'] - [String]
|
877 |
+
* @optional requestParameters['seller_note'] - [String]
|
878 |
+
* @optional requestParameters['seller_order_id'] - [String]
|
879 |
+
* @optional requestParameters['store_name'] - [String]
|
880 |
+
* @optional requestParameters['custom_information'] - [String]
|
881 |
+
* @optional requestParameters['mws_auth_token'] - [String]
|
882 |
+
*/
|
883 |
+
|
884 |
+
public function createOrderReferenceForId($requestParameters = array())
|
885 |
+
{
|
886 |
+
$parameters = array();
|
887 |
+
$parameters['Action'] = 'CreateOrderReferenceForId';
|
888 |
+
$requestParameters = array_change_key_case($requestParameters, CASE_LOWER);
|
889 |
+
|
890 |
+
$fieldMappings = array(
|
891 |
+
'merchant_id' => 'SellerId',
|
892 |
+
'id' => 'Id',
|
893 |
+
'id_type' => 'IdType',
|
894 |
+
'inherit_shipping_address' => 'InheritShippingAddress',
|
895 |
+
'confirm_now' => 'ConfirmNow',
|
896 |
+
'amount' => 'OrderReferenceAttributes.OrderTotal.Amount',
|
897 |
+
'currency_code' => 'OrderReferenceAttributes.OrderTotal.CurrencyCode',
|
898 |
+
'platform_id' => 'OrderReferenceAttributes.PlatformId',
|
899 |
+
'seller_note' => 'OrderReferenceAttributes.SellerNote',
|
900 |
+
'seller_order_id' => 'OrderReferenceAttributes.SellerOrderAttributes.SellerOrderId',
|
901 |
+
'store_name' => 'OrderReferenceAttributes.SellerOrderAttributes.StoreName',
|
902 |
+
'custom_information' => 'OrderReferenceAttributes.SellerOrderAttributes.CustomInformation',
|
903 |
+
'mws_auth_token' => 'MWSAuthToken'
|
904 |
+
);
|
905 |
+
|
906 |
+
$responseObject = $this->setParametersAndPost($parameters, $fieldMappings, $requestParameters);
|
907 |
+
|
908 |
+
return ($responseObject);
|
909 |
+
}
|
910 |
+
|
911 |
+
/* GetBillingAgreementDetails API Call - Returns details about the Billing Agreement object and its current state.
|
912 |
+
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetBillingAgreementDetails.html
|
913 |
+
*
|
914 |
+
* @param requestParameters['merchant_id'] - [String]
|
915 |
+
* @param requestParameters['amazon_billing_agreement_id'] - [String]
|
916 |
+
* @optional requestParameters['mws_auth_token'] - [String]
|
917 |
+
*/
|
918 |
+
|
919 |
+
public function getBillingAgreementDetails($requestParameters = array())
|
920 |
+
{
|
921 |
+
$parameters = array();
|
922 |
+
$parameters['Action'] = 'GetBillingAgreementDetails';
|
923 |
+
$requestParameters = array_change_key_case($requestParameters, CASE_LOWER);
|
924 |
+
|
925 |
+
$fieldMappings = array(
|
926 |
+
'merchant_id' => 'SellerId',
|
927 |
+
'amazon_billing_agreement_id' => 'AmazonBillingAgreementId',
|
928 |
+
'address_consent_token' => 'AddressConsentToken',
|
929 |
+
'mws_auth_token' => 'MWSAuthToken'
|
930 |
+
);
|
931 |
+
|
932 |
+
$responseObject = $this->setParametersAndPost($parameters, $fieldMappings, $requestParameters);
|
933 |
|
934 |
return ($responseObject);
|
935 |
+
}
|
936 |
+
|
937 |
+
/* SetBillingAgreementDetails API call - Sets Billing Agreement details such as a description of the agreement and other information about the seller.
|
938 |
+
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_SetBillingAgreementDetails.html
|
939 |
+
*
|
940 |
+
* @param requestParameters['merchant_id'] - [String]
|
941 |
+
* @param requestParameters['amazon_billing_agreement_id'] - [String]
|
942 |
+
* @param requestParameters['amount'] - [String]
|
943 |
+
* @param requestParameters['currency_code'] - [String]
|
944 |
+
* @optional requestParameters['platform_id'] - [String]
|
945 |
+
* @optional requestParameters['seller_note'] - [String]
|
946 |
+
* @optional requestParameters['seller_billing_agreement_id'] - [String]
|
947 |
+
* @optional requestParameters['store_name'] - [String]
|
948 |
+
* @optional requestParameters['custom_information'] - [String]
|
949 |
+
* @optional requestParameters['mws_auth_token'] - [String]
|
950 |
+
*/
|
951 |
+
|
952 |
+
public function setBillingAgreementDetails($requestParameters = array())
|
953 |
+
{
|
954 |
+
$parameters = array();
|
955 |
+
$parameters['Action'] = 'SetBillingAgreementDetails';
|
956 |
+
$requestParameters = array_change_key_case($requestParameters, CASE_LOWER);
|
957 |
+
|
958 |
+
$fieldMappings = array(
|
959 |
+
'merchant_id' => 'SellerId',
|
960 |
+
'amazon_billing_agreement_id' => 'AmazonBillingAgreementId',
|
961 |
+
'platform_id' => 'BillingAgreementAttributes.PlatformId',
|
962 |
+
'seller_note' => 'BillingAgreementAttributes.SellerNote',
|
963 |
+
'seller_billing_agreement_id' => 'BillingAgreementAttributes.SellerBillingAgreementAttributes.SellerBillingAgreementId',
|
964 |
+
'custom_information' => 'BillingAgreementAttributes.SellerBillingAgreementAttributes.CustomInformation',
|
965 |
+
'store_name' => 'BillingAgreementAttributes.SellerBillingAgreementAttributes.StoreName',
|
966 |
+
'mws_auth_token' => 'MWSAuthToken'
|
967 |
+
);
|
968 |
+
|
969 |
+
$responseObject = $this->setParametersAndPost($parameters, $fieldMappings, $requestParameters);
|
970 |
+
|
971 |
+
return ($responseObject);
|
972 |
+
}
|
973 |
+
|
974 |
+
/* ConfirmBillingAgreement API Call - Confirms that the Billing Agreement is free of constraints and all required information has been set on the Billing Agreement.
|
975 |
+
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_ConfirmBillingAgreement.html
|
976 |
+
*
|
977 |
+
* @param requestParameters['merchant_id'] - [String]
|
978 |
+
* @param requestParameters['amazon_billing_agreement_id'] - [String]
|
979 |
+
* @optional requestParameters['mws_auth_token'] - [String]
|
980 |
+
*/
|
981 |
+
|
982 |
+
public function confirmBillingAgreement($requestParameters = array())
|
983 |
+
{
|
984 |
+
$parameters = array();
|
985 |
+
$parameters['Action'] = 'ConfirmBillingAgreement';
|
986 |
+
$requestParameters = array_change_key_case($requestParameters, CASE_LOWER);
|
987 |
+
|
988 |
+
$fieldMappings = array(
|
989 |
+
'merchant_id' => 'SellerId',
|
990 |
+
'amazon_billing_agreement_id' => 'AmazonBillingAgreementId',
|
991 |
+
'mws_auth_token' => 'MWSAuthToken'
|
992 |
+
);
|
993 |
+
|
994 |
+
$responseObject = $this->setParametersAndPost($parameters, $fieldMappings, $requestParameters);
|
995 |
+
|
996 |
+
return ($responseObject);
|
997 |
+
}
|
998 |
+
|
999 |
+
/* ValidateBillignAgreement API Call - Validates the status of the Billing Agreement object and the payment method associated with it.
|
1000 |
+
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_ValidateBillingAgreement.html
|
1001 |
+
*
|
1002 |
+
* @param requestParameters['merchant_id'] - [String]
|
1003 |
+
* @param requestParameters['amazon_billing_agreement_id'] - [String]
|
1004 |
+
* @optional requestParameters['mws_auth_token'] - [String]
|
1005 |
+
*/
|
1006 |
+
|
1007 |
+
public function validateBillingAgreement($requestParameters = array())
|
1008 |
+
{
|
1009 |
+
$parameters = array();
|
1010 |
+
$parameters['Action'] = 'ValidateBillingAgreement';
|
1011 |
+
$requestParameters = array_change_key_case($requestParameters, CASE_LOWER);
|
1012 |
+
|
1013 |
+
$fieldMappings = array(
|
1014 |
+
'merchant_id' => 'SellerId',
|
1015 |
+
'amazon_billing_agreement_id' => 'AmazonBillingAgreementId',
|
1016 |
+
'mws_auth_token' => 'MWSAuthToken'
|
1017 |
+
);
|
1018 |
+
|
1019 |
+
$responseObject = $this->setParametersAndPost($parameters, $fieldMappings, $requestParameters);
|
1020 |
+
|
1021 |
+
return ($responseObject);
|
1022 |
+
}
|
1023 |
+
|
1024 |
+
/* AuthorizeOnBillingAgreement API call - Reserves a specified amount against the payment method(s) stored in the Billing Agreement.
|
1025 |
+
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_AuthorizeOnBillingAgreement.html
|
1026 |
+
*
|
1027 |
+
* @param requestParameters['merchant_id'] - [String]
|
1028 |
+
* @param requestParameters['amazon_billing_agreement_id'] - [String]
|
1029 |
+
* @param requestParameters['authorization_reference_id'] [String]
|
1030 |
+
* @param requestParameters['authorization_amount'] [String]
|
1031 |
+
* @param requestParameters['currency_code'] - [String]
|
1032 |
+
* @optional requestParameters['seller_authorization_note'] [String]
|
1033 |
+
* @optional requestParameters['transaction_timeout'] - Defaults to 1440 minutes
|
1034 |
+
* @optional requestParameters['capture_now'] [String]
|
1035 |
+
* @optional requestParameters['soft_descriptor'] - - [String]
|
1036 |
+
* @optional requestParameters['seller_note'] - [String]
|
1037 |
+
* @optional requestParameters['platform_id'] - [String]
|
1038 |
+
* @optional requestParameters['custom_information'] - [String]
|
1039 |
+
* @optional requestParameters['seller_order_id'] - [String]
|
1040 |
+
* @optional requestParameters['store_name'] - [String]
|
1041 |
+
* @optional requestParameters['inherit_shipping_address'] [Boolean] - Defaults to true
|
1042 |
+
* @optional requestParameters['mws_auth_token'] - [String]
|
1043 |
+
*/
|
1044 |
+
|
1045 |
+
public function authorizeOnBillingAgreement($requestParameters = array())
|
1046 |
+
{
|
1047 |
+
$parameters = array();
|
1048 |
+
$parameters['Action'] = 'AuthorizeOnBillingAgreement';
|
1049 |
+
$requestParameters = array_change_key_case($requestParameters, CASE_LOWER);
|
1050 |
+
|
1051 |
+
$fieldMappings = array(
|
1052 |
+
'merchant_id' => 'SellerId',
|
1053 |
+
'amazon_billing_agreement_id' => 'AmazonBillingAgreementId',
|
1054 |
+
'authorization_reference_id' => 'AuthorizationReferenceId',
|
1055 |
+
'authorization_amount' => 'AuthorizationAmount.Amount',
|
1056 |
+
'currency_code' => 'AuthorizationAmount.CurrencyCode',
|
1057 |
+
'seller_authorization_note' => 'SellerAuthorizationNote',
|
1058 |
+
'transaction_timeout' => 'TransactionTimeout',
|
1059 |
+
'capture_now' => 'CaptureNow',
|
1060 |
+
'soft_descriptor' => 'SoftDescriptor',
|
1061 |
+
'seller_note' => 'SellerNote',
|
1062 |
+
'platform_id' => 'PlatformId',
|
1063 |
+
'custom_information' => 'SellerOrderAttributes.CustomInformation',
|
1064 |
+
'seller_order_id' => 'SellerOrderAttributes.SellerOrderId',
|
1065 |
+
'store_name' => 'SellerOrderAttributes.StoreName',
|
1066 |
+
'inherit_shipping_address' => 'InheritShippingAddress',
|
1067 |
+
'mws_auth_token' => 'MWSAuthToken'
|
1068 |
+
);
|
1069 |
+
|
1070 |
+
$responseObject = $this->setParametersAndPost($parameters, $fieldMappings, $requestParameters);
|
1071 |
|
1072 |
return ($responseObject);
|
1073 |
+
}
|
1074 |
+
|
1075 |
+
/* CloseBillingAgreement API Call - Returns details about the Billing Agreement object and its current state.
|
1076 |
+
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_CloseBillingAgreement.html
|
1077 |
+
*
|
1078 |
+
* @param requestParameters['merchant_id'] - [String]
|
1079 |
+
* @param requestParameters['amazon_billing_agreement_id'] - [String]
|
1080 |
+
* @optional requestParameters['closure_reason'] [String]
|
1081 |
+
* @optional requestParameters['mws_auth_token'] - [String]
|
1082 |
+
*/
|
1083 |
+
|
1084 |
+
public function closeBillingAgreement($requestParameters = array())
|
1085 |
+
{
|
1086 |
+
$parameters = array();
|
1087 |
+
$parameters['Action'] = 'CloseBillingAgreement';
|
1088 |
+
$requestParameters = array_change_key_case($requestParameters, CASE_LOWER);
|
1089 |
+
|
1090 |
+
$fieldMappings = array(
|
1091 |
+
'merchant_id' => 'SellerId',
|
1092 |
+
'amazon_billing_agreement_id' => 'AmazonBillingAgreementId',
|
1093 |
+
'closure_reason' => 'ClosureReason',
|
1094 |
+
'mws_auth_token' => 'MWSAuthToken'
|
1095 |
+
);
|
1096 |
+
|
1097 |
+
$responseObject = $this->setParametersAndPost($parameters, $fieldMappings, $requestParameters);
|
1098 |
+
|
1099 |
+
return ($responseObject);
|
1100 |
+
}
|
1101 |
+
|
1102 |
+
/* charge convenience method
|
1103 |
+
* Performs the API calls
|
1104 |
+
* 1. SetOrderReferenceDetails / SetBillingAgreementDetails
|
1105 |
+
* 2. ConfirmOrderReference / ConfirmBillingAgreement
|
1106 |
+
* 3. Authorize (with Capture) / AuthorizeOnBillingAgreeemnt (with Capture)
|
1107 |
+
*
|
1108 |
+
* @param requestParameters['merchant_id'] - [String]
|
1109 |
+
*
|
1110 |
+
* @param requestParameters['amazon_reference_id'] - [String] : Order Reference ID /Billing Agreement ID
|
1111 |
+
* If requestParameters['amazon_reference_id'] is empty then the following is required,
|
1112 |
+
* @param requestParameters['amazon_order_reference_id'] - [String] : Order Reference ID
|
1113 |
+
* or,
|
1114 |
+
* @param requestParameters['amazon_billing_agreement_id'] - [String] : Billing Agreement ID
|
1115 |
+
*
|
1116 |
+
* @param $requestParameters['charge_amount'] - [String] : Amount value to be captured
|
1117 |
+
* @param requestParameters['currency_code'] - [String] : Currency Code for the Amount
|
1118 |
+
* @param requestParameters['authorization_reference_id'] - [String]- Any unique string that needs to be passed
|
1119 |
+
* @optional requestParameters['charge_note'] - [String] : Seller Note sent to the buyer
|
1120 |
+
* @optional requestParameters['transaction_timeout'] - [String] : Defaults to 1440 minutes
|
1121 |
+
* @optional requestParameters['charge_order_id'] - [String] : Custom Order ID provided
|
1122 |
+
* @optional requestParameters['mws_auth_token'] - [String]
|
1123 |
+
*/
|
1124 |
+
|
1125 |
+
public function charge($requestParameters = array()) {
|
1126 |
|
1127 |
$requestParameters = array_change_key_case($requestParameters, CASE_LOWER);
|
1128 |
$requestParameters= $this->trimArray($requestParameters);
|
1129 |
|
1130 |
$setParameters = $authorizeParameters = $confirmParameters = $requestParameters;
|
1131 |
|
1132 |
+
$chargeType = '';
|
1133 |
+
|
1134 |
if (!empty($requestParameters['amazon_order_reference_id']))
|
1135 |
{
|
1136 |
+
$chargeType = 'OrderReference';
|
1137 |
+
|
1138 |
} elseif(!empty($requestParameters['amazon_billing_agreement_id'])) {
|
1139 |
+
$chargeType = 'BillingAgreement';
|
1140 |
+
|
1141 |
} elseif (!empty($requestParameters['amazon_reference_id'])) {
|
1142 |
+
switch (substr(strtoupper($requestParameters['amazon_reference_id']), 0, 1)) {
|
1143 |
+
case 'P':
|
1144 |
+
case 'S':
|
1145 |
+
$chargeType = 'OrderReference';
|
1146 |
+
$setParameters['amazon_order_reference_id'] = $requestParameters['amazon_reference_id'];
|
1147 |
+
$authorizeParameters['amazon_order_reference_id'] = $requestParameters['amazon_reference_id'];
|
1148 |
+
$confirmParameters['amazon_order_reference_id'] = $requestParameters['amazon_reference_id'];
|
1149 |
+
break;
|
1150 |
+
case 'B':
|
1151 |
+
case 'C':
|
1152 |
+
$chargeType = 'BillingAgreement';
|
1153 |
+
$setParameters['amazon_billing_agreement_id'] = $requestParameters['amazon_reference_id'];
|
1154 |
+
$authorizeParameters['amazon_billing_agreement_id'] = $requestParameters['amazon_reference_id'];
|
1155 |
+
$confirmParameters['amazon_billing_agreement_id'] = $requestParameters['amazon_reference_id'];
|
1156 |
+
break;
|
1157 |
+
default:
|
1158 |
+
throw new \Exception('Invalid Amazon Reference ID');
|
1159 |
+
}
|
1160 |
+
} else {
|
1161 |
+
throw new \Exception('key amazon_order_reference_id or amazon_billing_agreement_id is null and is a required parameter');
|
1162 |
+
}
|
1163 |
|
1164 |
// Set the other parameters if the values are present
|
1165 |
+
$setParameters['amount'] = !empty($requestParameters['charge_amount']) ? $requestParameters['charge_amount'] : '';
|
1166 |
+
$authorizeParameters['authorization_amount'] = !empty($requestParameters['charge_amount']) ? $requestParameters['charge_amount'] : '';
|
1167 |
|
1168 |
+
$setParameters['seller_note'] = !empty($requestParameters['charge_note']) ? $requestParameters['charge_note'] : '';
|
1169 |
+
$authorizeParameters['seller_authorization_note'] = !empty($requestParameters['charge_note']) ? $requestParameters['charge_note'] : '';
|
1170 |
+
$authorizeParameters['seller_note'] = !empty($requestParameters['charge_note']) ? $requestParameters['charge_note'] : '';
|
1171 |
|
1172 |
+
$setParameters['seller_order_id'] = !empty($requestParameters['charge_order_id']) ? $requestParameters['charge_order_id'] : '';
|
1173 |
+
$setParameters['seller_billing_agreement_id'] = !empty($requestParameters['charge_order_id']) ? $requestParameters['charge_order_id'] : '';
|
1174 |
+
$authorizeParameters['seller_order_id'] = !empty($requestParameters['charge_order_id']) ? $requestParameters['charge_order_id'] : '';
|
1175 |
|
1176 |
+
$authorizeParameters['capture_now'] = 'true';
|
1177 |
|
1178 |
$response = $this->makeChargeCalls($chargeType, $setParameters, $confirmParameters, $authorizeParameters);
|
1179 |
return $response;
|
1180 |
+
}
|
1181 |
|
1182 |
+
/* makeChargeCalls - makes API calls based off the charge type (OrderReference or BillingAgreement) */
|
1183 |
|
1184 |
+
private function makeChargeCalls($chargeType, $setParameters, $confirmParameters, $authorizeParameters)
|
1185 |
+
{
|
1186 |
switch ($chargeType) {
|
1187 |
+
case 'OrderReference':
|
1188 |
+
$response = $this->setOrderReferenceDetails($setParameters);
|
1189 |
+
if ($this->success) {
|
1190 |
+
$this->confirmOrderReference($confirmParameters);
|
1191 |
+
}
|
1192 |
+
if ($this->success) {
|
1193 |
+
$response = $this->Authorize($authorizeParameters);
|
1194 |
+
}
|
1195 |
+
return $response;
|
1196 |
+
case 'BillingAgreement':
|
1197 |
+
// Get the Billing Agreement details and feed the response object to the ResponseParser
|
1198 |
+
$responseObj = $this->getBillingAgreementDetails($setParameters);
|
1199 |
+
// Call the function GetBillingAgreementDetailsStatus in ResponseParser.php providing it the XML response
|
1200 |
+
// $baStatus is an aray containing the State of the Billing Agreement
|
1201 |
+
$baStatus = $responseObj->getBillingAgreementDetailsStatus($responseObj->toXml());
|
1202 |
+
if ($baStatus['State'] != 'Open') {
|
1203 |
+
$response = $this->SetBillingAgreementDetails($setParameters);
|
1204 |
+
if ($this->success) {
|
1205 |
+
$response = $this->ConfirmBillingAgreement($confirmParameters);
|
1206 |
+
}
|
1207 |
+
}
|
1208 |
+
// Check the Billing Agreement status again before making the Authorization.
|
1209 |
+
$responseObj = $this->getBillingAgreementDetails($setParameters);
|
1210 |
+
$baStatus = $responseObj->GetBillingAgreementDetailsStatus($responseObj->toXml());
|
1211 |
+
if ($this->success && $baStatus['State'] === 'Open') {
|
1212 |
+
$response = $this->AuthorizeOnBillingAgreement($authorizeParameters);
|
1213 |
+
}
|
1214 |
+
return $response;
|
1215 |
+
}
|
1216 |
+
}
|
1217 |
+
|
1218 |
+
/* GetProviderCreditDetails API Call - Get the details of the Provider Credit.
|
1219 |
+
*
|
1220 |
+
* @param requestParameters['merchant_id'] - [String]
|
1221 |
+
* @param requestParameters['amazon_provider_credit_id'] - [String]
|
1222 |
+
* @optional requestParameters['mws_auth_token'] - [String]
|
1223 |
+
*/
|
1224 |
+
|
1225 |
+
public function getProviderCreditDetails($requestParameters = array())
|
1226 |
+
{
|
1227 |
$parameters = array();
|
1228 |
+
$parameters['Action'] = 'GetProviderCreditDetails';
|
1229 |
+
$requestParameters = array_change_key_case($requestParameters, CASE_LOWER);
|
1230 |
|
1231 |
+
$fieldMappings = array(
|
1232 |
+
'merchant_id' => 'SellerId',
|
1233 |
+
'amazon_provider_credit_id' => 'AmazonProviderCreditId',
|
1234 |
+
'mws_auth_token' => 'MWSAuthToken'
|
1235 |
+
);
|
1236 |
|
1237 |
+
$responseObject = $this->setParametersAndPost($parameters, $fieldMappings, $requestParameters);
|
1238 |
|
1239 |
+
return ($responseObject);
|
1240 |
+
}
|
1241 |
|
1242 |
+
/* GetProviderCreditReversalDetails API Call - Get details of the Provider Credit Reversal.
|
1243 |
+
*
|
1244 |
+
* @param requestParameters['merchant_id'] - [String]
|
1245 |
+
* @param requestParameters['amazon_provider_credit_reversal_id'] - [String]
|
1246 |
+
* @optional requestParameters['mws_auth_token'] - [String]
|
1247 |
+
*/
|
1248 |
|
1249 |
+
public function getProviderCreditReversalDetails($requestParameters = array())
|
1250 |
+
{
|
1251 |
$parameters = array();
|
1252 |
+
$parameters['Action'] = 'GetProviderCreditReversalDetails';
|
1253 |
+
$requestParameters = array_change_key_case($requestParameters, CASE_LOWER);
|
1254 |
+
|
1255 |
+
$fieldMappings = array(
|
1256 |
+
'merchant_id' => 'SellerId',
|
1257 |
+
'amazon_provider_credit_reversal_id' => 'AmazonProviderCreditReversalId',
|
1258 |
+
'mws_auth_token' => 'MWSAuthToken'
|
1259 |
+
);
|
1260 |
+
|
1261 |
+
$responseObject = $this->setParametersAndPost($parameters, $fieldMappings, $requestParameters);
|
1262 |
+
|
1263 |
+
return ($responseObject);
|
1264 |
+
}
|
1265 |
+
|
1266 |
+
/* ReverseProviderCredit API Call - Reverse the Provider Credit.
|
1267 |
+
*
|
1268 |
+
* @param requestParameters['merchant_id'] - [String]
|
1269 |
+
* @param requestParameters['amazon_provider_credit_id'] - [String]
|
1270 |
+
* @optional requestParameters['credit_reversal_reference_id'] - [String]
|
1271 |
+
* @param requestParameters['credit_reversal_amount'] - [String]
|
1272 |
+
* @optional requestParameters['currency_code'] - [String]
|
1273 |
+
* @optional requestParameters['credit_reversal_note'] - [String]
|
1274 |
+
* @optional requestParameters['mws_auth_token'] - [String]
|
1275 |
+
*/
|
1276 |
+
|
1277 |
+
public function reverseProviderCredit($requestParameters = array())
|
1278 |
+
{
|
1279 |
$parameters = array();
|
1280 |
+
$parameters['Action'] = 'ReverseProviderCredit';
|
1281 |
+
$requestParameters = array_change_key_case($requestParameters, CASE_LOWER);
|
1282 |
+
|
1283 |
+
$fieldMappings = array(
|
1284 |
+
'merchant_id' => 'SellerId',
|
1285 |
+
'amazon_provider_credit_id' => 'AmazonProviderCreditId',
|
1286 |
+
'credit_reversal_reference_id' => 'CreditReversalReferenceId',
|
1287 |
+
'credit_reversal_amount' => 'CreditReversalAmount.Amount',
|
1288 |
+
'currency_code' => 'CreditReversalAmount.CurrencyCode',
|
1289 |
+
'credit_reversal_note' => 'CreditReversalNote',
|
1290 |
+
'mws_auth_token' => 'MWSAuthToken'
|
1291 |
+
);
|
1292 |
+
|
1293 |
+
$responseObject = $this->setParametersAndPost($parameters, $fieldMappings, $requestParameters);
|
1294 |
+
|
1295 |
+
return ($responseObject);
|
1296 |
+
}
|
1297 |
+
|
1298 |
+
/* Create an Array of required parameters, sort them
|
1299 |
+
* Calculate signature and invoke the POST to the MWS Service URL
|
1300 |
+
*
|
1301 |
+
* @param AWSAccessKeyId [String]
|
1302 |
+
* @param Version [String]
|
1303 |
+
* @param SignatureMethod [String]
|
1304 |
+
* @param Timestamp [String]
|
1305 |
+
* @param Signature [String]
|
1306 |
+
*/
|
1307 |
+
|
1308 |
+
private function calculateSignatureAndParametersToString($parameters = array())
|
1309 |
+
{
|
1310 |
+
$parameters['AWSAccessKeyId'] = $this->config['access_key'];
|
1311 |
+
$parameters['Version'] = self::SERVICE_VERSION;
|
1312 |
+
$parameters['SignatureMethod'] = 'HmacSHA256';
|
1313 |
+
$parameters['SignatureVersion'] = 2;
|
1314 |
+
$parameters['Timestamp'] = $this->getFormattedTimestamp();
|
1315 |
+
uksort($parameters, 'strcmp');
|
1316 |
+
|
1317 |
+
$this->createServiceUrl();
|
1318 |
+
|
1319 |
+
$parameters['Signature'] = $this->signParameters($parameters);
|
1320 |
+
$parameters = $this->getParametersAsString($parameters);
|
1321 |
|
1322 |
// Save these parameters in the parameters variable so that it can be returned for unit testing.
|
1323 |
$this->parameters = $parameters;
|
1324 |
+
return $parameters;
|
1325 |
+
}
|
1326 |
+
|
1327 |
+
/* Computes RFC 2104-compliant HMAC signature for request parameters
|
1328 |
+
* Implements AWS Signature, as per following spec:
|
1329 |
+
*
|
1330 |
+
* If Signature Version is 0, it signs concatenated Action and Timestamp
|
1331 |
+
*
|
1332 |
+
* If Signature Version is 1, it performs the following:
|
1333 |
+
*
|
1334 |
+
* Sorts all parameters (including SignatureVersion and excluding Signature,
|
1335 |
+
* the value of which is being created), ignoring case.
|
1336 |
+
*
|
1337 |
+
* Iterate over the sorted list and append the parameter name (in original case)
|
1338 |
+
* and then its value. It will not URL-encode the parameter values before
|
1339 |
+
* constructing this string. There are no separators.
|
1340 |
+
*
|
1341 |
+
* If Signature Version is 2, string to sign is based on following:
|
1342 |
+
*
|
1343 |
+
* 1. The HTTP Request Method followed by an ASCII newline (%0A)
|
1344 |
+
* 2. The HTTP Host header in the form of lowercase host, followed by an ASCII newline.
|
1345 |
+
* 3. The URL encoded HTTP absolute path component of the URI
|
1346 |
+
* (up to but not including the query string parameters);
|
1347 |
+
* if this is empty use a forward '/'. This parameter is followed by an ASCII newline.
|
1348 |
+
* 4. The concatenation of all query string components (names and values)
|
1349 |
+
* as UTF-8 characters which are URL encoded as per RFC 3986
|
1350 |
+
* (hex characters MUST be uppercase), sorted using lexicographic byte ordering.
|
1351 |
+
* Parameter names are separated from their values by the '=' character
|
1352 |
+
* (ASCII character 61), even if the value is empty.
|
1353 |
+
* Pairs of parameter and values are separated by the '&' character (ASCII code 38).
|
1354 |
+
*
|
1355 |
+
*/
|
1356 |
+
|
1357 |
+
private function signParameters(array $parameters)
|
1358 |
+
{
|
1359 |
+
$signatureVersion = $parameters['SignatureVersion'];
|
1360 |
+
$algorithm = "HmacSHA1";
|
1361 |
+
$stringToSign = null;
|
1362 |
+
if (2 === $signatureVersion) {
|
1363 |
+
$algorithm = "HmacSHA256";
|
1364 |
+
$parameters['SignatureMethod'] = $algorithm;
|
1365 |
+
$stringToSign = $this->calculateStringToSignV2($parameters);
|
1366 |
+
} else {
|
1367 |
+
throw new \Exception("Invalid Signature Version specified");
|
1368 |
+
}
|
1369 |
+
|
1370 |
+
return $this->sign($stringToSign, $algorithm);
|
1371 |
+
}
|
1372 |
+
|
1373 |
+
/* Calculate String to Sign for SignatureVersion 2
|
1374 |
+
* @param array $parameters request parameters
|
1375 |
+
* @return String to Sign
|
1376 |
+
*/
|
1377 |
+
|
1378 |
+
private function calculateStringToSignV2(array $parameters)
|
1379 |
+
{
|
1380 |
+
$data = 'POST';
|
1381 |
+
$data .= "\n";
|
1382 |
+
$data .= $this->mwsEndpointUrl;
|
1383 |
+
$data .= "\n";
|
1384 |
+
$data .= $this->mwsEndpointPath;
|
1385 |
+
$data .= "\n";
|
1386 |
+
$data .= $this->getParametersAsString($parameters);
|
1387 |
+
return $data;
|
1388 |
+
}
|
1389 |
+
|
1390 |
+
/* Convert paremeters to Url encoded query string */
|
1391 |
+
|
1392 |
+
private function getParametersAsString(array $parameters)
|
1393 |
+
{
|
1394 |
+
$queryParameters = array();
|
1395 |
+
foreach ($parameters as $key => $value) {
|
1396 |
+
$queryParameters[] = $key . '=' . $this->urlEncode($value);
|
1397 |
+
}
|
1398 |
+
|
1399 |
+
return implode('&', $queryParameters);
|
1400 |
+
}
|
1401 |
+
|
1402 |
+
private function urlEncode($value)
|
1403 |
+
{
|
1404 |
+
return str_replace('%7E', '~', rawurlencode($value));
|
1405 |
+
}
|
1406 |
+
|
1407 |
+
/* Computes RFC 2104-compliant HMAC signature */
|
1408 |
+
|
1409 |
+
private function sign($data, $algorithm)
|
1410 |
+
{
|
1411 |
+
if ($algorithm === 'HmacSHA1') {
|
1412 |
+
$hash = 'sha1';
|
1413 |
+
} else if ($algorithm === 'HmacSHA256') {
|
1414 |
+
$hash = 'sha256';
|
1415 |
+
} else {
|
1416 |
+
throw new \Exception("Non-supported signing method specified");
|
1417 |
+
}
|
1418 |
+
|
1419 |
+
return base64_encode(hash_hmac($hash, $data, $this->config['secret_key'], true));
|
1420 |
+
}
|
1421 |
+
|
1422 |
+
/* Formats date as ISO 8601 timestamp */
|
1423 |
+
|
1424 |
+
private function getFormattedTimestamp()
|
1425 |
+
{
|
1426 |
+
return gmdate("Y-m-d\TH:i:s.\\0\\0\\0\\Z", time());
|
1427 |
+
}
|
1428 |
+
|
1429 |
+
/* invokePost takes the parameters and invokes the httpPost function to POST the parameters
|
1430 |
+
* Exponential retries on error 500 and 503
|
1431 |
+
* The response from the POST is an XML which is converted to Array
|
1432 |
+
*/
|
1433 |
+
|
1434 |
+
private function invokePost($parameters)
|
1435 |
+
{
|
1436 |
+
$response = array();
|
1437 |
+
$statusCode = 200;
|
1438 |
+
$this->success = false;
|
1439 |
|
1440 |
// Submit the request and read response body
|
1441 |
try {
|
1442 |
+
$shouldRetry = true;
|
1443 |
+
$retries = 0;
|
1444 |
+
do {
|
1445 |
+
try {
|
1446 |
+
$this->constructUserAgentHeader();
|
1447 |
|
1448 |
+
$httpCurlRequest = new HttpCurl($this->config);
|
1449 |
+
$response = $httpCurlRequest->httpPost($this->mwsServiceUrl, $this->userAgent, $parameters);
|
1450 |
|
1451 |
+
// Split the API response into Response Body and the other parts of the response into other
|
1452 |
+
list($other, $responseBody) = explode("\r\n\r\n", $response, 2);
|
1453 |
+
$other = preg_split("/\r\n|\n|\r/", $other);
|
1454 |
|
1455 |
+
list($protocol, $code, $text) = explode(' ', trim(array_shift($other)), 3);
|
1456 |
+
$response = array(
|
1457 |
+
'Status' => (int) $code,
|
1458 |
+
'ResponseBody' => $responseBody
|
1459 |
+
);
|
1460 |
|
1461 |
+
$statusCode = $response['Status'];
|
1462 |
|
1463 |
+
if ($statusCode == 200) {
|
1464 |
+
$shouldRetry = false;
|
1465 |
+
$this->success = true;
|
1466 |
+
} elseif ($statusCode == 500 || $statusCode == 503) {
|
1467 |
|
1468 |
$shouldRetry = true;
|
1469 |
+
if ($shouldRetry && strtolower($this->config['handle_throttle'])) {
|
1470 |
+
$this->pauseOnRetry(++$retries, $statusCode);
|
1471 |
+
}
|
1472 |
+
} else {
|
1473 |
+
$shouldRetry = false;
|
1474 |
+
}
|
1475 |
+
} catch (\Exception $e) {
|
1476 |
+
throw $e;
|
1477 |
+
}
|
1478 |
+
} while ($shouldRetry);
|
1479 |
+
} catch (\Exception $se) {
|
1480 |
+
throw $se;
|
1481 |
+
}
|
1482 |
+
|
1483 |
+
return $response;
|
1484 |
+
}
|
1485 |
+
|
1486 |
+
/* Exponential sleep on failed request
|
1487 |
+
* @param retries current retry
|
1488 |
+
* @throws Exception if maximum number of retries has been reached
|
1489 |
+
*/
|
1490 |
+
|
1491 |
+
private function pauseOnRetry($retries, $status)
|
1492 |
+
{
|
1493 |
+
if ($retries <= self::MAX_ERROR_RETRY) {
|
1494 |
+
$delay = (int) (pow(4, $retries) * 100000);
|
1495 |
+
usleep($delay);
|
1496 |
+
} else {
|
1497 |
+
throw new \Exception('Error Code: '. $status.PHP_EOL.'Maximum number of retry attempts - '. $retries .' reached');
|
1498 |
+
}
|
1499 |
+
}
|
1500 |
+
|
1501 |
+
/* Create MWS service URL and the Endpoint path */
|
1502 |
+
|
1503 |
+
private function createServiceUrl()
|
1504 |
+
{
|
1505 |
+
$this->modePath = strtolower($this->config['sandbox']) ? 'OffAmazonPayments_Sandbox' : 'OffAmazonPayments';
|
1506 |
+
|
1507 |
+
if (!empty($this->config['region'])) {
|
1508 |
+
$region = strtolower($this->config['region']);
|
1509 |
+
if (array_key_exists($region, $this->regionMappings)) {
|
1510 |
+
$this->mwsEndpointUrl = $this->mwsServiceUrls[$this->regionMappings[$region]];
|
1511 |
+
$this->mwsServiceUrl = 'https://' . $this->mwsEndpointUrl . '/' . $this->modePath . '/' . self::SERVICE_VERSION;
|
1512 |
+
$this->mwsEndpointPath = '/' . $this->modePath . '/' . self::SERVICE_VERSION;
|
1513 |
+
} else {
|
1514 |
+
throw new \Exception($region . ' is not a valid region');
|
1515 |
+
}
|
1516 |
+
} else {
|
1517 |
+
throw new \Exception("config['region'] is a required parameter and is not set");
|
1518 |
+
}
|
1519 |
+
}
|
1520 |
+
|
1521 |
+
/* Based on the config['region'] and config['sandbox'] values get the user profile URL */
|
1522 |
+
|
1523 |
+
private function profileEndpointUrl()
|
1524 |
+
{
|
1525 |
+
if (!empty($this->config['region'])) {
|
1526 |
+
$region = strtolower($this->config['region']);
|
1527 |
+
|
1528 |
+
if (array_key_exists($region, $this->sandboxProfileEndpoint) && $this->config['sandbox'] ) {
|
1529 |
+
$this->profileEndpoint = $this->sandboxProfileEndpoint[$region];
|
1530 |
+
} elseif (array_key_exists($region, $this->liveProfileEndpoint)) {
|
1531 |
$this->profileEndpoint = $this->liveProfileEndpoint[$region];
|
1532 |
+
} else{
|
1533 |
throw new \Exception($region . ' is not a valid region');
|
1534 |
+
}
|
1535 |
} else {
|
1536 |
+
throw new \Exception("config['region'] is a required parameter and is not set");
|
1537 |
+
}
|
1538 |
+
}
|
1539 |
+
|
1540 |
+
/* Create the User Agent Header sent with the POST request */
|
1541 |
+
|
1542 |
+
private function constructUserAgentHeader()
|
1543 |
+
{
|
1544 |
+
$this->userAgent = $this->quoteApplicationName($this->config['application_name']) . '/' . $this->quoteApplicationVersion($this->config['application_version']);
|
1545 |
+
$this->userAgent .= ' (';
|
1546 |
+
$this->userAgent .= 'Language=PHP/' . phpversion();
|
1547 |
+
$this->userAgent .= '; ';
|
1548 |
+
$this->userAgent .= 'Platform=' . php_uname('s') . '/' . php_uname('m') . '/' . php_uname('r');
|
1549 |
+
$this->userAgent .= '; ';
|
1550 |
+
$this->userAgent .= 'MWSClientVersion=' . self::MWS_CLIENT_VERSION;
|
1551 |
+
$this->userAgent .= ')';
|
1552 |
+
}
|
1553 |
+
|
1554 |
+
/* Collapse multiple whitespace characters into a single ' ' and backslash escape '\',
|
1555 |
+
* and '/' characters from a string.
|
1556 |
+
* @param $s
|
1557 |
+
* @return string
|
1558 |
+
*/
|
1559 |
+
|
1560 |
+
private function quoteApplicationName($s)
|
1561 |
+
{
|
1562 |
+
$quotedString = preg_replace('/ {2,}|\s/', ' ', $s);
|
1563 |
+
$quotedString = preg_replace('/\\\\/', '\\\\\\\\', $quotedString);
|
1564 |
+
$quotedString = preg_replace('/\//', '\\/', $quotedString);
|
1565 |
+
return $quotedString;
|
1566 |
+
}
|
1567 |
+
|
1568 |
+
/* Collapse multiple whitespace characters into a single ' ' and backslash escape '\',
|
1569 |
+
* and '(' characters from a string.
|
1570 |
+
*
|
1571 |
+
* @param $s
|
1572 |
+
* @return string
|
1573 |
+
*/
|
1574 |
+
|
1575 |
+
private function quoteApplicationVersion($s)
|
1576 |
+
{
|
1577 |
+
$quotedString = preg_replace('/ {2,}|\s/', ' ', $s);
|
1578 |
+
$quotedString = preg_replace('/\\\\/', '\\\\\\\\', $quotedString);
|
1579 |
+
$quotedString = preg_replace('/\\(/', '\\(', $quotedString);
|
1580 |
+
return $quotedString;
|
1581 |
+
}
|
1582 |
}
|
includes/gateways/libs/amazon/HttpCurl.php
CHANGED
@@ -1,6 +1,9 @@
|
|
1 |
<?php
|
2 |
namespace PayWithAmazon;
|
3 |
|
|
|
|
|
|
|
4 |
/* Class HttpCurl
|
5 |
* Handles Curl POST function for all requests
|
6 |
*/
|
@@ -12,25 +15,25 @@ class HttpCurl implements HttpCurlInterface
|
|
12 |
private $config = array();
|
13 |
private $header = false;
|
14 |
private $accessToken = null;
|
15 |
-
|
16 |
/* Takes user configuration array as input
|
17 |
* Takes configuration for API call or IPN config
|
18 |
*/
|
19 |
-
|
20 |
public function __construct($config = null)
|
21 |
{
|
22 |
$this->config = $config;
|
23 |
}
|
24 |
-
|
25 |
/* Setter for boolean header to get the user info */
|
26 |
-
|
27 |
public function setHttpHeader()
|
28 |
{
|
29 |
$this->header = true;
|
30 |
}
|
31 |
-
|
32 |
/* Setter for Access token to get the user info */
|
33 |
-
|
34 |
public function setAccessToken($accesstoken)
|
35 |
{
|
36 |
$this->accessToken = $accesstoken;
|
@@ -44,7 +47,7 @@ class HttpCurl implements HttpCurlInterface
|
|
44 |
* config['proxy_username']
|
45 |
* config['proxy_password']
|
46 |
*/
|
47 |
-
|
48 |
private function commonCurlParams($url,$userAgent)
|
49 |
{
|
50 |
$ch = curl_init();
|
@@ -53,65 +56,65 @@ class HttpCurl implements HttpCurlInterface
|
|
53 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
54 |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
55 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
56 |
-
|
57 |
if (!is_null($this->config['cabundle_file'])) {
|
58 |
curl_setopt($ch, CURLOPT_CAINFO, $this->config['cabundle_file']);
|
59 |
}
|
60 |
-
|
61 |
if (!empty($userAgent))
|
62 |
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
|
63 |
-
|
64 |
if ($this->config['proxy_host'] != null && $this->config['proxy_port'] != -1) {
|
65 |
curl_setopt($ch, CURLOPT_PROXY, $this->config['proxy_host'] . ':' . $this->config['proxy_port']);
|
66 |
}
|
67 |
-
|
68 |
if ($this->config['proxy_username'] != null && $this->config['proxy_password'] != null) {
|
69 |
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $this->config['proxy_username'] . ':' . $this->config['proxy_password']);
|
70 |
}
|
71 |
-
|
72 |
return $ch;
|
73 |
}
|
74 |
-
|
75 |
/* POST using curl for the following situations
|
76 |
* 1. API calls
|
77 |
* 2. IPN certificate retrieval
|
78 |
* 3. Get User Info
|
79 |
*/
|
80 |
-
|
81 |
public function httpPost($url, $userAgent = null, $parameters = null)
|
82 |
{
|
83 |
$ch = $this->commonCurlParams($url,$userAgent);
|
84 |
-
|
85 |
curl_setopt($ch, CURLOPT_POST, true);
|
86 |
curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters);
|
87 |
curl_setopt($ch, CURLOPT_HEADER, true);
|
88 |
-
|
89 |
$response = $this->execute($ch);
|
90 |
return $response;
|
91 |
}
|
92 |
-
|
93 |
/* GET using curl for the following situations
|
94 |
* 1. IPN certificate retrieval
|
95 |
* 2. Get User Info
|
96 |
*/
|
97 |
-
|
98 |
public function httpGet($url, $userAgent = null)
|
99 |
{
|
100 |
$ch = $this->commonCurlParams($url,$userAgent);
|
101 |
-
|
102 |
// Setting the HTTP header with the Access Token only for Getting user info
|
103 |
if ($this->header) {
|
104 |
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
105 |
'Authorization: bearer ' . $this->accessToken
|
106 |
));
|
107 |
}
|
108 |
-
|
109 |
$response = $this->execute($ch);
|
110 |
return $response;
|
111 |
}
|
112 |
-
|
113 |
/* Execute Curl request */
|
114 |
-
|
115 |
private function execute($ch)
|
116 |
{
|
117 |
$response = '';
|
1 |
<?php
|
2 |
namespace PayWithAmazon;
|
3 |
|
4 |
+
// Exit if accessed directly
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
/* Class HttpCurl
|
8 |
* Handles Curl POST function for all requests
|
9 |
*/
|
15 |
private $config = array();
|
16 |
private $header = false;
|
17 |
private $accessToken = null;
|
18 |
+
|
19 |
/* Takes user configuration array as input
|
20 |
* Takes configuration for API call or IPN config
|
21 |
*/
|
22 |
+
|
23 |
public function __construct($config = null)
|
24 |
{
|
25 |
$this->config = $config;
|
26 |
}
|
27 |
+
|
28 |
/* Setter for boolean header to get the user info */
|
29 |
+
|
30 |
public function setHttpHeader()
|
31 |
{
|
32 |
$this->header = true;
|
33 |
}
|
34 |
+
|
35 |
/* Setter for Access token to get the user info */
|
36 |
+
|
37 |
public function setAccessToken($accesstoken)
|
38 |
{
|
39 |
$this->accessToken = $accesstoken;
|
47 |
* config['proxy_username']
|
48 |
* config['proxy_password']
|
49 |
*/
|
50 |
+
|
51 |
private function commonCurlParams($url,$userAgent)
|
52 |
{
|
53 |
$ch = curl_init();
|
56 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
57 |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
58 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
59 |
+
|
60 |
if (!is_null($this->config['cabundle_file'])) {
|
61 |
curl_setopt($ch, CURLOPT_CAINFO, $this->config['cabundle_file']);
|
62 |
}
|
63 |
+
|
64 |
if (!empty($userAgent))
|
65 |
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
|
66 |
+
|
67 |
if ($this->config['proxy_host'] != null && $this->config['proxy_port'] != -1) {
|
68 |
curl_setopt($ch, CURLOPT_PROXY, $this->config['proxy_host'] . ':' . $this->config['proxy_port']);
|
69 |
}
|
70 |
+
|
71 |
if ($this->config['proxy_username'] != null && $this->config['proxy_password'] != null) {
|
72 |
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $this->config['proxy_username'] . ':' . $this->config['proxy_password']);
|
73 |
}
|
74 |
+
|
75 |
return $ch;
|
76 |
}
|
77 |
+
|
78 |
/* POST using curl for the following situations
|
79 |
* 1. API calls
|
80 |
* 2. IPN certificate retrieval
|
81 |
* 3. Get User Info
|
82 |
*/
|
83 |
+
|
84 |
public function httpPost($url, $userAgent = null, $parameters = null)
|
85 |
{
|
86 |
$ch = $this->commonCurlParams($url,$userAgent);
|
87 |
+
|
88 |
curl_setopt($ch, CURLOPT_POST, true);
|
89 |
curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters);
|
90 |
curl_setopt($ch, CURLOPT_HEADER, true);
|
91 |
+
|
92 |
$response = $this->execute($ch);
|
93 |
return $response;
|
94 |
}
|
95 |
+
|
96 |
/* GET using curl for the following situations
|
97 |
* 1. IPN certificate retrieval
|
98 |
* 2. Get User Info
|
99 |
*/
|
100 |
+
|
101 |
public function httpGet($url, $userAgent = null)
|
102 |
{
|
103 |
$ch = $this->commonCurlParams($url,$userAgent);
|
104 |
+
|
105 |
// Setting the HTTP header with the Access Token only for Getting user info
|
106 |
if ($this->header) {
|
107 |
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
108 |
'Authorization: bearer ' . $this->accessToken
|
109 |
));
|
110 |
}
|
111 |
+
|
112 |
$response = $this->execute($ch);
|
113 |
return $response;
|
114 |
}
|
115 |
+
|
116 |
/* Execute Curl request */
|
117 |
+
|
118 |
private function execute($ch)
|
119 |
{
|
120 |
$response = '';
|
includes/gateways/libs/amazon/Interface.php
CHANGED
@@ -1,6 +1,9 @@
|
|
1 |
<?php
|
2 |
namespace PayWithAmazon;
|
3 |
|
|
|
|
|
|
|
4 |
/* Interface class to showcase the public API methods for Pay With Amazon */
|
5 |
|
6 |
interface ClientInterface
|
@@ -9,21 +12,21 @@ interface ClientInterface
|
|
9 |
* Takes JSON file path with configuration information as input
|
10 |
* Validates the user configuation array against existing config array
|
11 |
*/
|
12 |
-
|
13 |
public function __construct($config = null);
|
14 |
-
|
15 |
/* Setter for sandbox
|
16 |
* Sets the boolean value for config['sandbox'] variable
|
17 |
*/
|
18 |
-
|
19 |
public function setSandbox($value);
|
20 |
-
|
21 |
/* Setter for config['client_id']
|
22 |
* Sets the value for config['client_id'] variable
|
23 |
*/
|
24 |
-
|
25 |
public function setClientId($value);
|
26 |
-
|
27 |
/* Setter for Proxy
|
28 |
* input $proxy [array]
|
29 |
* @param $proxy['proxy_user_host'] - hostname for the proxy
|
@@ -31,35 +34,35 @@ interface ClientInterface
|
|
31 |
* @param $proxy['proxy_user_name'] - if your proxy required a username
|
32 |
* @param $proxy['proxy_user_password'] - if your proxy required a passowrd
|
33 |
*/
|
34 |
-
|
35 |
public function setProxy($proxy);
|
36 |
-
|
37 |
/* Setter for $_mwsServiceUrl
|
38 |
-
* Set the URL to which the post request has to be made for unit testing
|
39 |
*/
|
40 |
-
|
41 |
public function setMwsServiceUrl($url);
|
42 |
-
|
43 |
/* Getter
|
44 |
* Gets the value for the key if the key exists in config
|
45 |
*/
|
46 |
-
|
47 |
public function __get($name);
|
48 |
-
|
49 |
/* Getter for parameters string
|
50 |
* Gets the value for the parameters string for unit testing
|
51 |
*/
|
52 |
-
|
53 |
public function getParameters();
|
54 |
-
|
55 |
/* GetUserInfo convenience funtion - Returns user's profile information from Amazon using the access token returned by the Button widget.
|
56 |
*
|
57 |
* @see http://docs.developer.amazonservices.com/en_US/apa_guide/APAGuide_ObtainProfile.html
|
58 |
* @param $access_token [String]
|
59 |
*/
|
60 |
-
|
61 |
public function getUserInfo($access_token);
|
62 |
-
|
63 |
/* GetOrderReferenceDetails API call - Returns details about the Order Reference object and its current state.
|
64 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetOrderReferenceDetails.html
|
65 |
*
|
@@ -68,9 +71,9 @@ interface ClientInterface
|
|
68 |
* @optional requestParameters['address_consent_token'] - [String]
|
69 |
* @optional requestParameters['mws_auth_token'] - [String]
|
70 |
*/
|
71 |
-
|
72 |
public function getOrderReferenceDetails($requestParameters = array());
|
73 |
-
|
74 |
/* SetOrderReferenceDetails API call - Sets order reference details such as the order total and a description for the order.
|
75 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_SetOrderReferenceDetails.html
|
76 |
*
|
@@ -85,19 +88,19 @@ interface ClientInterface
|
|
85 |
* @optional requestParameters['custom_information'] - [String]
|
86 |
* @optional requestParameters['mws_auth_token'] - [String]
|
87 |
*/
|
88 |
-
|
89 |
public function setOrderReferenceDetails($requestParameters = array());
|
90 |
-
|
91 |
/* ConfirmOrderReferenceDetails API call - Confirms that the order reference is free of constraints and all required information has been set on the order reference.
|
92 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_ConfirmOrderReference.html
|
93 |
-
|
94 |
* @param requestParameters['merchant_id'] - [String]
|
95 |
* @param requestParameters['amazon_order_reference_id'] - [String]
|
96 |
* @optional requestParameters['mws_auth_token'] - [String]
|
97 |
*/
|
98 |
-
|
99 |
public function confirmOrderReference($requestParameters = array());
|
100 |
-
|
101 |
/* CancelOrderReferenceDetails API call - Cancels a previously confirmed order reference.
|
102 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_CancelOrderReference.html
|
103 |
*
|
@@ -106,9 +109,9 @@ interface ClientInterface
|
|
106 |
* @optional requestParameters['cancelation_reason'] [String]
|
107 |
* @optional requestParameters['mws_auth_token'] - [String]
|
108 |
*/
|
109 |
-
|
110 |
public function cancelOrderReference($requestParameters = array());
|
111 |
-
|
112 |
/* CloseOrderReferenceDetails API call - Confirms that an order reference has been fulfilled (fully or partially)
|
113 |
* and that you do not expect to create any new authorizations on this order reference.
|
114 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_CloseOrderReference.html
|
@@ -118,9 +121,9 @@ interface ClientInterface
|
|
118 |
* @optional requestParameters['closure_reason'] [String]
|
119 |
* @optional requestParameters['mws_auth_token'] - [String]
|
120 |
*/
|
121 |
-
|
122 |
public function closeOrderReference($requestParameters = array());
|
123 |
-
|
124 |
/* CloseAuthorization API call - Closes an authorization.
|
125 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_CloseOrderReference.html
|
126 |
*
|
@@ -129,9 +132,9 @@ interface ClientInterface
|
|
129 |
* @optional requestParameters['closure_reason'] [String]
|
130 |
* @optional requestParameters['mws_auth_token'] - [String]
|
131 |
*/
|
132 |
-
|
133 |
public function closeAuthorization($requestParameters = array());
|
134 |
-
|
135 |
/* Authorize API call - Reserves a specified amount against the payment method(s) stored in the order reference.
|
136 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_Authorize.html
|
137 |
*
|
@@ -147,9 +150,9 @@ interface ClientInterface
|
|
147 |
* @optional requestParameters['soft_descriptor'] - [String]
|
148 |
* @optional requestParameters['mws_auth_token'] - [String]
|
149 |
*/
|
150 |
-
|
151 |
public function authorize($requestParameters = array());
|
152 |
-
|
153 |
/* GetAuthorizationDetails API call - Returns the status of a particular authorization and the total amount captured on the authorization.
|
154 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetAuthorizationDetails.html
|
155 |
*
|
@@ -157,9 +160,9 @@ interface ClientInterface
|
|
157 |
* @param requestParameters['amazon_authorization_id'] [String]
|
158 |
* @optional requestParameters['mws_auth_token'] - [String]
|
159 |
*/
|
160 |
-
|
161 |
public function getAuthorizationDetails($requestParameters = array());
|
162 |
-
|
163 |
/* Capture API call - Captures funds from an authorized payment instrument.
|
164 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_Capture.html
|
165 |
*
|
@@ -173,9 +176,9 @@ interface ClientInterface
|
|
173 |
* @optional requestParameters['soft_descriptor'] - [String]
|
174 |
* @optional requestParameters['mws_auth_token'] - [String]
|
175 |
*/
|
176 |
-
|
177 |
public function capture($requestParameters = array());
|
178 |
-
|
179 |
/* GetCaptureDetails API call - Returns the status of a particular capture and the total amount refunded on the capture.
|
180 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetCaptureDetails.html
|
181 |
*
|
@@ -183,9 +186,9 @@ interface ClientInterface
|
|
183 |
* @param requestParameters['amazon_capture_id'] - [String]
|
184 |
* @optional requestParameters['mws_auth_token'] - [String]
|
185 |
*/
|
186 |
-
|
187 |
public function getCaptureDetails($requestParameters = array());
|
188 |
-
|
189 |
/* Refund API call - Refunds a previously captured amount.
|
190 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_Refund.html
|
191 |
*
|
@@ -199,9 +202,9 @@ interface ClientInterface
|
|
199 |
* @optional requestParameters['soft_descriptor'] - [String]
|
200 |
* @optional requestParameters['mws_auth_token'] - [String]
|
201 |
*/
|
202 |
-
|
203 |
public function refund($requestParameters = array());
|
204 |
-
|
205 |
/* GetRefundDetails API call - Returns the status of a particular refund.
|
206 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetRefundDetails.html
|
207 |
*
|
@@ -209,9 +212,9 @@ interface ClientInterface
|
|
209 |
* @param requestParameters['amazon_refund_id'] - [String]
|
210 |
* @optional requestParameters['mws_auth_token'] - [String]
|
211 |
*/
|
212 |
-
|
213 |
public function getRefundDetails($requestParameters = array());
|
214 |
-
|
215 |
/* GetServiceStatus API Call - Returns the operational status of the Off-Amazon Payments API section
|
216 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetServiceStatus.html
|
217 |
*
|
@@ -222,9 +225,9 @@ interface ClientInterface
|
|
222 |
* @param requestParameters['merchant_id'] - [String]
|
223 |
* @optional requestParameters['mws_auth_token'] - [String]
|
224 |
*/
|
225 |
-
|
226 |
public function getServiceStatus($requestParameters = array());
|
227 |
-
|
228 |
/* CreateOrderReferenceForId API Call - Creates an order reference for the given object
|
229 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_CreateOrderReferenceForId.html
|
230 |
*
|
@@ -232,7 +235,7 @@ interface ClientInterface
|
|
232 |
* @param requestParameters['Id'] - [String]
|
233 |
* @optional requestParameters['inherit_shipping_address'] [Boolean]
|
234 |
* @optional requestParameters['ConfirmNow'] - [Boolean]
|
235 |
-
* @optional Amount (required when confirm_now is set to true) [String]
|
236 |
* @optional requestParameters['currency_code'] - [String]
|
237 |
* @optional requestParameters['seller_note'] - [String]
|
238 |
* @optional requestParameters['seller_order_id'] - [String]
|
@@ -240,9 +243,9 @@ interface ClientInterface
|
|
240 |
* @optional requestParameters['custom_information'] - [String]
|
241 |
* @optional requestParameters['mws_auth_token'] - [String]
|
242 |
*/
|
243 |
-
|
244 |
public function createOrderReferenceForId($requestParameters = array());
|
245 |
-
|
246 |
/* GetBillingAgreementDetails API Call - Returns details about the Billing Agreement object and its current state.
|
247 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetBillingAgreementDetails.html
|
248 |
*
|
@@ -250,9 +253,9 @@ interface ClientInterface
|
|
250 |
* @param requestParameters['amazon_billing_agreement_id'] - [String]
|
251 |
* @optional requestParameters['mws_auth_token'] - [String]
|
252 |
*/
|
253 |
-
|
254 |
public function getBillingAgreementDetails($requestParameters = array());
|
255 |
-
|
256 |
/* SetBillingAgreementDetails API call - Sets Billing Agreement details such as a description of the agreement and other information about the seller.
|
257 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_SetBillingAgreementDetails.html
|
258 |
*
|
@@ -267,9 +270,9 @@ interface ClientInterface
|
|
267 |
* @optional requestParameters['custom_information'] - [String]
|
268 |
* @optional requestParameters['mws_auth_token'] - [String]
|
269 |
*/
|
270 |
-
|
271 |
public function setBillingAgreementDetails($requestParameters = array());
|
272 |
-
|
273 |
/* ConfirmBillingAgreement API Call - Confirms that the Billing Agreement is free of constraints and all required information has been set on the Billing Agreement.
|
274 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_ConfirmBillingAgreement.html
|
275 |
*
|
@@ -277,9 +280,9 @@ interface ClientInterface
|
|
277 |
* @param requestParameters['amazon_billing_agreement_id'] - [String]
|
278 |
* @optional requestParameters['mws_auth_token'] - [String]
|
279 |
*/
|
280 |
-
|
281 |
public function confirmBillingAgreement($requestParameters = array());
|
282 |
-
|
283 |
/* ValidateBillingAgreement API Call - Validates the status of the Billing Agreement object and the payment method associated with it.
|
284 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_ValidateBillignAgreement.html
|
285 |
*
|
@@ -287,9 +290,9 @@ interface ClientInterface
|
|
287 |
* @param requestParameters['amazon_billing_agreement_id'] - [String]
|
288 |
* @optional requestParameters['mws_auth_token'] - [String]
|
289 |
*/
|
290 |
-
|
291 |
public function validateBillingAgreement($requestParameters = array());
|
292 |
-
|
293 |
/* AuthorizeOnBillingAgreement API call - Reserves a specified amount against the payment method(s) stored in the Billing Agreement.
|
294 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_AuthorizeOnBillingAgreement.html
|
295 |
*
|
@@ -310,9 +313,9 @@ interface ClientInterface
|
|
310 |
* @optional requestParameters['inherit_shipping_address'] [Boolean] - Defaults to true
|
311 |
* @optional requestParameters['mws_auth_token'] - [String]
|
312 |
*/
|
313 |
-
|
314 |
public function authorizeOnBillingAgreement($requestParameters = array());
|
315 |
-
|
316 |
/* CloseBillingAgreement API Call - Returns details about the Billing Agreement object and its current state.
|
317 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_CloseBillingAgreement.html
|
318 |
*
|
@@ -321,9 +324,9 @@ interface ClientInterface
|
|
321 |
* @optional requestParameters['closure_reason'] [String]
|
322 |
* @optional requestParameters['mws_auth_token'] - [String]
|
323 |
*/
|
324 |
-
|
325 |
public function closeBillingAgreement($requestParameters = array());
|
326 |
-
|
327 |
/* charge convenience method
|
328 |
* Performs the API calls
|
329 |
* 1. SetOrderReferenceDetails / SetBillingAgreementDetails
|
@@ -337,7 +340,7 @@ interface ClientInterface
|
|
337 |
* @param requestParameters['amazon_order_reference_id'] - [String] : Order Reference ID
|
338 |
* or,
|
339 |
* @param requestParameters['amazon_billing_agreement_id'] - [String] : Billing Agreement ID
|
340 |
-
*
|
341 |
* @param $requestParameters['charge_amount'] - [String] : Amount value to be captured
|
342 |
* @param requestParameters['currency_code'] - [String] : Currency Code for the Amount
|
343 |
* @param requestParameters['authorization_reference_id'] - [String]- Any unique string that needs to be passed
|
@@ -346,27 +349,27 @@ interface ClientInterface
|
|
346 |
* @optional requestParameters['charge_order_id'] - [String] : Custom Order ID provided
|
347 |
* @optional requestParameters['mws_auth_token'] - [String]
|
348 |
*/
|
349 |
-
|
350 |
public function charge($requestParameters = array());
|
351 |
-
|
352 |
/* GetProviderCreditDetails API Call - Get the details of the Provider Credit.
|
353 |
*
|
354 |
* @param requestParameters['merchant_id'] - [String]
|
355 |
* @param requestParameters['amazon_provider_credit_id'] - [String]
|
356 |
* @optional requestParameters['mws_auth_token'] - [String]
|
357 |
*/
|
358 |
-
|
359 |
public function getProviderCreditDetails($requestParameters = array());
|
360 |
-
|
361 |
/* GetProviderCreditReversalDetails API Call - Get details of the Provider Credit Reversal.
|
362 |
*
|
363 |
* @param requestParameters['merchant_id'] - [String]
|
364 |
* @param requestParameters['amazon_provider_credit_reversal_id'] - [String]
|
365 |
* @optional requestParameters['mws_auth_token'] - [String]
|
366 |
*/
|
367 |
-
|
368 |
public function getProviderCreditReversalDetails($requestParameters = array());
|
369 |
-
|
370 |
/* ReverseProviderCredit API Call - Reverse the Provider Credit.
|
371 |
*
|
372 |
* @param requestParameters['merchant_id'] - [String]
|
@@ -377,7 +380,7 @@ interface ClientInterface
|
|
377 |
* @optional requestParameters['credit_reversal_note'] - [String]
|
378 |
* @optional requestParameters['mws_auth_token'] - [String]
|
379 |
*/
|
380 |
-
|
381 |
public function reverseProviderCredit($requestParameters = array());
|
382 |
}
|
383 |
|
@@ -388,11 +391,11 @@ interface IpnHandlerInterface
|
|
388 |
/* Takes headers and body of the IPN message as input in the constructor
|
389 |
* verifies that the IPN is from the right resource and has the valid data
|
390 |
*/
|
391 |
-
|
392 |
public function __construct($headers, $body, $ipnConfig = null);
|
393 |
-
|
394 |
/* returnMessage() - JSON decode the raw [Message] portion of the IPN */
|
395 |
-
|
396 |
public function returnMessage();
|
397 |
|
398 |
/* toJson() - Converts IPN [Message] field to JSON
|
@@ -405,13 +408,13 @@ interface IpnHandlerInterface
|
|
405 |
* Topic ARN - Topic of the IPN
|
406 |
* @return response in JSON format
|
407 |
*/
|
408 |
-
|
409 |
public function toJson();
|
410 |
|
411 |
/* toArray() - Converts IPN [Message] field to associative array
|
412 |
* @return response in array format
|
413 |
*/
|
414 |
-
|
415 |
public function toArray();
|
416 |
}
|
417 |
|
@@ -422,30 +425,30 @@ interface HttpCurlInterface
|
|
422 |
/* Takes user configuration array as input
|
423 |
* Takes configuration for API call or IPN config
|
424 |
*/
|
425 |
-
|
426 |
public function __construct($config = null);
|
427 |
-
|
428 |
/* Set Http header for Access token for the GetUserInfo call */
|
429 |
-
|
430 |
public function setHttpHeader();
|
431 |
-
|
432 |
/* Setter for Access token to get the user info */
|
433 |
-
|
434 |
public function setAccessToken($accesstoken);
|
435 |
-
|
436 |
/* POST using curl for the following situations
|
437 |
* 1. API calls
|
438 |
* 2. IPN certificate retrieval
|
439 |
* 3. Get User Info
|
440 |
*/
|
441 |
-
|
442 |
public function httpPost($url, $userAgent = null, $parameters = null);
|
443 |
-
|
444 |
/* GET using curl for the following situations
|
445 |
* 1. IPN certificate retrieval
|
446 |
* 3. Get User Info
|
447 |
*/
|
448 |
-
|
449 |
public function httpGet($url, $userAgent = null);
|
450 |
}
|
451 |
|
@@ -454,26 +457,26 @@ interface HttpCurlInterface
|
|
454 |
interface ResponseInterface
|
455 |
{
|
456 |
/* Takes response from the API call */
|
457 |
-
|
458 |
public function __construct($response = null);
|
459 |
-
|
460 |
/* Returns the XML portion of the response */
|
461 |
-
|
462 |
public function toXml();
|
463 |
-
|
464 |
/* toJson - converts XML into Json
|
465 |
* @param $response [XML]
|
466 |
*/
|
467 |
-
|
468 |
public function toJson();
|
469 |
-
|
470 |
/* toArray - converts XML into associative array
|
471 |
* @param $this->_response [XML]
|
472 |
*/
|
473 |
-
|
474 |
public function toArray();
|
475 |
-
|
476 |
/* Get the status of the BillingAgreement */
|
477 |
-
|
478 |
public function getBillingAgreementDetailsStatus($response);
|
479 |
}
|
1 |
<?php
|
2 |
namespace PayWithAmazon;
|
3 |
|
4 |
+
// Exit if accessed directly
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
/* Interface class to showcase the public API methods for Pay With Amazon */
|
8 |
|
9 |
interface ClientInterface
|
12 |
* Takes JSON file path with configuration information as input
|
13 |
* Validates the user configuation array against existing config array
|
14 |
*/
|
15 |
+
|
16 |
public function __construct($config = null);
|
17 |
+
|
18 |
/* Setter for sandbox
|
19 |
* Sets the boolean value for config['sandbox'] variable
|
20 |
*/
|
21 |
+
|
22 |
public function setSandbox($value);
|
23 |
+
|
24 |
/* Setter for config['client_id']
|
25 |
* Sets the value for config['client_id'] variable
|
26 |
*/
|
27 |
+
|
28 |
public function setClientId($value);
|
29 |
+
|
30 |
/* Setter for Proxy
|
31 |
* input $proxy [array]
|
32 |
* @param $proxy['proxy_user_host'] - hostname for the proxy
|
34 |
* @param $proxy['proxy_user_name'] - if your proxy required a username
|
35 |
* @param $proxy['proxy_user_password'] - if your proxy required a passowrd
|
36 |
*/
|
37 |
+
|
38 |
public function setProxy($proxy);
|
39 |
+
|
40 |
/* Setter for $_mwsServiceUrl
|
41 |
+
* Set the URL to which the post request has to be made for unit testing
|
42 |
*/
|
43 |
+
|
44 |
public function setMwsServiceUrl($url);
|
45 |
+
|
46 |
/* Getter
|
47 |
* Gets the value for the key if the key exists in config
|
48 |
*/
|
49 |
+
|
50 |
public function __get($name);
|
51 |
+
|
52 |
/* Getter for parameters string
|
53 |
* Gets the value for the parameters string for unit testing
|
54 |
*/
|
55 |
+
|
56 |
public function getParameters();
|
57 |
+
|
58 |
/* GetUserInfo convenience funtion - Returns user's profile information from Amazon using the access token returned by the Button widget.
|
59 |
*
|
60 |
* @see http://docs.developer.amazonservices.com/en_US/apa_guide/APAGuide_ObtainProfile.html
|
61 |
* @param $access_token [String]
|
62 |
*/
|
63 |
+
|
64 |
public function getUserInfo($access_token);
|
65 |
+
|
66 |
/* GetOrderReferenceDetails API call - Returns details about the Order Reference object and its current state.
|
67 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetOrderReferenceDetails.html
|
68 |
*
|
71 |
* @optional requestParameters['address_consent_token'] - [String]
|
72 |
* @optional requestParameters['mws_auth_token'] - [String]
|
73 |
*/
|
74 |
+
|
75 |
public function getOrderReferenceDetails($requestParameters = array());
|
76 |
+
|
77 |
/* SetOrderReferenceDetails API call - Sets order reference details such as the order total and a description for the order.
|
78 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_SetOrderReferenceDetails.html
|
79 |
*
|
88 |
* @optional requestParameters['custom_information'] - [String]
|
89 |
* @optional requestParameters['mws_auth_token'] - [String]
|
90 |
*/
|
91 |
+
|
92 |
public function setOrderReferenceDetails($requestParameters = array());
|
93 |
+
|
94 |
/* ConfirmOrderReferenceDetails API call - Confirms that the order reference is free of constraints and all required information has been set on the order reference.
|
95 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_ConfirmOrderReference.html
|
96 |
+
|
97 |
* @param requestParameters['merchant_id'] - [String]
|
98 |
* @param requestParameters['amazon_order_reference_id'] - [String]
|
99 |
* @optional requestParameters['mws_auth_token'] - [String]
|
100 |
*/
|
101 |
+
|
102 |
public function confirmOrderReference($requestParameters = array());
|
103 |
+
|
104 |
/* CancelOrderReferenceDetails API call - Cancels a previously confirmed order reference.
|
105 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_CancelOrderReference.html
|
106 |
*
|
109 |
* @optional requestParameters['cancelation_reason'] [String]
|
110 |
* @optional requestParameters['mws_auth_token'] - [String]
|
111 |
*/
|
112 |
+
|
113 |
public function cancelOrderReference($requestParameters = array());
|
114 |
+
|
115 |
/* CloseOrderReferenceDetails API call - Confirms that an order reference has been fulfilled (fully or partially)
|
116 |
* and that you do not expect to create any new authorizations on this order reference.
|
117 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_CloseOrderReference.html
|
121 |
* @optional requestParameters['closure_reason'] [String]
|
122 |
* @optional requestParameters['mws_auth_token'] - [String]
|
123 |
*/
|
124 |
+
|
125 |
public function closeOrderReference($requestParameters = array());
|
126 |
+
|
127 |
/* CloseAuthorization API call - Closes an authorization.
|
128 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_CloseOrderReference.html
|
129 |
*
|
132 |
* @optional requestParameters['closure_reason'] [String]
|
133 |
* @optional requestParameters['mws_auth_token'] - [String]
|
134 |
*/
|
135 |
+
|
136 |
public function closeAuthorization($requestParameters = array());
|
137 |
+
|
138 |
/* Authorize API call - Reserves a specified amount against the payment method(s) stored in the order reference.
|
139 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_Authorize.html
|
140 |
*
|
150 |
* @optional requestParameters['soft_descriptor'] - [String]
|
151 |
* @optional requestParameters['mws_auth_token'] - [String]
|
152 |
*/
|
153 |
+
|
154 |
public function authorize($requestParameters = array());
|
155 |
+
|
156 |
/* GetAuthorizationDetails API call - Returns the status of a particular authorization and the total amount captured on the authorization.
|
157 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetAuthorizationDetails.html
|
158 |
*
|
160 |
* @param requestParameters['amazon_authorization_id'] [String]
|
161 |
* @optional requestParameters['mws_auth_token'] - [String]
|
162 |
*/
|
163 |
+
|
164 |
public function getAuthorizationDetails($requestParameters = array());
|
165 |
+
|
166 |
/* Capture API call - Captures funds from an authorized payment instrument.
|
167 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_Capture.html
|
168 |
*
|
176 |
* @optional requestParameters['soft_descriptor'] - [String]
|
177 |
* @optional requestParameters['mws_auth_token'] - [String]
|
178 |
*/
|
179 |
+
|
180 |
public function capture($requestParameters = array());
|
181 |
+
|
182 |
/* GetCaptureDetails API call - Returns the status of a particular capture and the total amount refunded on the capture.
|
183 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetCaptureDetails.html
|
184 |
*
|
186 |
* @param requestParameters['amazon_capture_id'] - [String]
|
187 |
* @optional requestParameters['mws_auth_token'] - [String]
|
188 |
*/
|
189 |
+
|
190 |
public function getCaptureDetails($requestParameters = array());
|
191 |
+
|
192 |
/* Refund API call - Refunds a previously captured amount.
|
193 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_Refund.html
|
194 |
*
|
202 |
* @optional requestParameters['soft_descriptor'] - [String]
|
203 |
* @optional requestParameters['mws_auth_token'] - [String]
|
204 |
*/
|
205 |
+
|
206 |
public function refund($requestParameters = array());
|
207 |
+
|
208 |
/* GetRefundDetails API call - Returns the status of a particular refund.
|
209 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetRefundDetails.html
|
210 |
*
|
212 |
* @param requestParameters['amazon_refund_id'] - [String]
|
213 |
* @optional requestParameters['mws_auth_token'] - [String]
|
214 |
*/
|
215 |
+
|
216 |
public function getRefundDetails($requestParameters = array());
|
217 |
+
|
218 |
/* GetServiceStatus API Call - Returns the operational status of the Off-Amazon Payments API section
|
219 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetServiceStatus.html
|
220 |
*
|
225 |
* @param requestParameters['merchant_id'] - [String]
|
226 |
* @optional requestParameters['mws_auth_token'] - [String]
|
227 |
*/
|
228 |
+
|
229 |
public function getServiceStatus($requestParameters = array());
|
230 |
+
|
231 |
/* CreateOrderReferenceForId API Call - Creates an order reference for the given object
|
232 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_CreateOrderReferenceForId.html
|
233 |
*
|
235 |
* @param requestParameters['Id'] - [String]
|
236 |
* @optional requestParameters['inherit_shipping_address'] [Boolean]
|
237 |
* @optional requestParameters['ConfirmNow'] - [Boolean]
|
238 |
+
* @optional Amount (required when confirm_now is set to true) [String]
|
239 |
* @optional requestParameters['currency_code'] - [String]
|
240 |
* @optional requestParameters['seller_note'] - [String]
|
241 |
* @optional requestParameters['seller_order_id'] - [String]
|
243 |
* @optional requestParameters['custom_information'] - [String]
|
244 |
* @optional requestParameters['mws_auth_token'] - [String]
|
245 |
*/
|
246 |
+
|
247 |
public function createOrderReferenceForId($requestParameters = array());
|
248 |
+
|
249 |
/* GetBillingAgreementDetails API Call - Returns details about the Billing Agreement object and its current state.
|
250 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetBillingAgreementDetails.html
|
251 |
*
|
253 |
* @param requestParameters['amazon_billing_agreement_id'] - [String]
|
254 |
* @optional requestParameters['mws_auth_token'] - [String]
|
255 |
*/
|
256 |
+
|
257 |
public function getBillingAgreementDetails($requestParameters = array());
|
258 |
+
|
259 |
/* SetBillingAgreementDetails API call - Sets Billing Agreement details such as a description of the agreement and other information about the seller.
|
260 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_SetBillingAgreementDetails.html
|
261 |
*
|
270 |
* @optional requestParameters['custom_information'] - [String]
|
271 |
* @optional requestParameters['mws_auth_token'] - [String]
|
272 |
*/
|
273 |
+
|
274 |
public function setBillingAgreementDetails($requestParameters = array());
|
275 |
+
|
276 |
/* ConfirmBillingAgreement API Call - Confirms that the Billing Agreement is free of constraints and all required information has been set on the Billing Agreement.
|
277 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_ConfirmBillingAgreement.html
|
278 |
*
|
280 |
* @param requestParameters['amazon_billing_agreement_id'] - [String]
|
281 |
* @optional requestParameters['mws_auth_token'] - [String]
|
282 |
*/
|
283 |
+
|
284 |
public function confirmBillingAgreement($requestParameters = array());
|
285 |
+
|
286 |
/* ValidateBillingAgreement API Call - Validates the status of the Billing Agreement object and the payment method associated with it.
|
287 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_ValidateBillignAgreement.html
|
288 |
*
|
290 |
* @param requestParameters['amazon_billing_agreement_id'] - [String]
|
291 |
* @optional requestParameters['mws_auth_token'] - [String]
|
292 |
*/
|
293 |
+
|
294 |
public function validateBillingAgreement($requestParameters = array());
|
295 |
+
|
296 |
/* AuthorizeOnBillingAgreement API call - Reserves a specified amount against the payment method(s) stored in the Billing Agreement.
|
297 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_AuthorizeOnBillingAgreement.html
|
298 |
*
|
313 |
* @optional requestParameters['inherit_shipping_address'] [Boolean] - Defaults to true
|
314 |
* @optional requestParameters['mws_auth_token'] - [String]
|
315 |
*/
|
316 |
+
|
317 |
public function authorizeOnBillingAgreement($requestParameters = array());
|
318 |
+
|
319 |
/* CloseBillingAgreement API Call - Returns details about the Billing Agreement object and its current state.
|
320 |
* @see http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_CloseBillingAgreement.html
|
321 |
*
|
324 |
* @optional requestParameters['closure_reason'] [String]
|
325 |
* @optional requestParameters['mws_auth_token'] - [String]
|
326 |
*/
|
327 |
+
|
328 |
public function closeBillingAgreement($requestParameters = array());
|
329 |
+
|
330 |
/* charge convenience method
|
331 |
* Performs the API calls
|
332 |
* 1. SetOrderReferenceDetails / SetBillingAgreementDetails
|
340 |
* @param requestParameters['amazon_order_reference_id'] - [String] : Order Reference ID
|
341 |
* or,
|
342 |
* @param requestParameters['amazon_billing_agreement_id'] - [String] : Billing Agreement ID
|
343 |
+
*
|
344 |
* @param $requestParameters['charge_amount'] - [String] : Amount value to be captured
|
345 |
* @param requestParameters['currency_code'] - [String] : Currency Code for the Amount
|
346 |
* @param requestParameters['authorization_reference_id'] - [String]- Any unique string that needs to be passed
|
349 |
* @optional requestParameters['charge_order_id'] - [String] : Custom Order ID provided
|
350 |
* @optional requestParameters['mws_auth_token'] - [String]
|
351 |
*/
|
352 |
+
|
353 |
public function charge($requestParameters = array());
|
354 |
+
|
355 |
/* GetProviderCreditDetails API Call - Get the details of the Provider Credit.
|
356 |
*
|
357 |
* @param requestParameters['merchant_id'] - [String]
|
358 |
* @param requestParameters['amazon_provider_credit_id'] - [String]
|
359 |
* @optional requestParameters['mws_auth_token'] - [String]
|
360 |
*/
|
361 |
+
|
362 |
public function getProviderCreditDetails($requestParameters = array());
|
363 |
+
|
364 |
/* GetProviderCreditReversalDetails API Call - Get details of the Provider Credit Reversal.
|
365 |
*
|
366 |
* @param requestParameters['merchant_id'] - [String]
|
367 |
* @param requestParameters['amazon_provider_credit_reversal_id'] - [String]
|
368 |
* @optional requestParameters['mws_auth_token'] - [String]
|
369 |
*/
|
370 |
+
|
371 |
public function getProviderCreditReversalDetails($requestParameters = array());
|
372 |
+
|
373 |
/* ReverseProviderCredit API Call - Reverse the Provider Credit.
|
374 |
*
|
375 |
* @param requestParameters['merchant_id'] - [String]
|
380 |
* @optional requestParameters['credit_reversal_note'] - [String]
|
381 |
* @optional requestParameters['mws_auth_token'] - [String]
|
382 |
*/
|
383 |
+
|
384 |
public function reverseProviderCredit($requestParameters = array());
|
385 |
}
|
386 |
|
391 |
/* Takes headers and body of the IPN message as input in the constructor
|
392 |
* verifies that the IPN is from the right resource and has the valid data
|
393 |
*/
|
394 |
+
|
395 |
public function __construct($headers, $body, $ipnConfig = null);
|
396 |
+
|
397 |
/* returnMessage() - JSON decode the raw [Message] portion of the IPN */
|
398 |
+
|
399 |
public function returnMessage();
|
400 |
|
401 |
/* toJson() - Converts IPN [Message] field to JSON
|
408 |
* Topic ARN - Topic of the IPN
|
409 |
* @return response in JSON format
|
410 |
*/
|
411 |
+
|
412 |
public function toJson();
|
413 |
|
414 |
/* toArray() - Converts IPN [Message] field to associative array
|
415 |
* @return response in array format
|
416 |
*/
|
417 |
+
|
418 |
public function toArray();
|
419 |
}
|
420 |
|
425 |
/* Takes user configuration array as input
|
426 |
* Takes configuration for API call or IPN config
|
427 |
*/
|
428 |
+
|
429 |
public function __construct($config = null);
|
430 |
+
|
431 |
/* Set Http header for Access token for the GetUserInfo call */
|
432 |
+
|
433 |
public function setHttpHeader();
|
434 |
+
|
435 |
/* Setter for Access token to get the user info */
|
436 |
+
|
437 |
public function setAccessToken($accesstoken);
|
438 |
+
|
439 |
/* POST using curl for the following situations
|
440 |
* 1. API calls
|
441 |
* 2. IPN certificate retrieval
|
442 |
* 3. Get User Info
|
443 |
*/
|
444 |
+
|
445 |
public function httpPost($url, $userAgent = null, $parameters = null);
|
446 |
+
|
447 |
/* GET using curl for the following situations
|
448 |
* 1. IPN certificate retrieval
|
449 |
* 3. Get User Info
|
450 |
*/
|
451 |
+
|
452 |
public function httpGet($url, $userAgent = null);
|
453 |
}
|
454 |
|
457 |
interface ResponseInterface
|
458 |
{
|
459 |
/* Takes response from the API call */
|
460 |
+
|
461 |
public function __construct($response = null);
|
462 |
+
|
463 |
/* Returns the XML portion of the response */
|
464 |
+
|
465 |
public function toXml();
|
466 |
+
|
467 |
/* toJson - converts XML into Json
|
468 |
* @param $response [XML]
|
469 |
*/
|
470 |
+
|
471 |
public function toJson();
|
472 |
+
|
473 |
/* toArray - converts XML into associative array
|
474 |
* @param $this->_response [XML]
|
475 |
*/
|
476 |
+
|
477 |
public function toArray();
|
478 |
+
|
479 |
/* Get the status of the BillingAgreement */
|
480 |
+
|
481 |
public function getBillingAgreementDetailsStatus($response);
|
482 |
}
|
includes/gateways/libs/amazon/IpnHandler.php
CHANGED
@@ -1,6 +1,9 @@
|
|
1 |
<?php
|
2 |
namespace PayWithAmazon;
|
3 |
|
|
|
|
|
|
|
4 |
/* Class IPN_Handler
|
5 |
* Takes headers and body of the IPN message as input in the constructor
|
6 |
* verifies that the IPN is from the right resource and has the valid data
|
@@ -76,7 +79,7 @@ class IpnHandler implements IpnHandlerInterface
|
|
76 |
/* Setter function
|
77 |
* Sets the value for the key if the key exists in ipnConfig
|
78 |
*/
|
79 |
-
|
80 |
public function __set($name, $value)
|
81 |
{
|
82 |
if (array_key_exists(strtolower($name), $this->ipnConfig)) {
|
@@ -89,7 +92,7 @@ class IpnHandler implements IpnHandlerInterface
|
|
89 |
/* Getter function
|
90 |
* Returns the value for the key if the key exists in ipnConfig
|
91 |
*/
|
92 |
-
|
93 |
public function __get($name)
|
94 |
{
|
95 |
if (array_key_exists(strtolower($name), $this->ipnConfig)) {
|
@@ -100,7 +103,7 @@ class IpnHandler implements IpnHandlerInterface
|
|
100 |
}
|
101 |
|
102 |
/* Trim the input Array key values */
|
103 |
-
|
104 |
private function trimArray($array)
|
105 |
{
|
106 |
foreach ($array as $key => $value)
|
@@ -109,7 +112,7 @@ class IpnHandler implements IpnHandlerInterface
|
|
109 |
}
|
110 |
return $array;
|
111 |
}
|
112 |
-
|
113 |
private function validateHeaders()
|
114 |
{
|
115 |
// Quickly check that this is a sns message
|
@@ -140,7 +143,7 @@ class IpnHandler implements IpnHandlerInterface
|
|
140 |
*
|
141 |
* @return string error message
|
142 |
*/
|
143 |
-
|
144 |
private function getErrorMessageForJsonError($json_error)
|
145 |
{
|
146 |
switch ($json_error) {
|
@@ -217,7 +220,7 @@ class IpnHandler implements IpnHandlerInterface
|
|
217 |
*
|
218 |
* @return bool true if valid
|
219 |
*/
|
220 |
-
|
221 |
private function constructAndVerifySignature()
|
222 |
{
|
223 |
$signature = base64_decode($this->getMandatoryField("Signature"));
|
@@ -235,7 +238,7 @@ class IpnHandler implements IpnHandlerInterface
|
|
235 |
*
|
236 |
* gets the certificate from the $certificatePath using Curl
|
237 |
*/
|
238 |
-
|
239 |
private function getCertificate($certificatePath)
|
240 |
{
|
241 |
$httpCurlRequest = new HttpCurl($this->ipnConfig);
|
@@ -294,7 +297,7 @@ class IpnHandler implements IpnHandlerInterface
|
|
294 |
*
|
295 |
* @return string field contents if found
|
296 |
*/
|
297 |
-
|
298 |
private function getMandatoryField($fieldName)
|
299 |
{
|
300 |
$value = $this->getField($fieldName);
|
@@ -310,7 +313,7 @@ class IpnHandler implements IpnHandlerInterface
|
|
310 |
*
|
311 |
* @return string field contents if found, null otherwise
|
312 |
*/
|
313 |
-
|
314 |
private function getField($fieldName)
|
315 |
{
|
316 |
if (array_key_exists($fieldName, $this->snsMessage)) {
|
@@ -321,7 +324,7 @@ class IpnHandler implements IpnHandlerInterface
|
|
321 |
}
|
322 |
|
323 |
/* returnMessage() - JSON decode the raw [Message] portion of the IPN */
|
324 |
-
|
325 |
public function returnMessage()
|
326 |
{
|
327 |
return json_decode($this->snsMessage['Message'], true);
|
@@ -337,7 +340,7 @@ class IpnHandler implements IpnHandlerInterface
|
|
337 |
* Topic ARN - Topic of the IPN
|
338 |
* @return response in JSON format
|
339 |
*/
|
340 |
-
|
341 |
public function toJson()
|
342 |
{
|
343 |
$response = $this->simpleXmlObject();
|
@@ -355,7 +358,7 @@ class IpnHandler implements IpnHandlerInterface
|
|
355 |
/* toArray() - Converts IPN [Message] field to associative array
|
356 |
* @return response in array format
|
357 |
*/
|
358 |
-
|
359 |
public function toArray()
|
360 |
{
|
361 |
$response = $this->simpleXmlObject();
|
@@ -400,7 +403,7 @@ class IpnHandler implements IpnHandlerInterface
|
|
400 |
/* getRemainingIpnFields()
|
401 |
* Gets the remaining fields of the IPN to be later appended to the return message
|
402 |
*/
|
403 |
-
|
404 |
private function getRemainingIpnFields()
|
405 |
{
|
406 |
$ipnMessage = $this->returnMessage();
|
1 |
<?php
|
2 |
namespace PayWithAmazon;
|
3 |
|
4 |
+
// Exit if accessed directly
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
/* Class IPN_Handler
|
8 |
* Takes headers and body of the IPN message as input in the constructor
|
9 |
* verifies that the IPN is from the right resource and has the valid data
|
79 |
/* Setter function
|
80 |
* Sets the value for the key if the key exists in ipnConfig
|
81 |
*/
|
82 |
+
|
83 |
public function __set($name, $value)
|
84 |
{
|
85 |
if (array_key_exists(strtolower($name), $this->ipnConfig)) {
|
92 |
/* Getter function
|
93 |
* Returns the value for the key if the key exists in ipnConfig
|
94 |
*/
|
95 |
+
|
96 |
public function __get($name)
|
97 |
{
|
98 |
if (array_key_exists(strtolower($name), $this->ipnConfig)) {
|
103 |
}
|
104 |
|
105 |
/* Trim the input Array key values */
|
106 |
+
|
107 |
private function trimArray($array)
|
108 |
{
|
109 |
foreach ($array as $key => $value)
|
112 |
}
|
113 |
return $array;
|
114 |
}
|
115 |
+
|
116 |
private function validateHeaders()
|
117 |
{
|
118 |
// Quickly check that this is a sns message
|
143 |
*
|
144 |
* @return string error message
|
145 |
*/
|
146 |
+
|
147 |
private function getErrorMessageForJsonError($json_error)
|
148 |
{
|
149 |
switch ($json_error) {
|
220 |
*
|
221 |
* @return bool true if valid
|
222 |
*/
|
223 |
+
|
224 |
private function constructAndVerifySignature()
|
225 |
{
|
226 |
$signature = base64_decode($this->getMandatoryField("Signature"));
|
238 |
*
|
239 |
* gets the certificate from the $certificatePath using Curl
|
240 |
*/
|
241 |
+
|
242 |
private function getCertificate($certificatePath)
|
243 |
{
|
244 |
$httpCurlRequest = new HttpCurl($this->ipnConfig);
|
297 |
*
|
298 |
* @return string field contents if found
|
299 |
*/
|
300 |
+
|
301 |
private function getMandatoryField($fieldName)
|
302 |
{
|
303 |
$value = $this->getField($fieldName);
|
313 |
*
|
314 |
* @return string field contents if found, null otherwise
|
315 |
*/
|
316 |
+
|
317 |
private function getField($fieldName)
|
318 |
{
|
319 |
if (array_key_exists($fieldName, $this->snsMessage)) {
|
324 |
}
|
325 |
|
326 |
/* returnMessage() - JSON decode the raw [Message] portion of the IPN */
|
327 |
+
|
328 |
public function returnMessage()
|
329 |
{
|
330 |
return json_decode($this->snsMessage['Message'], true);
|
340 |
* Topic ARN - Topic of the IPN
|
341 |
* @return response in JSON format
|
342 |
*/
|
343 |
+
|
344 |
public function toJson()
|
345 |
{
|
346 |
$response = $this->simpleXmlObject();
|
358 |
/* toArray() - Converts IPN [Message] field to associative array
|
359 |
* @return response in array format
|
360 |
*/
|
361 |
+
|
362 |
public function toArray()
|
363 |
{
|
364 |
$response = $this->simpleXmlObject();
|
403 |
/* getRemainingIpnFields()
|
404 |
* Gets the remaining fields of the IPN to be later appended to the return message
|
405 |
*/
|
406 |
+
|
407 |
private function getRemainingIpnFields()
|
408 |
{
|
409 |
$ipnMessage = $this->returnMessage();
|
includes/gateways/libs/amazon/ResponseParser.php
CHANGED
@@ -1,6 +1,9 @@
|
|
1 |
<?php
|
2 |
namespace PayWithAmazon;
|
3 |
|
|
|
|
|
|
|
4 |
/* ResponseParser
|
5 |
* Methods provided to convert the Response from the POST to XML, Array or JSON
|
6 |
*/
|
@@ -10,62 +13,62 @@ require_once 'Interface.php';
|
|
10 |
class ResponseParser implements ResponseInterface
|
11 |
{
|
12 |
public $response = null;
|
13 |
-
|
14 |
public function __construct($response=null)
|
15 |
{
|
16 |
$this->response = $response;
|
17 |
}
|
18 |
-
|
19 |
/* Returns the XML portion of the response */
|
20 |
-
|
21 |
public function toXml()
|
22 |
{
|
23 |
return $this->response['ResponseBody'];
|
24 |
}
|
25 |
-
|
26 |
/* toJson - converts XML into Json
|
27 |
* @param $response [XML]
|
28 |
*/
|
29 |
-
|
30 |
public function toJson()
|
31 |
{
|
32 |
$response = $this->simpleXmlObject();
|
33 |
-
|
34 |
return (json_encode($response));
|
35 |
}
|
36 |
-
|
37 |
/* toArray - converts XML into associative array
|
38 |
* @param $this->response [XML]
|
39 |
*/
|
40 |
-
|
41 |
public function toArray()
|
42 |
{
|
43 |
$response = $this->simpleXmlObject();
|
44 |
-
|
45 |
// Converting the SimpleXMLElement Object to array()
|
46 |
$response = json_encode($response);
|
47 |
-
|
48 |
return (json_decode($response, true));
|
49 |
}
|
50 |
-
|
51 |
private function simpleXmlObject()
|
52 |
{
|
53 |
$response = $this->response;
|
54 |
-
|
55 |
// Getting the HttpResponse Status code to the output as a string
|
56 |
$status = strval($response['Status']);
|
57 |
-
|
58 |
// Getting the Simple XML element object of the XML Response Body
|
59 |
$response = simplexml_load_string((string) $response['ResponseBody']);
|
60 |
-
|
61 |
// Adding the HttpResponse Status code to the output as a string
|
62 |
$response->addChild('ResponseStatus', $status);
|
63 |
-
|
64 |
return $response;
|
65 |
}
|
66 |
-
|
67 |
/* Get the status of the BillingAgreement */
|
68 |
-
|
69 |
public function getBillingAgreementDetailsStatus($response)
|
70 |
{
|
71 |
$data= new \SimpleXMLElement($response);
|
@@ -77,7 +80,7 @@ class ResponseParser implements ResponseInterface
|
|
77 |
foreach ($data->xpath('//GetBA:BillingAgreementStatus') as $value) {
|
78 |
$baStatus = json_decode(json_encode((array)$value), TRUE);
|
79 |
}
|
80 |
-
|
81 |
return $baStatus ;
|
82 |
}
|
83 |
}
|
1 |
<?php
|
2 |
namespace PayWithAmazon;
|
3 |
|
4 |
+
// Exit if accessed directly
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
6 |
+
|
7 |
/* ResponseParser
|
8 |
* Methods provided to convert the Response from the POST to XML, Array or JSON
|
9 |
*/
|
13 |
class ResponseParser implements ResponseInterface
|
14 |
{
|
15 |
public $response = null;
|
16 |
+
|
17 |
public function __construct($response=null)
|
18 |
{
|
19 |
$this->response = $response;
|
20 |
}
|
21 |
+
|
22 |
/* Returns the XML portion of the response */
|
23 |
+
|
24 |
public function toXml()
|
25 |
{
|
26 |
return $this->response['ResponseBody'];
|
27 |
}
|
28 |
+
|
29 |
/* toJson - converts XML into Json
|
30 |
* @param $response [XML]
|
31 |
*/
|
32 |
+
|
33 |
public function toJson()
|
34 |
{
|
35 |
$response = $this->simpleXmlObject();
|
36 |
+
|
37 |
return (json_encode($response));
|
38 |
}
|
39 |
+
|
40 |
/* toArray - converts XML into associative array
|
41 |
* @param $this->response [XML]
|
42 |
*/
|
43 |
+
|
44 |
public function toArray()
|
45 |
{
|
46 |
$response = $this->simpleXmlObject();
|
47 |
+
|
48 |
// Converting the SimpleXMLElement Object to array()
|
49 |
$response = json_encode($response);
|
50 |
+
|
51 |
return (json_decode($response, true));
|
52 |
}
|
53 |
+
|
54 |
private function simpleXmlObject()
|
55 |
{
|
56 |
$response = $this->response;
|
57 |
+
|
58 |
// Getting the HttpResponse Status code to the output as a string
|
59 |
$status = strval($response['Status']);
|
60 |
+
|
61 |
// Getting the Simple XML element object of the XML Response Body
|
62 |
$response = simplexml_load_string((string) $response['ResponseBody']);
|
63 |
+
|
64 |
// Adding the HttpResponse Status code to the output as a string
|
65 |
$response->addChild('ResponseStatus', $status);
|
66 |
+
|
67 |
return $response;
|
68 |
}
|
69 |
+
|
70 |
/* Get the status of the BillingAgreement */
|
71 |
+
|
72 |
public function getBillingAgreementDetailsStatus($response)
|
73 |
{
|
74 |
$data= new \SimpleXMLElement($response);
|
80 |
foreach ($data->xpath('//GetBA:BillingAgreementStatus') as $value) {
|
81 |
$baStatus = json_decode(json_encode((array)$value), TRUE);
|
82 |
}
|
83 |
+
|
84 |
return $baStatus ;
|
85 |
}
|
86 |
}
|
includes/gateways/paypal-standard.php
CHANGED
@@ -74,6 +74,8 @@ function edd_process_paypal_purchase( $purchase_data ) {
|
|
74 |
$paypal_args = array(
|
75 |
'business' => edd_get_option( 'paypal_email', false ),
|
76 |
'email' => $purchase_data['user_email'],
|
|
|
|
|
77 |
'invoice' => $purchase_data['purchase_key'],
|
78 |
'no_shipping' => '1',
|
79 |
'shipping' => '0',
|
74 |
$paypal_args = array(
|
75 |
'business' => edd_get_option( 'paypal_email', false ),
|
76 |
'email' => $purchase_data['user_email'],
|
77 |
+
'first_name' => $purchase_data['user_info']['first_name'],
|
78 |
+
'last_name' => $purchase_data['user_info']['last_name'],
|
79 |
'invoice' => $purchase_data['purchase_key'],
|
80 |
'no_shipping' => '1',
|
81 |
'shipping' => '0',
|
includes/misc-functions.php
CHANGED
@@ -52,7 +52,7 @@ function edd_logged_in_only() {
|
|
52 |
* @return bool $ret True is redirect is enabled, false otherwise
|
53 |
*/
|
54 |
function edd_straight_to_checkout() {
|
55 |
-
$ret = edd_get_option( 'redirect_on_add', false );
|
56 |
return (bool) apply_filters( 'edd_straight_to_checkout', $ret );
|
57 |
}
|
58 |
|
@@ -696,6 +696,43 @@ function edd_set_upload_dir( $upload ) {
|
|
696 |
return $upload;
|
697 |
}
|
698 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
699 |
|
700 |
if ( ! function_exists( 'cal_days_in_month' ) ) {
|
701 |
// Fallback in case the calendar extension is not loaded in PHP
|
@@ -756,4 +793,4 @@ if ( ! function_exists( 'getallheaders' ) ) :
|
|
756 |
return $headers;
|
757 |
}
|
758 |
|
759 |
-
endif;
|
52 |
* @return bool $ret True is redirect is enabled, false otherwise
|
53 |
*/
|
54 |
function edd_straight_to_checkout() {
|
55 |
+
$ret = edd_get_option( 'redirect_on_add', false );
|
56 |
return (bool) apply_filters( 'edd_straight_to_checkout', $ret );
|
57 |
}
|
58 |
|
696 |
return $upload;
|
697 |
}
|
698 |
|
699 |
+
/**
|
700 |
+
* Check if the upgrade routine has been run for a specific action
|
701 |
+
*
|
702 |
+
* @since 2.3
|
703 |
+
* @param string $upgrade_action The upgrade action to check completion for
|
704 |
+
* @return bool If the action has been added to the copmleted actions array
|
705 |
+
*/
|
706 |
+
function edd_has_upgrade_completed( $upgrade_action = '' ) {
|
707 |
+
|
708 |
+
if ( empty( $upgrade_action ) ) {
|
709 |
+
return false;
|
710 |
+
}
|
711 |
+
|
712 |
+
$completed_upgrades = edd_get_completed_upgrades();
|
713 |
+
|
714 |
+
return in_array( $upgrade_action, $completed_upgrades );
|
715 |
+
|
716 |
+
}
|
717 |
+
|
718 |
+
/**
|
719 |
+
* Get's the array of completed upgrade actions
|
720 |
+
*
|
721 |
+
* @since 2.3
|
722 |
+
* @return array The array of completed upgrades
|
723 |
+
*/
|
724 |
+
function edd_get_completed_upgrades() {
|
725 |
+
|
726 |
+
$completed_upgrades = get_option( 'edd_completed_upgrades' );
|
727 |
+
|
728 |
+
if ( false === $completed_upgrades ) {
|
729 |
+
$completed_upgrades = array();
|
730 |
+
}
|
731 |
+
|
732 |
+
return $completed_upgrades;
|
733 |
+
|
734 |
+
}
|
735 |
+
|
736 |
|
737 |
if ( ! function_exists( 'cal_days_in_month' ) ) {
|
738 |
// Fallback in case the calendar extension is not loaded in PHP
|
793 |
return $headers;
|
794 |
}
|
795 |
|
796 |
+
endif;
|
includes/template-functions.php
CHANGED
@@ -58,7 +58,7 @@ function edd_get_purchase_link( $args = array() ) {
|
|
58 |
|
59 |
$post_id = is_object( $post ) ? $post->ID : 0;
|
60 |
$button_behavior = edd_get_download_button_behavior( $post_id );
|
61 |
-
|
62 |
$defaults = apply_filters( 'edd_purchase_link_defaults', array(
|
63 |
'download_id' => $post_id,
|
64 |
'price' => (bool) true,
|
@@ -322,7 +322,7 @@ function edd_download_purchase_form_quantity_field( $download_id = 0, $args = ar
|
|
322 |
<div class="edd_download_quantity_wrapper">
|
323 |
<input type="number" min="1" step="1" name="edd_download_quantity" class="edd-input edd-item-quantity" value="1" />
|
324 |
</div>
|
325 |
-
<?php
|
326 |
$quantity_input = ob_get_clean();
|
327 |
|
328 |
echo apply_filters( 'edd_purchase_form_quantity_input', $quantity_input, $download_id, $args );
|
@@ -354,7 +354,7 @@ function edd_variable_price_quantity_field( $key, $price, $download_id ) {
|
|
354 |
<span class="edd_price_option_sep"> x </span>
|
355 |
<input type="number" min="1" step="1" name="edd_download_quantity_<?php echo esc_attr( $key ) ?>" class="edd-input edd-item-quantity" value="1" />
|
356 |
</div>
|
357 |
-
<?php
|
358 |
$quantity_input = ob_get_clean();
|
359 |
|
360 |
echo apply_filters( 'edd_purchase_form_variation_quantity_input', $quantity_input, $download_id, $key, $price );
|
@@ -732,16 +732,16 @@ add_filter( 'the_title', 'edd_microdata_title', 10, 2 );
|
|
732 |
*
|
733 |
* @return void
|
734 |
*/
|
735 |
-
function edd_microdata_wrapper_open() {
|
736 |
global $post;
|
737 |
|
738 |
static $microdata_open = NULL;
|
739 |
|
740 |
-
if( ! edd_add_schema_microdata() || true === $microdata_open || ! is_object( $
|
741 |
return;
|
742 |
}
|
743 |
|
744 |
-
if ( $
|
745 |
$microdata_open = true;
|
746 |
echo '<span itemscope itemtype="http://schema.org/Product">';
|
747 |
}
|
58 |
|
59 |
$post_id = is_object( $post ) ? $post->ID : 0;
|
60 |
$button_behavior = edd_get_download_button_behavior( $post_id );
|
61 |
+
|
62 |
$defaults = apply_filters( 'edd_purchase_link_defaults', array(
|
63 |
'download_id' => $post_id,
|
64 |
'price' => (bool) true,
|
322 |
<div class="edd_download_quantity_wrapper">
|
323 |
<input type="number" min="1" step="1" name="edd_download_quantity" class="edd-input edd-item-quantity" value="1" />
|
324 |
</div>
|
325 |
+
<?php
|
326 |
$quantity_input = ob_get_clean();
|
327 |
|
328 |
echo apply_filters( 'edd_purchase_form_quantity_input', $quantity_input, $download_id, $args );
|
354 |
<span class="edd_price_option_sep"> x </span>
|
355 |
<input type="number" min="1" step="1" name="edd_download_quantity_<?php echo esc_attr( $key ) ?>" class="edd-input edd-item-quantity" value="1" />
|
356 |
</div>
|
357 |
+
<?php
|
358 |
$quantity_input = ob_get_clean();
|
359 |
|
360 |
echo apply_filters( 'edd_purchase_form_variation_quantity_input', $quantity_input, $download_id, $key, $price );
|
732 |
*
|
733 |
* @return void
|
734 |
*/
|
735 |
+
function edd_microdata_wrapper_open( $query ) {
|
736 |
global $post;
|
737 |
|
738 |
static $microdata_open = NULL;
|
739 |
|
740 |
+
if( ! edd_add_schema_microdata() || true === $microdata_open || ! is_object( $query ) ) {
|
741 |
return;
|
742 |
}
|
743 |
|
744 |
+
if ( $query && ! empty( $query->query['post_type'] ) && $query->query['post_type'] == 'download' && is_singular( 'download' ) && $query->is_main_query() ) {
|
745 |
$microdata_open = true;
|
746 |
echo '<span itemscope itemtype="http://schema.org/Product">';
|
747 |
}
|
languages/edd.pot
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
# This file is distributed under the same license as the Easy Digital Downloads package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: Easy Digital Downloads 2.4\n"
|
6 |
"Report-Msgid-Bugs-To: https://easydigitaldownloads.com/\n"
|
7 |
-
"POT-Creation-Date: 2015-07-
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
@@ -86,7 +86,7 @@ msgstr ""
|
|
86 |
#: includes/deprecated-functions.php:517 includes/deprecated-functions.php:532
|
87 |
#: includes/deprecated-functions.php:542 includes/download-functions.php:1152
|
88 |
#: includes/emails/actions.php:48 includes/emails/template.php:241
|
89 |
-
#: includes/error-tracking.php:36 includes/gateways/functions.php:
|
90 |
#: includes/gateways/manual.php:33 includes/gateways/paypal-standard.php:34
|
91 |
#: includes/process-download.php:231 includes/process-download.php:698
|
92 |
#: includes/query-filters.php:48
|
@@ -459,7 +459,7 @@ msgid "Invalid Customer ID Provided."
|
|
459 |
msgstr ""
|
460 |
|
461 |
#: includes/admin/customers/customers.php:115
|
462 |
-
#: includes/admin/payments/view-order-details.php:
|
463 |
msgid "Customer Details"
|
464 |
msgstr ""
|
465 |
|
@@ -532,7 +532,7 @@ msgstr ""
|
|
532 |
|
533 |
#: includes/admin/customers/customers.php:305
|
534 |
#: includes/admin/customers/customers.php:520
|
535 |
-
#: includes/admin/payments/view-order-details.php:
|
536 |
#: includes/admin/thickbox.php:135 includes/class-edd-html-elements.php:573
|
537 |
msgid "Cancel"
|
538 |
msgstr ""
|
@@ -942,7 +942,7 @@ msgstr ""
|
|
942 |
#: includes/admin/discounts/class-discount-codes-table.php:206
|
943 |
#: includes/admin/discounts/class-discount-codes-table.php:274
|
944 |
#: includes/admin/payments/class-payments-table.php:302
|
945 |
-
#: includes/admin/payments/class-payments-table.php:
|
946 |
#: includes/payments/functions.php:1658
|
947 |
msgid "Delete"
|
948 |
msgstr ""
|
@@ -1403,7 +1403,7 @@ msgstr ""
|
|
1403 |
|
1404 |
#: includes/admin/downloads/metabox.php:865
|
1405 |
#: includes/admin/settings/register-settings.php:763
|
1406 |
-
#: includes/admin/thickbox.php:62 includes/checkout/template.php:
|
1407 |
#: includes/scripts.php:58 includes/shortcodes.php:36
|
1408 |
#: includes/template-functions.php:67
|
1409 |
msgid "Purchase"
|
@@ -1559,50 +1559,50 @@ msgstr ""
|
|
1559 |
msgid "Resend Purchase Receipt"
|
1560 |
msgstr ""
|
1561 |
|
1562 |
-
#: includes/admin/payments/class-payments-table.php:
|
1563 |
msgid "(unknown)"
|
1564 |
msgstr ""
|
1565 |
|
1566 |
-
#: includes/admin/payments/class-payments-table.php:357
|
1567 |
#: includes/admin/payments/class-payments-table.php:359
|
|
|
1568 |
#: includes/admin/reporting/class-export-payments.php:192
|
1569 |
#: includes/admin/reporting/export/class-batch-export-payments.php:186
|
1570 |
msgid "guest"
|
1571 |
msgstr ""
|
1572 |
|
1573 |
-
#: includes/admin/payments/class-payments-table.php:
|
1574 |
msgid "Set To Completed"
|
1575 |
msgstr ""
|
1576 |
|
1577 |
-
#: includes/admin/payments/class-payments-table.php:
|
1578 |
msgid "Set To Pending"
|
1579 |
msgstr ""
|
1580 |
|
1581 |
-
#: includes/admin/payments/class-payments-table.php:
|
1582 |
msgid "Set To Refunded"
|
1583 |
msgstr ""
|
1584 |
|
1585 |
-
#: includes/admin/payments/class-payments-table.php:
|
1586 |
msgid "Set To Revoked"
|
1587 |
msgstr ""
|
1588 |
|
1589 |
-
#: includes/admin/payments/class-payments-table.php:
|
1590 |
msgid "Set To Failed"
|
1591 |
msgstr ""
|
1592 |
|
1593 |
-
#: includes/admin/payments/class-payments-table.php:
|
1594 |
msgid "Set To Abandoned"
|
1595 |
msgstr ""
|
1596 |
|
1597 |
-
#: includes/admin/payments/class-payments-table.php:
|
1598 |
msgid "Set To Preapproval"
|
1599 |
msgstr ""
|
1600 |
|
1601 |
-
#: includes/admin/payments/class-payments-table.php:
|
1602 |
msgid "Set To Cancelled"
|
1603 |
msgstr ""
|
1604 |
|
1605 |
-
#: includes/admin/payments/class-payments-table.php:
|
1606 |
msgid "Resend Email Receipts"
|
1607 |
msgstr ""
|
1608 |
|
@@ -1833,7 +1833,7 @@ msgid "Total:"
|
|
1833 |
msgstr ""
|
1834 |
|
1835 |
#: includes/admin/payments/view-order-details.php:331
|
1836 |
-
#: includes/admin/payments/view-order-details.php:
|
1837 |
msgid "Copy Download Link(s)"
|
1838 |
msgstr ""
|
1839 |
|
@@ -1850,70 +1850,70 @@ msgstr ""
|
|
1850 |
msgid "Quantity"
|
1851 |
msgstr ""
|
1852 |
|
1853 |
-
#: includes/admin/payments/view-order-details.php:
|
1854 |
msgid "Item Price: "
|
1855 |
msgstr ""
|
1856 |
|
1857 |
-
#: includes/admin/payments/view-order-details.php:
|
1858 |
msgid "Add %s to Payment"
|
1859 |
msgstr ""
|
1860 |
|
1861 |
-
#: includes/admin/payments/view-order-details.php:
|
1862 |
msgid "No %s included with this purchase"
|
1863 |
msgstr ""
|
1864 |
|
1865 |
-
#: includes/admin/payments/view-order-details.php:
|
1866 |
msgid "View Customer Details"
|
1867 |
msgstr ""
|
1868 |
|
1869 |
-
#: includes/admin/payments/view-order-details.php:
|
1870 |
msgid "New Customer"
|
1871 |
msgstr ""
|
1872 |
|
1873 |
-
#: includes/admin/payments/view-order-details.php:
|
1874 |
msgid "Name:"
|
1875 |
msgstr ""
|
1876 |
|
1877 |
-
#: includes/admin/payments/view-order-details.php:
|
1878 |
msgid "Email:"
|
1879 |
msgstr ""
|
1880 |
|
1881 |
-
#: includes/admin/payments/view-order-details.php:
|
1882 |
msgid "Click \"Save Payment\" to create new customer"
|
1883 |
msgstr ""
|
1884 |
|
1885 |
-
#: includes/admin/payments/view-order-details.php:
|
1886 |
#: includes/checkout/template.php:329
|
1887 |
msgid "Billing Address"
|
1888 |
msgstr ""
|
1889 |
|
1890 |
-
#: includes/admin/payments/view-order-details.php:
|
1891 |
msgid "Street Address Line 1:"
|
1892 |
msgstr ""
|
1893 |
|
1894 |
-
#: includes/admin/payments/view-order-details.php:
|
1895 |
msgid "Street Address Line 2:"
|
1896 |
msgstr ""
|
1897 |
|
1898 |
-
#: includes/admin/payments/view-order-details.php:
|
1899 |
#: includes/admin/settings/register-settings.php:263
|
1900 |
msgid "Select a country"
|
1901 |
msgstr ""
|
1902 |
|
1903 |
-
#: includes/admin/payments/view-order-details.php:
|
1904 |
#: includes/admin/settings/register-settings.php:271
|
1905 |
msgid "Select a state"
|
1906 |
msgstr ""
|
1907 |
|
1908 |
-
#: includes/admin/payments/view-order-details.php:
|
1909 |
msgid "Payment Notes"
|
1910 |
msgstr ""
|
1911 |
|
1912 |
-
#: includes/admin/payments/view-order-details.php:
|
1913 |
msgid "No payment notes"
|
1914 |
msgstr ""
|
1915 |
|
1916 |
-
#: includes/admin/payments/view-order-details.php:
|
1917 |
msgid "Add Note"
|
1918 |
msgstr ""
|
1919 |
|
@@ -4483,48 +4483,48 @@ msgstr ""
|
|
4483 |
msgid "Select Payment Method"
|
4484 |
msgstr ""
|
4485 |
|
4486 |
-
#: includes/checkout/template.php:
|
4487 |
msgid "Have a discount code?"
|
4488 |
msgstr ""
|
4489 |
|
4490 |
-
#: includes/checkout/template.php:
|
4491 |
msgid "Discount"
|
4492 |
msgstr ""
|
4493 |
|
4494 |
-
#: includes/checkout/template.php:
|
4495 |
msgid "Enter a coupon code if you have one."
|
4496 |
msgstr ""
|
4497 |
|
4498 |
-
#: includes/checkout/template.php:
|
4499 |
#: includes/scripts.php:53
|
4500 |
msgid "Enter discount"
|
4501 |
msgstr ""
|
4502 |
|
4503 |
-
#: includes/checkout/template.php:
|
4504 |
msgid "Agree to Terms?"
|
4505 |
msgstr ""
|
4506 |
|
4507 |
-
#: includes/checkout/template.php:
|
4508 |
msgid "Show Terms"
|
4509 |
msgstr ""
|
4510 |
|
4511 |
-
#: includes/checkout/template.php:
|
4512 |
msgid "Hide Terms"
|
4513 |
msgstr ""
|
4514 |
|
4515 |
-
#: includes/checkout/template.php:
|
4516 |
msgid "Purchase Total:"
|
4517 |
msgstr ""
|
4518 |
|
4519 |
-
#: includes/checkout/template.php:
|
4520 |
msgid "Go back"
|
4521 |
msgstr ""
|
4522 |
|
4523 |
-
#: includes/checkout/template.php:
|
4524 |
msgid "Next"
|
4525 |
msgstr ""
|
4526 |
|
4527 |
-
#: includes/checkout/template.php:
|
4528 |
msgid "Free Download"
|
4529 |
msgstr ""
|
4530 |
|
@@ -5520,11 +5520,11 @@ msgstr ""
|
|
5520 |
msgid "Test Payment"
|
5521 |
msgstr ""
|
5522 |
|
5523 |
-
#: includes/gateways/functions.php:
|
5524 |
msgid "Free Purchase"
|
5525 |
msgstr ""
|
5526 |
|
5527 |
-
#: includes/gateways/functions.php:
|
5528 |
msgid "The requested price ID does not exist."
|
5529 |
msgstr ""
|
5530 |
|
@@ -6649,22 +6649,22 @@ msgstr ""
|
|
6649 |
msgid "Serve Digital Downloads Through WordPress"
|
6650 |
msgstr ""
|
6651 |
|
6652 |
-
#: includes/admin/payments/view-order-details.php:
|
6653 |
msgctxt "Address City"
|
6654 |
msgid "City:"
|
6655 |
msgstr ""
|
6656 |
|
6657 |
-
#: includes/admin/payments/view-order-details.php:
|
6658 |
msgctxt "Zip / Postal code of address"
|
6659 |
msgid "Zip / Postal Code:"
|
6660 |
msgstr ""
|
6661 |
|
6662 |
-
#: includes/admin/payments/view-order-details.php:
|
6663 |
msgctxt "Address country"
|
6664 |
msgid "Country:"
|
6665 |
msgstr ""
|
6666 |
|
6667 |
-
#: includes/admin/payments/view-order-details.php:
|
6668 |
msgctxt "State / province of address"
|
6669 |
msgid "State / Province:"
|
6670 |
msgstr ""
|
@@ -6674,12 +6674,12 @@ msgctxt "Date one to date two"
|
|
6674 |
msgid "to"
|
6675 |
msgstr ""
|
6676 |
|
6677 |
-
#: includes/checkout/template.php:
|
6678 |
msgctxt "Entering a discount code"
|
6679 |
msgid "Click to enter it"
|
6680 |
msgstr ""
|
6681 |
|
6682 |
-
#: includes/checkout/template.php:
|
6683 |
msgctxt "Apply discount at checkout"
|
6684 |
msgid "Apply"
|
6685 |
msgstr ""
|
2 |
# This file is distributed under the same license as the Easy Digital Downloads package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Easy Digital Downloads 2.4.1\n"
|
6 |
"Report-Msgid-Bugs-To: https://easydigitaldownloads.com/\n"
|
7 |
+
"POT-Creation-Date: 2015-07-06 19:53:04+00:00\n"
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
86 |
#: includes/deprecated-functions.php:517 includes/deprecated-functions.php:532
|
87 |
#: includes/deprecated-functions.php:542 includes/download-functions.php:1152
|
88 |
#: includes/emails/actions.php:48 includes/emails/template.php:241
|
89 |
+
#: includes/error-tracking.php:36 includes/gateways/functions.php:221
|
90 |
#: includes/gateways/manual.php:33 includes/gateways/paypal-standard.php:34
|
91 |
#: includes/process-download.php:231 includes/process-download.php:698
|
92 |
#: includes/query-filters.php:48
|
459 |
msgstr ""
|
460 |
|
461 |
#: includes/admin/customers/customers.php:115
|
462 |
+
#: includes/admin/payments/view-order-details.php:393
|
463 |
msgid "Customer Details"
|
464 |
msgstr ""
|
465 |
|
532 |
|
533 |
#: includes/admin/customers/customers.php:305
|
534 |
#: includes/admin/customers/customers.php:520
|
535 |
+
#: includes/admin/payments/view-order-details.php:427
|
536 |
#: includes/admin/thickbox.php:135 includes/class-edd-html-elements.php:573
|
537 |
msgid "Cancel"
|
538 |
msgstr ""
|
942 |
#: includes/admin/discounts/class-discount-codes-table.php:206
|
943 |
#: includes/admin/discounts/class-discount-codes-table.php:274
|
944 |
#: includes/admin/payments/class-payments-table.php:302
|
945 |
+
#: includes/admin/payments/class-payments-table.php:377
|
946 |
#: includes/payments/functions.php:1658
|
947 |
msgid "Delete"
|
948 |
msgstr ""
|
1403 |
|
1404 |
#: includes/admin/downloads/metabox.php:865
|
1405 |
#: includes/admin/settings/register-settings.php:763
|
1406 |
+
#: includes/admin/thickbox.php:62 includes/checkout/template.php:829
|
1407 |
#: includes/scripts.php:58 includes/shortcodes.php:36
|
1408 |
#: includes/template-functions.php:67
|
1409 |
msgid "Purchase"
|
1559 |
msgid "Resend Purchase Receipt"
|
1560 |
msgstr ""
|
1561 |
|
1562 |
+
#: includes/admin/payments/class-payments-table.php:309
|
1563 |
msgid "(unknown)"
|
1564 |
msgstr ""
|
1565 |
|
|
|
1566 |
#: includes/admin/payments/class-payments-table.php:359
|
1567 |
+
#: includes/admin/payments/class-payments-table.php:361
|
1568 |
#: includes/admin/reporting/class-export-payments.php:192
|
1569 |
#: includes/admin/reporting/export/class-batch-export-payments.php:186
|
1570 |
msgid "guest"
|
1571 |
msgstr ""
|
1572 |
|
1573 |
+
#: includes/admin/payments/class-payments-table.php:378
|
1574 |
msgid "Set To Completed"
|
1575 |
msgstr ""
|
1576 |
|
1577 |
+
#: includes/admin/payments/class-payments-table.php:379
|
1578 |
msgid "Set To Pending"
|
1579 |
msgstr ""
|
1580 |
|
1581 |
+
#: includes/admin/payments/class-payments-table.php:380
|
1582 |
msgid "Set To Refunded"
|
1583 |
msgstr ""
|
1584 |
|
1585 |
+
#: includes/admin/payments/class-payments-table.php:381
|
1586 |
msgid "Set To Revoked"
|
1587 |
msgstr ""
|
1588 |
|
1589 |
+
#: includes/admin/payments/class-payments-table.php:382
|
1590 |
msgid "Set To Failed"
|
1591 |
msgstr ""
|
1592 |
|
1593 |
+
#: includes/admin/payments/class-payments-table.php:383
|
1594 |
msgid "Set To Abandoned"
|
1595 |
msgstr ""
|
1596 |
|
1597 |
+
#: includes/admin/payments/class-payments-table.php:384
|
1598 |
msgid "Set To Preapproval"
|
1599 |
msgstr ""
|
1600 |
|
1601 |
+
#: includes/admin/payments/class-payments-table.php:385
|
1602 |
msgid "Set To Cancelled"
|
1603 |
msgstr ""
|
1604 |
|
1605 |
+
#: includes/admin/payments/class-payments-table.php:386
|
1606 |
msgid "Resend Email Receipts"
|
1607 |
msgstr ""
|
1608 |
|
1833 |
msgstr ""
|
1834 |
|
1835 |
#: includes/admin/payments/view-order-details.php:331
|
1836 |
+
#: includes/admin/payments/view-order-details.php:565
|
1837 |
msgid "Copy Download Link(s)"
|
1838 |
msgstr ""
|
1839 |
|
1850 |
msgid "Quantity"
|
1851 |
msgstr ""
|
1852 |
|
1853 |
+
#: includes/admin/payments/view-order-details.php:363
|
1854 |
msgid "Item Price: "
|
1855 |
msgstr ""
|
1856 |
|
1857 |
+
#: includes/admin/payments/view-order-details.php:371
|
1858 |
msgid "Add %s to Payment"
|
1859 |
msgstr ""
|
1860 |
|
1861 |
+
#: includes/admin/payments/view-order-details.php:382
|
1862 |
msgid "No %s included with this purchase"
|
1863 |
msgstr ""
|
1864 |
|
1865 |
+
#: includes/admin/payments/view-order-details.php:409
|
1866 |
msgid "View Customer Details"
|
1867 |
msgstr ""
|
1868 |
|
1869 |
+
#: includes/admin/payments/view-order-details.php:412
|
1870 |
msgid "New Customer"
|
1871 |
msgstr ""
|
1872 |
|
1873 |
+
#: includes/admin/payments/view-order-details.php:418
|
1874 |
msgid "Name:"
|
1875 |
msgstr ""
|
1876 |
|
1877 |
+
#: includes/admin/payments/view-order-details.php:422
|
1878 |
msgid "Email:"
|
1879 |
msgstr ""
|
1880 |
|
1881 |
+
#: includes/admin/payments/view-order-details.php:430
|
1882 |
msgid "Click \"Save Payment\" to create new customer"
|
1883 |
msgstr ""
|
1884 |
|
1885 |
+
#: includes/admin/payments/view-order-details.php:445
|
1886 |
#: includes/checkout/template.php:329
|
1887 |
msgid "Billing Address"
|
1888 |
msgstr ""
|
1889 |
|
1890 |
+
#: includes/admin/payments/view-order-details.php:455
|
1891 |
msgid "Street Address Line 1:"
|
1892 |
msgstr ""
|
1893 |
|
1894 |
+
#: includes/admin/payments/view-order-details.php:459
|
1895 |
msgid "Street Address Line 2:"
|
1896 |
msgstr ""
|
1897 |
|
1898 |
+
#: includes/admin/payments/view-order-details.php:487
|
1899 |
#: includes/admin/settings/register-settings.php:263
|
1900 |
msgid "Select a country"
|
1901 |
msgstr ""
|
1902 |
|
1903 |
+
#: includes/admin/payments/view-order-details.php:503
|
1904 |
#: includes/admin/settings/register-settings.php:271
|
1905 |
msgid "Select a state"
|
1906 |
msgstr ""
|
1907 |
|
1908 |
+
#: includes/admin/payments/view-order-details.php:523
|
1909 |
msgid "Payment Notes"
|
1910 |
msgstr ""
|
1911 |
|
1912 |
+
#: includes/admin/payments/view-order-details.php:538
|
1913 |
msgid "No payment notes"
|
1914 |
msgstr ""
|
1915 |
|
1916 |
+
#: includes/admin/payments/view-order-details.php:544
|
1917 |
msgid "Add Note"
|
1918 |
msgstr ""
|
1919 |
|
4483 |
msgid "Select Payment Method"
|
4484 |
msgstr ""
|
4485 |
|
4486 |
+
#: includes/checkout/template.php:702
|
4487 |
msgid "Have a discount code?"
|
4488 |
msgstr ""
|
4489 |
|
4490 |
+
#: includes/checkout/template.php:706
|
4491 |
msgid "Discount"
|
4492 |
msgstr ""
|
4493 |
|
4494 |
+
#: includes/checkout/template.php:709
|
4495 |
msgid "Enter a coupon code if you have one."
|
4496 |
msgstr ""
|
4497 |
|
4498 |
+
#: includes/checkout/template.php:710 includes/process-purchase.php:273
|
4499 |
#: includes/scripts.php:53
|
4500 |
msgid "Enter discount"
|
4501 |
msgstr ""
|
4502 |
|
4503 |
+
#: includes/checkout/template.php:731
|
4504 |
msgid "Agree to Terms?"
|
4505 |
msgstr ""
|
4506 |
|
4507 |
+
#: includes/checkout/template.php:742
|
4508 |
msgid "Show Terms"
|
4509 |
msgstr ""
|
4510 |
|
4511 |
+
#: includes/checkout/template.php:743
|
4512 |
msgid "Hide Terms"
|
4513 |
msgstr ""
|
4514 |
|
4515 |
+
#: includes/checkout/template.php:762
|
4516 |
msgid "Purchase Total:"
|
4517 |
msgstr ""
|
4518 |
|
4519 |
+
#: includes/checkout/template.php:788
|
4520 |
msgid "Go back"
|
4521 |
msgstr ""
|
4522 |
|
4523 |
+
#: includes/checkout/template.php:811
|
4524 |
msgid "Next"
|
4525 |
msgstr ""
|
4526 |
|
4527 |
+
#: includes/checkout/template.php:831
|
4528 |
msgid "Free Download"
|
4529 |
msgstr ""
|
4530 |
|
5520 |
msgid "Test Payment"
|
5521 |
msgstr ""
|
5522 |
|
5523 |
+
#: includes/gateways/functions.php:120 includes/gateways/functions.php:139
|
5524 |
msgid "Free Purchase"
|
5525 |
msgstr ""
|
5526 |
|
5527 |
+
#: includes/gateways/functions.php:221
|
5528 |
msgid "The requested price ID does not exist."
|
5529 |
msgstr ""
|
5530 |
|
6649 |
msgid "Serve Digital Downloads Through WordPress"
|
6650 |
msgstr ""
|
6651 |
|
6652 |
+
#: includes/admin/payments/view-order-details.php:466
|
6653 |
msgctxt "Address City"
|
6654 |
msgid "City:"
|
6655 |
msgstr ""
|
6656 |
|
6657 |
+
#: includes/admin/payments/view-order-details.php:471
|
6658 |
msgctxt "Zip / Postal code of address"
|
6659 |
msgid "Zip / Postal Code:"
|
6660 |
msgstr ""
|
6661 |
|
6662 |
+
#: includes/admin/payments/view-order-details.php:478
|
6663 |
msgctxt "Address country"
|
6664 |
msgid "Country:"
|
6665 |
msgstr ""
|
6666 |
|
6667 |
+
#: includes/admin/payments/view-order-details.php:492
|
6668 |
msgctxt "State / province of address"
|
6669 |
msgid "State / Province:"
|
6670 |
msgstr ""
|
6674 |
msgid "to"
|
6675 |
msgstr ""
|
6676 |
|
6677 |
+
#: includes/checkout/template.php:702
|
6678 |
msgctxt "Entering a discount code"
|
6679 |
msgid "Click to enter it"
|
6680 |
msgstr ""
|
6681 |
|
6682 |
+
#: includes/checkout/template.php:711
|
6683 |
msgctxt "Apply discount at checkout"
|
6684 |
msgid "Apply"
|
6685 |
msgstr ""
|
readme.txt
CHANGED
@@ -7,7 +7,7 @@ Tags: download, downloads, e-store, eshop, digital downloads, e-downloads, ecomm
|
|
7 |
Requires at least: 3.9.2
|
8 |
Tested up to: 4.2
|
9 |
|
10 |
-
Stable Tag: 2.4.
|
11 |
|
12 |
License: GNU Version 2 or Any Later Version
|
13 |
|
@@ -191,6 +191,25 @@ Yes, through the addition of one or more of the add-on payment gateways, you can
|
|
191 |
|
192 |
== Changelog ==
|
193 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
= 2.4.1, July 2, 2015 =
|
195 |
|
196 |
* Tweak: Updated Language Files
|
7 |
Requires at least: 3.9.2
|
8 |
Tested up to: 4.2
|
9 |
|
10 |
+
Stable Tag: 2.4.2
|
11 |
|
12 |
License: GNU Version 2 or Any Later Version
|
13 |
|
191 |
|
192 |
== Changelog ==
|
193 |
|
194 |
+
= 2.4.2, July 13, 2015 =
|
195 |
+
|
196 |
+
* Tweak: Allow filtering the ajax user search
|
197 |
+
* Tweak: Send first_name and last_name to PayPal
|
198 |
+
* Tweak: edd_filter_success_page_content() not run early enough
|
199 |
+
* Tweak: URLs to remove fees and items should not be caught by caching
|
200 |
+
* Tweak: Improve batch exporter extensibility
|
201 |
+
* Tweak: Add ABSPATH check to Amazon gateway files
|
202 |
+
* Fix: Multiple tax rates with same id in taxes settings
|
203 |
+
* Fix: Clarified opt-in messaging
|
204 |
+
* Fix: Microdata wrapper showing in sidebar
|
205 |
+
* Fix: Excerpt missing from products API Endpoint
|
206 |
+
* Fix: Customer search not working with name or email in API
|
207 |
+
* Fix: Invalid markup on profile editor save
|
208 |
+
* Fix: API Key fields caused fatal error when viewed in front end profile editors
|
209 |
+
* Fix: Invalid 'for' attribute in username label for login shortcode
|
210 |
+
* Fix: Correct edd_listen_for_failed_payments() sending post id, not WP_Post object
|
211 |
+
* Fix: Fix tax state not saving when text field
|
212 |
+
|
213 |
= 2.4.1, July 2, 2015 =
|
214 |
|
215 |
* Tweak: Updated Language Files
|
templates/shortcode-login.php
CHANGED
@@ -12,7 +12,7 @@ if ( ! is_user_logged_in() ) :
|
|
12 |
<span><legend><?php _e( 'Log into Your Account', 'edd' ); ?></legend></span>
|
13 |
<?php do_action( 'edd_login_fields_before' ); ?>
|
14 |
<p>
|
15 |
-
<label for="
|
16 |
<input name="edd_user_login" id="edd_user_login" class="required edd-input" type="text" title="<?php _e( 'Username', 'edd' ); ?>"/>
|
17 |
</p>
|
18 |
<p>
|
12 |
<span><legend><?php _e( 'Log into Your Account', 'edd' ); ?></legend></span>
|
13 |
<?php do_action( 'edd_login_fields_before' ); ?>
|
14 |
<p>
|
15 |
+
<label for="edd_user_login"><?php _e( 'Username', 'edd' ); ?></label>
|
16 |
<input name="edd_user_login" id="edd_user_login" class="required edd-input" type="text" title="<?php _e( 'Username', 'edd' ); ?>"/>
|
17 |
</p>
|
18 |
<p>
|
templates/shortcode-profile-editor.php
CHANGED
@@ -17,7 +17,7 @@ if ( is_user_logged_in() ):
|
|
17 |
<?php endif; ?>
|
18 |
|
19 |
<?php if ( isset( $_GET['updated'] ) && $_GET['updated'] == true && ! edd_get_errors() ): ?>
|
20 |
-
<div class="edd_success edd-alert edd-alert-success"><strong><?php _e( 'Success', 'edd'); ?>:</strong> <?php _e( 'Your profile has been edited successfully.', 'edd' );
|
21 |
<?php endif; ?>
|
22 |
|
23 |
<?php edd_print_errors(); ?>
|
17 |
<?php endif; ?>
|
18 |
|
19 |
<?php if ( isset( $_GET['updated'] ) && $_GET['updated'] == true && ! edd_get_errors() ): ?>
|
20 |
+
<div class="edd_success edd-alert edd-alert-success"><strong><?php _e( 'Success', 'edd'); ?>:</strong> <?php _e( 'Your profile has been edited successfully.', 'edd' ); ?></div>
|
21 |
<?php endif; ?>
|
22 |
|
23 |
<?php edd_print_errors(); ?>
|