File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ Buy Now buttons are for single item purchases.
1111
1212``` html
1313<script src =" paypal.js?merchant=MERCHANT_ID"
14- data-type =" buy "
14+ data-type =" buynow "
1515 data-item_name =" Buy me now!"
1616 data-amount =" 1.00"
1717></script >
Original file line number Diff line number Diff line change @@ -40,13 +40,21 @@ PAYPAL.apps = PAYPAL.apps || {};
4040 * @param el {HTMLElement} The element to replace
4141 * @param type (String) The type of the button to render
4242 * @param data {Object} An object of key/value data to set as button params
43+ * @return {Boolean }
4344 */
4445 app . renderButton = function ( el , type , data ) {
4546 var merchantId = el . src . split ( '?merchant=' ) [ 1 ] ,
4647 form = document . createElement ( 'form' ) ,
4748 btn = document . createElement ( 'input' ) ,
4849 hidden = document . createElement ( 'input' ) ,
49- btn , hidden , input , key ;
50+ input , key ;
51+
52+ // Don't render if there's no merchant ID
53+ if ( merchantId ) {
54+ data . business = merchantId ;
55+ } else {
56+ return false ;
57+ }
5058
5159 btn . type = 'image' ;
5260 hidden . type = 'hidden' ;
@@ -69,10 +77,6 @@ PAYPAL.apps = PAYPAL.apps || {};
6977 btn . src = BUY_BTN_URL ;
7078 }
7179
72- if ( merchantId ) {
73- data . business = merchantId
74- }
75-
7680 for ( key in data ) {
7781 input = hidden . cloneNode ( true ) ;
7882 input . name = key ;
@@ -92,6 +96,8 @@ PAYPAL.apps = PAYPAL.apps || {};
9296 PAYPAL . apps . MiniCart . render ( ) ;
9397 } , 'PAYPAL.apps.MiniCart' ) ;
9498 }
99+
100+ return true ;
95101 } ;
96102
97103 /**
You can’t perform that action at this time.
0 commit comments