Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only split/explode the payment meta by ":" once #232

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

james-allan
Copy link
Contributor

@james-allan james-allan commented Jan 18, 2021

Issue: #221

Description:

Some payment gateway tokens, like Square, include a ':' character in the token itself. When exporting payment gateway data we concatenate the key and meta value with a ':' (see example below) and so splitting the value by ':' resulted in only saving the first half of the token.

This commit ensures we only explode/split the value once so the second half of the key is preserved.

Steps to test this PR:

  1. Export your own Square subscriptions (only 1 is needed) via WooCommerce > Export Subscriptions making sure to include the payment data or...
  2. Download the test csv here: https://d.pr/f/vvQlJf
    • This csv includes export data for 5 of my Square subscriptions.
    • The data is anonymised.
    • There are no line items exported so you won't need to worry about misaligned product IDs.
    • The subscriptions will be for customer ID 1.
  3. Import the exported csv.
  4. The default import mapping should be fine, just make sure the payment meta is correct (https://d.pr/i/t5EUZQ).
  5. Import.
  6. View the resulting subscription.

Some payment gateway (like Square) tokens include a ':' character in the token.
When exporting payment gateway data we concat the key and meta value
with a ':' (see example below) and so splitting the value by ':' resulted in only saving the
first half of the token.

This commit ensures we only explode/split the value once so the second half of the key is preserved.

Example Square export value:
"_wc_square_credit_card_payment_token:ccof:xyz|_wc_square_credit_card_customer_id:abc"
Copy link

@sun sun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good and only splitting into key/value certainly was the intention here.

@@ -551,7 +551,8 @@ public static function set_payment_meta( $subscription, $data ) {

if ( ! empty( $data[ self::$fields['payment_method_post_meta'] ] ) ) {
foreach ( explode( '|', $data[ self::$fields['payment_method_post_meta'] ] ) as $meta ) {
list( $name, $value ) = explode( ':', $meta );
// Some payment gateway meta (like Square), includes a ':' in the token so limit the explode to only split once (2 values).
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Some payment gateway meta (like Square), includes a ':' in the token so limit the explode to only split once (2 values).
// Some payment gateway meta values contain a colon (e.g. Square token).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants