How to get card.id from CreatePaymentResponse?

    object(Square\Models\CreatePaymentResponse)#54 (2) {
  ["errors":"Square\Models\CreatePaymentResponse":private]=>
  NULL
  ["payment":"Square\Models\CreatePaymentResponse":private]=>
  object(Square\Models\Payment)#56 (29) {
    ["id":"Square\Models\Payment":private]=>
    string(29) "ZkuZ4k9QmLx3PuiNo9ObmTvkFqKZY"
    ["createdAt":"Square\Models\Payment":private]=>
    string(24) "2021-02-04T19:31:20.420Z"
    ["updatedAt":"Square\Models\Payment":private]=>
    string(24) "2021-02-04T19:31:20.580Z"
    ["amountMoney":"Square\Models\Payment":private]=>
    object(Square\Models\Money)#55 (2) {
      ["amount":"Square\Models\Money":private]=>
      int(20)
      ["currency":"Square\Models\Money":private]=>
      string(3) "USD"
    }
    ["tipMoney":"Square\Models\Payment":private]=>
    NULL
    ["totalMoney":"Square\Models\Payment":private]=>
    object(Square\Models\Money)#143 (2) {
      ["amount":"Square\Models\Money":private]=>
      int(20)
      ["currency":"Square\Models\Money":private]=>
      string(3) "USD"
    }
    ["appFeeMoney":"Square\Models\Payment":private]=>
    NULL
    ["processingFee":"Square\Models\Payment":private]=>
    NULL
    ["refundedMoney":"Square\Models\Payment":private]=>
    NULL
    ["status":"Square\Models\Payment":private]=>
    string(9) "COMPLETED"
    ["delayDuration":"Square\Models\Payment":private]=>
    string(6) "PT168H"
    ["delayAction":"Square\Models\Payment":private]=>
    string(6) "CANCEL"
    ["delayedUntil":"Square\Models\Payment":private]=>
    string(24) "2021-02-11T19:31:20.420Z"
    ["sourceType":"Square\Models\Payment":private]=>
    string(4) "CARD"
    ["cardDetails":"Square\Models\Payment":private]=>
    object(Square\Models\CardPaymentDetails)#120 (15) {
      ["status":"Square\Models\CardPaymentDetails":private]=>
      string(8) "CAPTURED"
      ["card":"Square\Models\CardPaymentDetails":private]=>
      object(Square\Models\Card)#63 (11) {
        ["id":"Square\Models\Card":private]=>
        NULL
        ["cardBrand":"Square\Models\Card":private]=>
        string(4) "VISA"
        ["last4":"Square\Models\Card":private]=>
        string(4) "1111"
        ["expMonth":"Square\Models\Card":private]=>
        int(12)
        ["expYear":"Square\Models\Card":private]=>
        int(2021)
        ["cardholderName":"Square\Models\Card":private]=>
        NULL
        ["billingAddress":"Square\Models\Card":private]=>
        NULL
        ["fingerprint":"Square\Models\Card":private]=>
        string(71) "sq-1-oQl5Xk4jIBRmHw7P_SFUtOYriaYWfJn6SEpsWQs4ZoNgUVw9Y5yw2Ki40AEdA8fLbg"
        ["cardType":"Square\Models\Card":private]=>
        string(6) "CREDIT"
        ["prepaidType":"Square\Models\Card":private]=>
        NULL
        ["bin":"Square\Models\Card":private]=>
        string(6) "411111"
      }
      ["entryMethod":"Square\Models\CardPaymentDetails":private]=>
      string(7) "ON_FILE"
      ["cvvStatus":"Square\Models\CardPaymentDetails":private]=>
      string(15) "CVV_NOT_CHECKED"
      ["avsStatus":"Square\Models\CardPaymentDetails":private]=>
      string(12) "AVS_ACCEPTED"
      ["authResultCode":"Square\Models\CardPaymentDetails":private]=>
      NULL
      ["applicationIdentifier":"Square\Models\CardPaymentDetails":private]=>
      NULL
      ["applicationName":"Square\Models\CardPaymentDetails":private]=>
      NULL
      ["applicationCryptogram":"Square\Models\CardPaymentDetails":private]=>
      NULL
      ["verificationMethod":"Square\Models\CardPaymentDetails":private]=>
      NULL
      ["verificationResults":"Square\Models\CardPaymentDetails":private]=>
      NULL
      ["statementDescription":"Square\Models\CardPaymentDetails":private]=>
      string(24) "SQ *DEFAULT TEST ACCOUNT"
      ["deviceDetails":"Square\Models\CardPaymentDetails":private]=>
      NULL
      ["refundRequiresCardPresence":"Square\Models\CardPaymentDetails":private]=>
      NULL
      ["errors":"Square\Models\CardPaymentDetails":private]=>
      NULL
    }
    ["locationId":"Square\Models\Payment":private]=>
    string(13) "LYM125RN8XRX3"
    ["orderId":"Square\Models\Payment":private]=>
    string(28) "s9i3S9joeNLZQqxQ4xcFW7R6Rb4F"
    ["referenceId":"Square\Models\Payment":private]=>
    NULL
    ["customerId":"Square\Models\Payment":private]=>
    string(26) "S588F5KMQMXBD14TNKK9PY2FEC"
    ["employeeId":"Square\Models\Payment":private]=>
    NULL
    ["refundIds":"Square\Models\Payment":private]=>
    NULL
    ["riskEvaluation":"Square\Models\Payment":private]=>
    object(Square\Models\RiskEvaluation)#142 (2) {
      ["createdAt":"Square\Models\RiskEvaluation":private]=>
      string(24) "2021-02-04T19:31:20.528Z"
      ["riskLevel":"Square\Models\RiskEvaluation":private]=>
      string(6) "NORMAL"
    }
    ["buyerEmailAddress":"Square\Models\Payment":private]=>
    NULL
    ["billingAddress":"Square\Models\Payment":private]=>
    NULL
    ["shippingAddress":"Square\Models\Payment":private]=>
    NULL
    ["note":"Square\Models\Payment":private]=>
    NULL
    ["statementDescriptionIdentifier":"Square\Models\Payment":private]=>
    NULL
    ["receiptNumber":"Square\Models\Payment":private]=>
    string(4) "ZkuZ"
    ["receiptUrl":"Square\Models\Payment":private]=>
    string(73) "https://squareupsandbox.com/receipt/preview/ZkuZ4k9QmLx3PuiNo9ObmTvkFqKZY"
  }
}

Why I am not getting cardId in card object in createPaymentResponse?

Hi @hvsharma welcome to the forums!

A card will only have an id when using CreateCustomerCard endpoint and saving it to a customer. So you’ll need to save the card first before you’re able to see an id. Right now, you cannot use a card again without saving it on file.

I have already saved it in a customer. The flow is. I display cards from Customer listing API. User selects any existing card for completing the payment. At that time, I already have the Card ID, Since during first time payment I’ve had it added to the customer. So I’ve Customer ID, Card ID and amount. Now, I just need to add all these details on create payment request.
So I did the same. I already have the Card ID, But I was hoping, we could get it anyway from createpayment response.

Ah, I see. Thanks for clarifying! I think even if you use the card_id on the CreatePayment request, it will not show up in the CreatePaymentResponse unfortunately, only in the Customer object.

If I may ask, is there any reason for card_id not being there in CreatePaymentResponse ?

Honestly I do not know sorry to say :slight_smile: . I can update this to be a feature request to see if one of our PMs would like to chime in.

1 Like