4040import io .snabble .sdk .Snabble ;
4141import io .snabble .sdk .payment .data .GiropayAuthorizationData ;
4242import io .snabble .sdk .payment .data .GiropayData ;
43+ import io .snabble .sdk .payment .data .PayoneData ;
4344import io .snabble .sdk .payment .externalbilling .data .ExternalBillingPaymentCredentials ;
4445import io .snabble .sdk .payment .payone .sepa .PayoneSepaData ;
4546import io .snabble .sdk .utils .GsonHolder ;
@@ -153,18 +154,6 @@ private static class DatatransData {
153154 private String expiryYear ;
154155 }
155156
156- private static class PayoneData {
157- PayoneData (String pseudoCardPAN , String name , String userID ) {
158- this .pseudoCardPAN = pseudoCardPAN ;
159- this .name = name ;
160- this .userID = userID ;
161- }
162-
163- private final String pseudoCardPAN ;
164- private final String name ;
165- private final String userID ;
166- }
167-
168157 private static class TegutEmployeeCard {
169158 private String cardNumber ;
170159 }
@@ -470,18 +459,23 @@ public static PaymentCredentials fromDatatrans(String token, Brand brand, String
470459 /**
471460 * Encrypts and stores a payone pseudo card pan.
472461 */
473- public static PaymentCredentials fromPayone (String pseudocardpan ,
474- String truncatedcardpan ,
475- PaymentCredentials .Brand brand ,
476- String cardexpiredate ,
477- String lastname ,
478- String userId ,
479- String projectId ) {
480- if (pseudocardpan == null ) {
481- return null ;
482- }
483-
484- PaymentCredentials pc = new PaymentCredentials ();
462+ @ Nullable
463+ public static PaymentCredentials fromPayone (
464+ @ NonNull final String pseudoCardPan ,
465+ @ NonNull final String truncatedCardPan ,
466+ @ NonNull final PaymentCredentials .Brand brand ,
467+ @ NonNull final String cardExpiryDate ,
468+ @ NonNull final String lastname ,
469+ @ NonNull final String street ,
470+ @ NonNull final String zip ,
471+ @ NonNull final String city ,
472+ @ NonNull final String country ,
473+ @ Nullable final String state ,
474+ @ NonNull final String email ,
475+ @ Nullable final String userId ,
476+ @ NonNull final String projectId
477+ ) {
478+ final PaymentCredentials pc = new PaymentCredentials ();
485479 pc .generateId ();
486480 if (brand == Brand .MASTERCARD || brand == Brand .AMEX || brand == Brand .VISA ) {
487481 pc .type = Type .PAYONE_CREDITCARD ;
@@ -490,22 +484,32 @@ public static PaymentCredentials fromPayone(String pseudocardpan,
490484 }
491485 pc .projectId = projectId ;
492486
493- List <X509Certificate > certificates = Snabble .getInstance ().getPaymentCertificates ();
494- if (certificates . size () == 0 ) {
487+ final List <X509Certificate > certificates = Snabble .getInstance ().getPaymentCertificates ();
488+ if (certificates == null || certificates . isEmpty () ) {
495489 return null ;
496490 }
497491
498- PayoneData payoneData = new PayoneData (pseudocardpan , lastname , userId );
492+ final PayoneData payoneData = new PayoneData (
493+ pseudoCardPan ,
494+ lastname ,
495+ email ,
496+ street ,
497+ zip ,
498+ city ,
499+ country ,
500+ state ,
501+ userId
502+ );
499503
500- String json = GsonHolder .get ().toJson (payoneData , PayoneData .class );
504+ final String json = GsonHolder .get ().toJson (payoneData , PayoneData .class );
501505
502- X509Certificate certificate = certificates .get (0 );
506+ final X509Certificate certificate = certificates .get (0 );
503507 pc .rsaEncryptedData = pc .rsaEncrypt (certificate , json .getBytes ());
504508 pc .signature = pc .sha256Signature (certificate );
505509 pc .appId = Snabble .getInstance ().getConfig ().appId ;
506510 pc .brand = brand ;
507- pc .obfuscatedId = truncatedcardpan ;
508- pc .validTo = parseValidTo ("yyMM" , cardexpiredate );
511+ pc .obfuscatedId = truncatedCardPan ;
512+ pc .validTo = parseValidTo ("yyMM" , cardExpiryDate );
509513
510514 if (pc .rsaEncryptedData == null ) {
511515 return null ;
0 commit comments