Support » Plugin: Peach Payments Gateway » Support for WooGraphQL

  • Resolved simonbuerger

    (@simonbuerger)


    Hi there

    I’d like to request first class support for WooGraphQL – it’s a popular option for using graphql with woocommerce and I was able to make peach payments (version 2 anyway, haven’t tried 3) work with it with a few additions to my functions.php

    But there is still some flakiness and it would be great to have “official” support as some of it is a bit of a hack as I need to artificially add stuff to $_POST in places where it doesn’t feel right

    // Add saved cards to graphql
    register_graphql_object_type('PeachPaymentsSavedCard', [
      'description' => __('Describe the Type and what it represents', 'wp-graphql'),
      'fields' => [
          'payment_id' => [
            'type' => 'String',
            'description' => __('Card registration ID', 'wp-graphql'),
          ],
          'active_card' => [
              'type' => 'String',
              'description' => __('Last 4 digits', 'wp-graphql'),
          ],
          'exp_month' => [
            'type' => 'String',
            'description' => __('Expiry Month', 'wp-graphql'),
          ],
          'exp_year' => [
            'type' => 'String',
            'description' => __('Expiry Year', 'wp-graphql'),
          ],
          'brand' => [
            'type' => 'string',
            'description' => __('Card brand', 'wp-graphql'),
          ],
      ],
    ]);
    
    add_action( 'graphql_register_types', function() {
      register_graphql_field( 'Customer', 'peachPaymentsSavedCards', [
         'type' => [ 'list_of' => 'PeachPaymentsSavedCard' ],
         'description' => __( 'Saved cards from Peach Payments', 'wp-graphql' ),
         'resolve' => function( $customer ) {
            $credit_cards = get_user_meta(  $customer->databaseId, '_peach_payment_id', false );
            return $credit_cards ? $credit_cards : array();
        }
      ] );
    } );
    
    add_action( 'graphql_woocommerce_before_checkout', function() {
      $_POST['peach_payment_id'] = 'dontsave';
    } );
    
    add_filter( 'graphql_peach-payments_process_payment_args',  function ($args) {
      $peach_payment_id = get_post_meta($args[0], '_peach_payment_id', true);
      if (isset($peach_payment_id))
      {
        $_POST['peach_payment_id'] = $peach_payment_id;
      } else
      {
        $_POST['peach_payment_id'] = 'dontsave';
      }
      return $args;
    });

    This is the current code I have in my theme, and after doing a checkout mutation I redirect to the redirect url for payment/completion

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author peachpayments

    (@peachpayments)

    @simonbuerger we are taking a look at this. We will do a release in a future update with the support. I have logged this with the development team.

    Plugin Author peachpayments

    (@peachpayments)

    @simonbuerger We have spoken to the development team and they have some reservations about bundling the code from wp-graphql into the Peach Payments code plugin. We could consider building an extension in future that is managed separately. But this will be dependent on requests we get from users.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.