0

I'm running a marketplace website using Dokan Pro where I have integrated Stripe Connect. Now I want to integrate iDeal with it but they don't have it officially so I'm following Stripe's documentation to do some custom coding but I'm not able to achieve anything so far.

Stripe provided me this documentation:

https://stripe.com/docs/connect/direct-charges#create-a-charge

There's an official plugin on Stripe For Woocommerce that also has iDeal option but the problem is that it doesn't split payment because it doesn't work with Stripe Connect. I did try to edit it's code but it gives me an error when I send the application_fee parameter. Here's the code:

public function create_source( $order ) {
    $currency              = $order->get_currency();
    $return_url            = $this->get_stripe_return_url( $order );
    $post_data             = array();
    $post_data['amount']   = WC_Stripe_Helper::get_stripe_amount( $order->get_total(), $currency );
    $post_data['currency'] = strtolower( $currency );
    $post_data['type']     = 'ideal';
    $post_data['application_fee_amount']     = '10';
    $post_data['owner']    = $this->get_owner_details( $order );
    $post_data['redirect'] = array( 'return_url' => $return_url );

    if ( ! empty( $this->statement_descriptor ) ) {
        $post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor( $this->statement_descriptor );
    }

    WC_Stripe_Logger::log( 'Info: Begin creating iDeal source' );

    return WC_Stripe_API::request( apply_filters( 'wc_stripe_ideal_source', $post_data, $order ), 'sources' );
}

Any help would be appreciated.

  • Can you share the error details you're getting, and say more about what you mean by "Split Payments"? I'm going to make some assumptions and answer below, but will update if needed. – Nolan H Oct 05 '20 at 20:30

1 Answers1

0

Assumption: I'm assuming for "split payments" you mean to handle when a customer does a single order/payment to your platform which includes goods/services from more than one provider. You need to allocate the payment and send some of it to more than one destination account.

A couple of items that I think are making things difficult for you:

  • Rather than Sources, I'd recommend looking at the updated Payment Intents guide for iDEAL. You should find this aligns much better with all the most recent documentation across Stripe's API.
  • If you're intending to split payments to multiple recipients, you will not be able to do so with direct charges. Instead, you should use "Separate Charges & Transfers" to allow you to send portions of the payment to more than one provider of goods/services.

On server:

// Create a PaymentIntent:
$paymentIntent = \Stripe\PaymentIntent::create([
  'amount' => 10000,
  'currency' => 'eur',
  'payment_method_types' => ['ideal'],
  'transfer_group' => 'YOUR_ORDER_ID_123',
]);

// Send $paymentIntent->client_secret to the client

On client:

//HTML
<div id="ideal-bank-element">
  <!-- A Stripe Element will be inserted here. -->
</div>

//JS
// Create an instance of the idealBank Element
var idealBank = elements.create('idealBank', options);

// Add an instance of the idealBank Element into
// the `ideal-bank-element` <div>
idealBank.mount('#ideal-bank-element');
...
    stripe.confirmIdealPayment(
    '{{PAYMENT_INTENT_CLIENT_SECRET}}',
    {
      payment_method: {
        ideal: idealBank,
        billing_details: {
          name: accountholderName.value,
        },
      },
      return_url: 'https://your-website.com/checkout/complete',
    }
  );

On server, later:

// Create a Transfer to a connected account (later):
$transfer = \Stripe\Transfer::create([
  'amount' => 7000,
  'currency' => 'eur',
  'destination' => 'acct_123',
  'transfer_group' => 'YOUR_ORDER_ID_123',
]);

// Create a second Transfer to another connected account (later):
$transfer = \Stripe\Transfer::create([
  'amount' => 2000,
  'currency' => 'eur',
  'destination' => 'acct_456',
  'transfer_group' => 'YOUR_ORDER_ID_123',
]);
Nolan H
  • 6,205
  • 1
  • 5
  • 19
  • I appreciate your detailed answer. Let me give you some explanation. So I'm using Dokan Pro on my website and it has a module Stripe Connected integrated with it. It supports card payments & splits them correctly to our connected Stripe connect. I want the same functionality through iDeal which Dokan doesn't have integrated. I spoke to Stripe, they provided me the documentation which I shared above so I just need a clue where should the split is happening in the code so I can have an idea and integrate the same with iDeal. – Syed Ali Azlan Oct 06 '20 at 08:16
  • Yep, then what I answered is what you need. Separate charges and transfers is how to split payments. – Nolan H Oct 06 '20 at 15:11