Card Payments API

You can integrate your e-commerce application directly to our platform-agnostic Card Payments API and process all major credit cards through the Paysafe payment gateway.

Click the links below to view our code samples.

Verify That the Service Is Accessible

boolean isOnline = apiClient.cardPaymentService().monitor();

Authorize a Card Payment

Process an authorization
Authorization auth =
   Authorization.builder()
     .merchantRefNum("0f8fad5bd9cb469fa16570867728950e")
     .amount(555)
     .card()
       .cardNum("4111111111111111")
       .cvv(123)
       .cardExpiry()
         .month(2)
         .year(2017)
         .done()
       .done()
     .billingDetails()
      .zip("M5H 2N2")
      .done()
     .build();

 Authorization response = apiClient.cardPaymentService().authorize(auth);
Process a complex authorization
Authorization auth =
       Authorization.builder()
         .merchantRefNum("0f8fad5bd9cb469fa16570867728950e")
         .amount(6666)
         .settleWithAuth(false)
         .card()
           .cardNum("4111111111111111")
           .cvv(123)
           .cardExpiry()
             .month(2)
             .year(2017)
             .done()
           .done()
         .authentication()
           .eci(5)
           .cavv("AAABCIEjYgAAAAAAlCNiENiWiV+=")
           .xid("OU9rcTRCY1VJTFlDWTFESXFtTHU=")
           .threeDEnrollment("Y")
           .threeDResult("Y")
           .signatureStatus("Y")
           .done()
         .billingDetails()
           .street("100 Queen Street West")
           .city("Toronto")
           .state("ON")
           .country("CA")
           .zip("M5H 2N2")
           .done()
         .shippingDetails()
           .carrier("UPS")
           .shipMethod("N")
           .street("100 Queen Street West")
           .city("Toronto")
           .state("ON")
           .country("CA")
           .zip("M5H 2N2")
           .done()
         .customerIp("204.91.0.12")
         .description("Got U a video")
         .build();

     Authorization response = apiClient.cardPaymentService().authorize(auth);
Look up an authorization using an authorization ID
Authorization authResponse = apiClient.cardPaymentService().getAuth(auth.getId());
Look up an authorization using a merchant reference number
AuthorizationQuery newAuth =
    AuthorizationQuery.builder()
      .account(accountNumber)
      .merchantRefNum("0f8fad5bd9cb469fa16570867728950e")
      .build();

AuthorizationResultSet auths = apiClient.cardPaymentService().query(newAuth);

Process a Card Purchase

Process a purchase
Authorization auth =
       Authorization.builder()
         .merchantRefNum("0f8fad5bd9cb469fa16570867728950e")
         .amount(10098)
         .settleWithAuth(true)
         .card()
           .cardNum("4111111111111111")
           .cvv(123)
           .cardExpiry()
             .month(2)
             .year(2023)
             .done()
           .done()
         .billingDetails()
           .zip("M5H 2N2")
         .done()
         .build();

     apiClient.cardPaymentService().authorize(auth);
Void (reverse) an authorization
Authorization authResponse = makeAuthRequest("processAuthReversal");

AuthorizationReversal voidAuth =
    AuthorizationReversal.builder()
      .merchantRefNum(authResponse.getMerchantRefNum())
      .amount(555)
      .authorizationId(authResponse.getId())
      .build();

AuthorizationReversal voidAuthResponse = apiClient.cardPaymentService().voidAuth(voidAuth);
Process a partial void (partial reversal)
Authorization authResponse = makeAuthRequest("processPartialAuthReversal");

AuthorizationReversal voidAuth =
    AuthorizationReversal.builder()
      .merchantRefNum(authResponse.getMerchantRefNum())
      .authorizationId(authResponse.getId())
      .amount(333)
      .build();

AuthorizationReversal voidAuthResponse = apiClient.cardPaymentService().voidAuth(voidAuth);
Look up a void (reversal) using an void ID (authorization reversal ID)
AuthorizationReversalId authLookup = auth.getId();
AuthorizationReversal authLookupResponse = apiClient.cardPaymentService().getAuthReversal(authLookup);
Look up a void (reversal) using a merchant reference number
AuthorizationReversalQuery authLookup =
    AuthorizationReversalQuery.builder()
      .merchantRefNum("0f8fad5bd9cb469fa16570867728950e")
      .build();

AuthorizationReversalResultSet results = apiClient.cardPaymentService().query(authLookup);
Approve a held authorization
apiClient.cardPaymentService().approveHeldAuth(auth.getId());
Cancel a held authorization
apiClient.cardPaymentService().cancelHeldAuth(auth.getId());

Settle a Card Authorization

Settle an authorization
Settlement settlement =
    Settlement.builder()
      .authorizationId(auth.getId())
      .merchantRefNum("0f8fad5bd9cb469fa16570867728950e")
      .build();

Settlement settlementResponse = apiClient.cardPaymentService().settlement(settlement);
Cancel a settlement
apiClient.cardPaymentService().cancelSettlement(settlementResponse.getId());
Look up a settlement using a settlement ID
Settlement settleLookupResponse = apiClient.cardPaymentService().getSettlement(settlementResponse.getId());
Look up a settlement using a merchant reference number
SettlementQuery querySettlements =
   SettlementQuery.builder()
     .merchantRefNum("0f8fad5bd9cb469fa16570867728950e")
     .build();

 SettlementResultSet settlements = apiClient.cardPaymentService().query(querySettlements);

Process a Card Refund

Process a refund
Refund refund = Refund.builder()
    .settlementId(settlement.getId())
    .merchantRefNum("0f8fad5bd9cb469fa16570867728950e")
    .build();

Refund refundResponse = apiClient.cardPaymentService().refund(refund);
Look up a refund using a refund ID
Refund refundResponse = apiClient.cardPaymentService().getRefund(refund.getId());
Look up a refund using a merchant reference number
RefundQuery query = RefundQuery.builder()
    .merchantRefNum("0f8fad5bd9cb469fa16570867728950e")
    .build();

RefundResultSet refundResultSet = apiClient.cardPaymentService().query(query);

Verify a Card Payment

Verify card and billing details
Verification verification =
    Verification.builder()
      .merchantRefNum("0f8fad5bd9cb469fa16570867728950e")
      .card()
        .cardNum("4111111111111111")
        .cardExpiry()
          .month(3)
          .year(2023)
          .done()
          .cvv( "234" )
        .done()
      .profile()
        .firstName(getRandomChars("Joe"))
        .lastName("Smith")
        .email("Joe.Smith@canada.com")
        .done()
      .billingDetails()
        .street("100 Queen Street West")
        .city("Toronto")
        .state("ON")
        .country("CA")
        .zip("M5H2N2")
        .done()
      .customerIp("209.91.0.12")
      .description("This is a test transaction")
      .build();

Verification verificationResponse = apiClient.cardPaymentService().verify(verification);
Look up a verification using a verification ID
Verification verificationResponse = apiClient.cardPaymentService().getVerification(verification.getId());
Look up a verification using a merchant reference number
VerificationQuery queryVerification =
  VerificationQuery.builder()
    .merchantRefNum("0f8fad5bd9cb469fa16570867728950e")
    .build();

VerificationResultSet verifications = apiClient.cardPaymentService().query(queryVerification);
Did you find this page useful?