@@ -64,7 +64,7 @@ public InvoiceClient(
6464 * @throws BitPayException BitPayException class
6565 * @throws InvoiceCreationException InvoiceCreationException class
6666 */
67- public Invoice createInvoice (Invoice invoice , Facade facade , Boolean signRequest ) throws BitPayException ,
67+ public Invoice create (Invoice invoice , Facade facade , Boolean signRequest ) throws BitPayException ,
6868 InvoiceCreationException {
6969 if (Objects .isNull (invoice ) || Objects .isNull (facade )) {
7070 throw new InvoiceCreationException (null , "missing required parameter" );
@@ -106,7 +106,7 @@ public Invoice createInvoice(Invoice invoice, Facade facade, Boolean signRequest
106106 * @throws BitPayException BitPayException class
107107 * @throws InvoiceQueryException InvoiceQueryException class
108108 */
109- public Invoice getInvoice (String invoiceId , Facade facade , Boolean signRequest ) throws BitPayException ,
109+ public Invoice get (String invoiceId , Facade facade , Boolean signRequest ) throws BitPayException ,
110110 InvoiceQueryException {
111111 final List <BasicNameValuePair > params = new ArrayList <BasicNameValuePair >();
112112 ParameterAdder .execute (params , "token" , this .accessTokens .getAccessToken (facade ));
@@ -138,7 +138,7 @@ public Invoice getInvoice(String invoiceId, Facade facade, Boolean signRequest)
138138 * @return A BitPay Invoice object.
139139 * @throws InvoiceQueryException InvoiceQueryException class
140140 */
141- public Invoice getInvoiceByGuid (String guid , Facade facade , Boolean signRequest ) throws InvoiceQueryException {
141+ public Invoice getByGuid (String guid , Facade facade , Boolean signRequest ) throws InvoiceQueryException {
142142 if (Objects .isNull (guid ) || Objects .isNull (facade )) {
143143 throw new InvoiceQueryException (null , "missing required parameters" );
144144 }
@@ -252,7 +252,7 @@ public InvoiceEventToken getInvoiceEventToken(String invoiceId) throws BitPayExc
252252 * @throws BitPayException BitPayException class
253253 * @throws InvoiceUpdateException InvoiceUpdateException class
254254 */
255- public Invoice updateInvoice (
255+ public Invoice update (
256256 String invoiceId ,
257257 String buyerSms ,
258258 String smsCode ,
@@ -304,27 +304,6 @@ public Invoice updateInvoice(
304304 return invoice ;
305305 }
306306
307- private void validateSmsCode (String buyerSms , String smsCode , Boolean autoVerify ) throws InvoiceUpdateException {
308- if (Objects .isNull (autoVerify )) {
309- return ;
310- }
311-
312- if (autoVerify ) {
313- return ;
314- }
315-
316- if (Objects .nonNull (buyerSms ) && Objects .nonNull (smsCode )) {
317- return ;
318- }
319-
320- if (Objects .isNull (buyerSms ) && Objects .isNull (smsCode )) {
321- return ;
322- }
323-
324- throw new InvoiceUpdateException (null ,
325- "If provided alongside a valid SMS, will bypass the need to complete an SMS challenge" );
326- }
327-
328307 /**
329308 * Pay a BitPay invoice with a mock transaction.
330309 *
@@ -334,7 +313,7 @@ private void validateSmsCode(String buyerSms, String smsCode, Boolean autoVerify
334313 * @throws BitPayException BitPayException class
335314 * @throws InvoiceUpdateException InvoiceUpdateException class
336315 */
337- public Invoice payInvoice (String invoiceId , String status ) throws BitPayException , InvoiceUpdateException {
316+ public Invoice pay (String invoiceId , String status ) throws BitPayException , InvoiceUpdateException {
338317 final Map <String , Object > params = new HashMap <>();
339318 params .put ("token" , this .accessTokens .getAccessToken (Facade .MERCHANT ));
340319 if (status != null ) {
@@ -372,9 +351,9 @@ public Invoice payInvoice(String invoiceId, String status) throws BitPayExceptio
372351 * @throws InvoiceCancellationException InvoiceCancellationException class
373352 * @throws BitPayException BitPayException class
374353 */
375- public Invoice cancelInvoice (String invoiceId ) throws InvoiceCancellationException , BitPayException {
354+ public Invoice cancel (String invoiceId ) throws InvoiceCancellationException , BitPayException {
376355 try {
377- return this .cancelInvoice (invoiceId , false );
356+ return this .cancel (invoiceId , false );
378357 } catch (BitPayException ex ) {
379358 throw new InvoiceCancellationException (ex .getStatusCode (), ex .getReasonPhrase ());
380359 } catch (Exception e ) {
@@ -391,7 +370,7 @@ public Invoice cancelInvoice(String invoiceId) throws InvoiceCancellationExcepti
391370 * @throws InvoiceCancellationException InvoiceCancellationException class
392371 * @throws BitPayException BitPayException class
393372 */
394- public Invoice cancelInvoice (String invoiceId , Boolean forceCancel )
373+ public Invoice cancel (String invoiceId , Boolean forceCancel )
395374 throws InvoiceCancellationException , BitPayException {
396375 final List <BasicNameValuePair > params = new ArrayList <BasicNameValuePair >();
397376 ParameterAdder .execute (params , "token" , this .accessTokens .getAccessToken (Facade .MERCHANT ));
@@ -413,7 +392,7 @@ public Invoice cancelInvoice(String invoiceId, Boolean forceCancel)
413392 return invoice ;
414393 }
415394
416- public Invoice cancelInvoiceByGuid (String guid , Boolean forceCancel ) throws BitPayException {
395+ public Invoice cancelByGuid (String guid , Boolean forceCancel ) throws BitPayException {
417396 if (Objects .isNull (guid ) || Objects .isNull (forceCancel )) {
418397 throw new InvoiceCancellationException (null , "missing required parameter" );
419398 }
@@ -470,4 +449,25 @@ private void validateRequiredField(String buyerSms, String buyerEmail) throws In
470449 throw new InvoiceUpdateException (null , "Updating an invoice will require EITHER an SMS or E-mail)" );
471450 }
472451 }
452+
453+ private void validateSmsCode (String buyerSms , String smsCode , Boolean autoVerify ) throws InvoiceUpdateException {
454+ if (Objects .isNull (autoVerify )) {
455+ return ;
456+ }
457+
458+ if (autoVerify ) {
459+ return ;
460+ }
461+
462+ if (Objects .nonNull (buyerSms ) && Objects .nonNull (smsCode )) {
463+ return ;
464+ }
465+
466+ if (Objects .isNull (buyerSms ) && Objects .isNull (smsCode )) {
467+ return ;
468+ }
469+
470+ throw new InvoiceUpdateException (null ,
471+ "If provided alongside a valid SMS, will bypass the need to complete an SMS challenge" );
472+ }
473473}
0 commit comments