I’m trying to use the following flow (the data is all converted to JSON):
1 - submit a payment (success)
2 - create a customer using the payment’s source_id (success)
3 - save a card related to the customer using the source_id and customer_id (FAIL)
I Send a payment with a response of:
Payment response:Array
(
[payment] => Array
(
[id] => 73BQjUJutcF8LdmqHX0Twbom6R8YY
[created_at] => 2021-09-27T22:03:07.481Z
[updated_at] => 2021-09-27T22:03:07.671Z
[amount_money] => Array
(
[amount] => 33048
[currency] => GBP
)
[status] => COMPLETED
[delay_duration] => PT168H
[source_type] => CARD
[card_details] => Array
(
[status] => CAPTURED
[card] => Array
(
[card_brand] => VISA
[last_4] => 1019
[exp_month] => 11
[exp_year] => 2022
[fingerprint] => sq-1-oqGDocPJcaleGojsHKQx2qvtBIcTKJn7hbgPy70oPwF8iTvjkQA7xpV8BTR6AWen0w
[card_type] => CREDIT
[prepaid_type] => NOT_PREPAID
[bin] => 431000
)
[entry_method] => KEYED
[cvv_status] => CVV_ACCEPTED
[avs_status] => AVS_ACCEPTED
[statement_description] => SQ *DEFAULT TEST ACCOUNT
[card_payment_timeline] => Array
(
[authorized_at] => 2021-09-27T22:03:07.593Z
[captured_at] => 2021-09-27T22:03:07.671Z
)
)
[location_id] => L1C7FNP4HA3FJ
[order_id] => OeuTJe74ZaVfzfFvr8mF5fXI6OIZY
[reference_id] => 6416
[risk_evaluation] => Array
(
[created_at] => 2021-09-27T22:03:07.593Z
[risk_level] => NORMAL
)
[buyer_email_address] => [email protected]
[shipping_address] => Array
(
[address_line_1] => The Queens Walk
[locality] => London
[administrative_district_level_1] => LDN
[postal_code] => se1
[country] => GB
)
[note] => Order: 6416
[total_money] => Array
(
[amount] => 33048
[currency] => GBP
)
[approved_money] => Array
(
[amount] => 33048
[currency] => GBP
)
[receipt_number] => 73BQ
[receipt_url] => https://squareupsandbox.com/receipt/preview/73BQjUJutcF8LdmqHX0Twbom6R8YY
[delay_action] => CANCEL
[delayed_until] => 2021-10-04T22:03:07.481Z
[version_token] => j0Lzr70WIGcrIN9n4MKyKZzJLP6l7xixDgLkklTUdQ45o
)
)
I then create a customer using a source_id of 73BQjUJutcF8LdmqHX0Twbom6R8YY which returns an ‘id’ of JAHTXJJNR0WDN0RD9NC2VMH94M
I attempt to create a card for that customer using:
squarepay::send_request(https://connect.squareupsandbox.com/v2/cards): request:Array
(
[type] => post
[url] => https://connect.squareupsandbox.com/v2/cards
[send_data] => Array
(
[source_id] => 73BQjUJutcF8LdmqHX0Twbom6R8YY
[card] => Array
(
[card_brand] => VISA
[last_4] => 1019
[exp_month] => 11
[exp_year] => 2022
[fingerprint] => sq-1-oqGDocPJcaleGojsHKQx2qvtBIcTKJn7hbgPy70oPwF8iTvjkQA7xpV8BTR6AWen0w
[card_type] => CREDIT
[prepaid_type] => NOT_PREPAID
[bin] => 431000
[customer_id] => JAHTXJJNR0WDN0RD9NC2VMH94M
[cardholder_name] => Tony 1
)
[idempotency_key] => sq_card_uk-dev346761523f9bb2eb2
)
[headers] => Array
(
[0] => Authorization: Bearer EAAAEGp_Q7nYSFoymliCdDqkJOR4Y8KPhUjP7kOOcKDsee_VEICOJHnzFNQYP8p2
[1] => Accept: application/json
)
)
But it FAILS with:
squarepay::send_request(https://connect.squareupsandbox.com/v2/cards): response:Array
(
[errors] => Array
(
[0] => Array
(
[category] => INVALID_REQUEST_ERROR
[code] => INVALID_CARD_DATA
[detail] => Invalid card data.
[field] => source_id
)
)
)