Payment gateways are “methods” of accepting payments for purchases through Easy Digital Downloads. By default, the plugin comes with two payment gateways: PayPal Standard and Manual Payment. Due to the extensible nature of the plugin, add-on payment gateways can be created, of which there are quite a few available. We can have a gateway to process payments through Stripe, Moneybookers, or many, many others. In this tutorial, I’m going to walk you through the process of creating your own custom payment gateway.

NOTE: this tutorial is severely out of date though some of the methods are still applicable today.

Introduction

There are four primary sections to a payment gateway in Easy Digital Downloads:

  1. Registering the gateway
  2. Setting up the credit card form, if any
  3. Processing the payment
  4. Adding the gateway settings for API keys and such

We will go through the process step by step.

Registering the Gateway

By registering the payment gateway, we make it available for use. This process also makes the gateway appear in the Payment Gateways list, shown below:

Adding our own custom gateway is very simple, it is just one function attached to a filter. The structure of the function looks like this:

// registers the gateway
function pw_edd_register_gateway($gateways) {
	$gateways['gateway_id'] = array('admin_label' => 'Label Shown in the Admin', 'checkout_label' => __('Label Shown on Checkout', 'your_textdomain'));
	return $gateways;
}
add_filter('edd_payment_gateways', 'pw_edd_register_gateway');

Replace the place holders with actual values and we get this:

// registers the gateway
function pw_edd_register_gateway($gateways) {
	$gateways['sample_gateway'] = array('admin_label' => 'Sample Gateway', 'checkout_label' => __('Sample Gateway', 'pw_edd'));
	return $gateways;
}
add_filter('edd_payment_gateways', 'pw_edd_register_gateway');

That’s it. Your gateway will now be available in the list of Payment Gateways in the settings for Easy Digital Downloads. You can enable it and select it as your method of payment during checkout. It won’t function yet, since we haven’t setup the payment processing function, but it is there.

Setting Up (or disabling) the Credit Card Form

Some payment gateways, such as Stripe, accept credit card details on the checkout page, and other gateways, such as PayPal, redirect the user to a secure site where the payment is processed. Easy Digital Downloads can easily support both of these.

The main difference between these two kinds of payment gateways is that one requires a credit card form on the site, and the other doesn’t.

By default, Easy Digital Downloads will output a credit card form that looks like this:

If your payment gateway accepts credit cards, then this form will likely work just fine for you, but if you would like to use your own custom form (as the Stripe gateway does), then there is a simple way to set it up.

When loading the checkout page, EDD will look to see if the following action is registered:

edd_{gateway ID}_cc_form

If the action is registered, then whatever function (for outputting HTML) is hooked to the action will be executed, otherwise the default credit card form is loaded instead.

To completely disable the credit card form, all you have to do is register the edd_{gateway ID}_cc_form action (with your gateway ID) and attach a blank function, or one that returns nothing. A sample function for disabling the credit card form is shown below:

function pw_edd_sample_gateway_cc_form() {
	// register the action to remove default CC form
	return;
}
add_action('edd_sample_gateway_cc_form', 'pw_edd_sample_gateway_cc_form');

With this action registered, the checkout form will now look like this:

Disabling the credit card forms is something you will usually do when creating a gateway that accepts payment through the merchant site, such as PayPal or Moneybookers.

Now what if you want to customize the credit card forms? You simply register the action as you did above and add HTML output to your function, like so:

// setup a custom CC form for Sample Gateway
function pw_edd_sample_gateway_cc_form() {
	ob_start(); ?>

/

	<!--?php
	echo ob_get_clean();
}
add_action('edd_sample_gateway_cc_form', 'pw_edd_sample_gateway_cc_form');
</pre-->

This is the exact HTML that the Stripe payment gateway uses.

Processing the Payment

When a purchase is made through a gateway, Easy Digital Downloads executes a gateway-specific function for processing the payment. The function that is executed is determined by a special hook, similar to the way the credit card form is outputted (or not).

function gateway_function_to_process_payment($purchase_data) {
	// payment processing happens here
}
add_action('edd_gateway_{gateway ID}', 'gateway_function_to_process_payment');

To setup the function that processes the purchase in your gateway, all you have to do is hook your function to this action: edd_gateway_{gateway ID}.

Inside of your hooked function, you can process the payment however you wish. Some gateways will redirect to the offsite merchant here, while others will use an API to process the payment without leaving the site.

The $purchase_data parameter contains all of the necessary information about the downloads being purchased. It also contains information about the buyer, such as email, user ID (if logged in), first name, and last name.

When processing the payment, there are a few things you need to take into account:

  • Is the plugin in Test mode?
  • Make sure you check for valid data in any credit card fields you have setup, and store the errors if there are any.
  • Setup and store the purchase data in EDD.
  • Process the payment or redirect to a merchant site.
  • Mark the payment as complete (if applicable).
  • Redirect back to checkout on error, or the thank you page on successful payment.

The first thing we do is check whether Easy Digital Downloads is being used in test mode. We do this with a simple conditional function:

/**********************************
* set transaction mode
**********************************/
 
if(edd_is_test_mode()) {
	// set test credentials here
} else {
	// set live credentials here
}

This conditional will allow you to properly setup your merchant API keys or redirect URLs. For example, in PayPal Standard, when the plugin is in test mode, the following URL is used:

https://www.sandbox.paypal.com/cgi-bin/webscr

But when in Live mode, this one is used:

https://www.paypal.com/cgi-bin/webscr

This makes it much easier for us to test our payment gateway to make sure it is working properly.

The next thing we do in our process purchase function is check for valid data. If your gateway accepts credit cards, then you need to make sure that the data entered is okay. You can do that easily like this:

// errors can be set like this
if(!isset($_POST['card_number'])) {
	// error code followed by error message
	edd_set_error('empty_card', __('You must enter a card number', 'edd'));
}

The edd_set_error(() function will store the error and display it on the checkout page.

After our data validation checks run, we do a quick test to see if any errors were recorded:

// check for any stored errors
$errors = edd_get_errors();
if(!$errors) {
	// no errors, so process the payment
} else {
	$fail = true; // errors were detected
}

If there are no errors detected, we move on to processing the payment, or redirecting to the off site merchant. If there are errors, then we set a flag which will cause the user to be redirected back to the purchase page.

Next, inside of the !$errors conditional, we need to retrieve the purchase summary. This is not required but is a good thing to do, as the summary contains basic information related to what items the user purchased.

$purchase_summary = edd_get_purchase_summary($purchase_data);

Remember, the $purchase_data is passed as a parameter to our payment processing function, and it contains all of the information about the purchase.

After the purchase summary is retrieved, we setup and store a pending purchase, which goes into the Payment History page. This particular step will very rarely differ between gateways, but, if for any reason, you can modify it if needed.

/**********************************
* setup the payment details
**********************************/
 
$payment = array( 
'price' =&gt; $purchase_data['price'], 
'date' =&gt; $purchase_data['date'], 
'user_email' =&gt; $purchase_data['user_email'],
'purchase_key' =&gt; $purchase_data['purchase_key'],
'currency' =&gt; $edd_options['currency'],
'downloads' =&gt; $purchase_data['downloads'],
'cart_details' =&gt; $purchase_data['cart_details'],
'user_info' =&gt; $purchase_data['user_info'],
'status' =&gt; 'pending'
);
 
// record the pending payment
$payment = edd_insert_payment($payment);

The edd_insert_payment() function will create the payment in Easy Digital Downloads, making it available in the Payment History. It will look like this:

Note that the payment status is “pending”. We only want to mark the payment as “complete” once we have a confirmed payment. Once the payment is marked as “complete”, the purchase receipt with download links is sent out, as is the admin sale notification email.

At this point we now either redirect to the off site merchant or process the payment onsite with a merchant API. Since the method for processing the payment itself can differ so much, I’m leaving that part up to you. If you are already looking to create a payment gateway for a particular merchant, then you probably are at least a little aware of how it works, but feel free to ask if you need help.

Once you have confirmed that the merchant payment was complete, you will update the status of the payment and send the buyer to the success page:

$merchant_payment_confirmed = false;
 
/**********************************
* Process the credit card here.
* If not using a credit card
* then redirect to merchant
* and verify payment with an IPN
**********************************/
 
// if the merchant payment is complete, set a flag
$merchant_payment_confirmed = true;		
 
if($merchant_payment_confirmed) { // this is used when processing credit cards on site
 
	// once a transaction is successful, set the purchase to complete
	edd_update_payment_status($payment, 'complete');
 
	// go to the success page			
	edd_send_to_success_page();
 
} else {
	$fail = true; // payment wasn't recorded
}

There’s just one part left, and that is redirecting back to the checkout page if there were any errors:

if( $fail !== false ) {
	// if errors are present, send the user back to the purchase page so they can be corrected
	edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
}

The complete payment processing function looks like this:

// processes the payment
function pw_edd_process_payment($purchase_data) {
 
	global $edd_options;
 
	/**********************************
	* set transaction mode
	**********************************/
 
	if(edd_is_test_mode()) {
		// set test credentials here
	} else {
		// set live credentials here
	}
 
	/**********************************
	* check for errors here
	**********************************/
 
	/*
	// errors can be set like this
	if(!isset($_POST['card_number'])) {
		// error code followed by error message
		edd_set_error('empty_card', __('You must enter a card number', 'edd'));
	}
	*/
 
	// check for any stored errors
	$errors = edd_get_errors();
	if(!$errors) {
 
		$purchase_summary = edd_get_purchase_summary($purchase_data);
 
		/**********************************
		* setup the payment details
		**********************************/
 
		$payment = array( 
			'price' =&gt; $purchase_data['price'], 
			'date' =&gt; $purchase_data['date'], 
			'user_email' =&gt; $purchase_data['user_email'],
			'purchase_key' =&gt; $purchase_data['purchase_key'],
			'currency' =&gt; $edd_options['currency'],
			'downloads' =&gt; $purchase_data['downloads'],
			'cart_details' =&gt; $purchase_data['cart_details'],
			'user_info' =&gt; $purchase_data['user_info'],
			'status' =&gt; 'pending'
		);
 
		// record the pending payment
		$payment = edd_insert_payment($payment);
 
		$merchant_payment_confirmed = false;
 
		/**********************************
		* Process the credit card here.
		* If not using a credit card
		* then redirect to merchant
		* and verify payment with an IPN
		**********************************/
 
		// if the merchant payment is complete, set a flag
		$merchant_payment_confirmed = true;		
 
		if($merchant_payment_confirmed) { // this is used when processing credit cards on site
 
			// once a transaction is successful, set the purchase to complete
			edd_update_payment_status($payment, 'complete');
 
			// go to the success page			
			edd_send_to_success_page();
 
		} else {
			$fail = true; // payment wasn't recorded
		}
 
	} else {
		$fail = true; // errors were detected
	}
 
	if( $fail !== false ) {
		// if errors are present, send the user back to the purchase page so they can be corrected
		edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
	}
}
add_action('edd_gateway_sample_gateway', 'pw_edd_process_payment');

Setting Up the Gateway Settings

In order for most payment gateways to function, you need to have the ability to store API keys or email addresses that are connected to the merchant account. Luckily, Easy Digital Downloads provides a very simple way of doing this.

All we have to do is setup an array of fields and pass it through a filter. When creating your settings, you have a variety of field types to choose from:

  • header – A section header. This just outputs a label.
  • checkbox – a simple check box field.
  • multicheck – a list of check boxes.
  • text – a simple text input field.
  • select – a drop down menu field.
  • rich_editor – a tinymce text editor field.

For our sample gateway, we are going to register three new setting fields: one for a section header, one for a live API key, and one for a test API key.

The function for registering the settings looks like this:

// adds the settings to the Payment Gateways section
function pw_edd_add_settings($settings) {
 
	$sample_gateway_settings = array(
		array(
			'id' =&gt; 'sample_gateway_settings',
			'name' =&gt; '<strong>' . __('Sample Gateway Settings', 'pw_edd') . '</strong>',
			'desc' =&gt; __('Configure the gateway settings', 'pw_edd'),
			'type' =&gt; 'header'
		),
		array(
			'id' =&gt; 'live_api_key',
			'name' =&gt; __('Live API Key', 'pw_edd'),
			'desc' =&gt; __('Enter your live API key, found in your gateway Account Settins', 'pw_edd'),
			'type' =&gt; 'text',
			'size' =&gt; 'regular'
		),
		array(
			'id' =&gt; 'test_api_key',
			'name' =&gt; __('Test API Key', 'pw_edd'),
			'desc' =&gt; __('Enter your test API key, found in your Stripe Account Settins', 'pw_edd'),
			'type' =&gt; 'text',
			'size' =&gt; 'regular'
		)
	);
 
	return array_merge($settings, $sample_gateway_settings);	
}
add_filter('edd_settings_gateways', 'pw_edd_add_settings');

$sample_gateway_settings is a multidimensional array (a separate array for each field). After the array of new fields is set up, we return the array through the array_merge() function, which combines the $settings (the existing plugin settings) with our new fields.

Our settings will look like this, in the Payment Gateways section:

Final Gateway Code

The final code for our add-on gateway looks like this:

<!--?php
/*
Plugin Name: Easy Digital Downloads - Sample Gateway
Plugin URL: http://easydigitaldownloads.com/extension/sample-gateway
Description: A sample gateway for Easy Digital Downloads
Version: 1.0
Author: Pippin Williamson
Author URI: https://pippinsplugins.com
Contributors: mordauk
*/
 
 
// registers the gateway
function pw_edd_register_gateway($gateways) {
	$gateways['sample_gateway'] = array('admin_label' =--> 'Sample Gateway', 'checkout_label' =&gt; __('Sample Gateway', 'pw_edd'));
	return $gateways;
}
add_filter('edd_payment_gateways', 'pw_edd_register_gateway');
 
function pw_edd_sample_gateway_cc_form() {
	// register the action to remove default CC form
	return;
}
add_action('edd_sample_gateway_cc_form', 'pw_edd_sample_gateway_cc_form');
 
// processes the payment
function pw_edd_process_payment($purchase_data) {
 
	global $edd_options;
 
	/**********************************
	* set transaction mode
	**********************************/
 
	if(edd_is_test_mode()) {
		// set test credentials here
	} else {
		// set live credentials here
	}
 
	/**********************************
	* check for errors here
	**********************************/
 
	/*
	// errors can be set like this
	if(!isset($_POST['card_number'])) {
		// error code followed by error message
		edd_set_error('empty_card', __('You must enter a card number', 'edd'));
	}
	*/
 
	// check for any stored errors
	$errors = edd_get_errors();
	if(!$errors) {
 
		$purchase_summary = edd_get_purchase_summary($purchase_data);
 
		/**********************************
		* setup the payment details
		**********************************/
 
		$payment = array( 
			'price' =&gt; $purchase_data['price'], 
			'date' =&gt; $purchase_data['date'], 
			'user_email' =&gt; $purchase_data['user_email'],
			'purchase_key' =&gt; $purchase_data['purchase_key'],
			'currency' =&gt; $edd_options['currency'],
			'downloads' =&gt; $purchase_data['downloads'],
			'cart_details' =&gt; $purchase_data['cart_details'],
			'user_info' =&gt; $purchase_data['user_info'],
			'status' =&gt; 'pending'
		);
 
		// record the pending payment
		$payment = edd_insert_payment($payment);
 
		$merchant_payment_confirmed = false;
 
		/**********************************
		* Process the credit card here.
		* If not using a credit card
		* then redirect to merchant
		* and verify payment with an IPN
		**********************************/
 
		// if the merchant payment is complete, set a flag
		$merchant_payment_confirmed = true;		
 
		if($merchant_payment_confirmed) { // this is used when processing credit cards on site
 
			// once a transaction is successful, set the purchase to complete
			edd_update_payment_status($payment, 'complete');
 
			// go to the success page			
			edd_send_to_success_page();
 
		} else {
			$fail = true; // payment wasn't recorded
		}
 
	} else {
		$fail = true; // errors were detected
	}
 
	if( $fail !== false ) {
		// if errors are present, send the user back to the purchase page so they can be corrected
		edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
	}
}
add_action('edd_gateway_sample_gateway', 'pw_edd_process_payment');
 
// adds the settings to the Payment Gateways section
function pw_edd_add_settings($settings) {
 
	$sample_gateway_settings = array(
		array(
			'id' =&gt; 'sample_gateway_settings',
			'name' =&gt; '<strong>' . __('Sample Gateway Settings', 'pw_edd') . '</strong>',
			'desc' =&gt; __('Configure the gateway settings', 'pw_edd'),
			'type' =&gt; 'header'
		),
		array(
			'id' =&gt; 'live_api_key',
			'name' =&gt; __('Live API Key', 'pw_edd'),
			'desc' =&gt; __('Enter your live API key, found in your gateway Account Settins', 'pw_edd'),
			'type' =&gt; 'text',
			'size' =&gt; 'regular'
		),
		array(
			'id' =&gt; 'test_api_key',
			'name' =&gt; __('Test API Key', 'pw_edd'),
			'desc' =&gt; __('Enter your test API key, found in your Stripe Account Settins', 'pw_edd'),
			'type' =&gt; 'text',
			'size' =&gt; 'regular'
		)
	);
 
	return array_merge($settings, $sample_gateway_settings);	
}
add_filter('edd_settings_gateways', 'pw_edd_add_settings');

Concluding Notes

Overall, the payment gateway process for Easy Digital Downloads is pretty simple. It may seem complex if you’re not familiar with this kind of system, but once you work with it a little, you’ll find it quite simple.

One very important thing to take note of is that when you are working with an offsite payment system, you will likely have to setup a “listener” function that will help you detect when payments are confirmed. If you are building such a system, then I would encourage you to look at the source code for the PayPal Standard gateway for a sample system.

Download the Sample Gateway

The complete source code for the sample gateway can be download below.

[download id=”45″ format=”1″]

  1. Daysleeper

    Thanks for this. Much appreciated. It makes a great demonstration of creating an add-on for digital downloads.

    • Pippin

      Thanks. This is just one example of the add-ons you can create for EDD. I will be publishing many more similar tutorials for other aspects of Easy Digital Downloads.

  2. papa

    I am using the version

    i dont have the manual payment version. 1.2.2

    how can i get this option enabled again?

    thanks for your reply.

    i am using offline payment normally… with able to verify payment, and enabled download for user…

    • Pippin

      This is not the place to ask this question. Please post it in the Easy Digital Downloads support forum.

  3. Arlene

    Hi,
    Thank you for this plugin!

    The only problem that I encountered in the customization are in the following:
    1. purchase_data <= 0 automatically renders to manual gateway even with the customized already set.
    2. if the $_GET payment-mode is set but still with the cart amount == 0, it will still use the manual gateway.
    3. if the $_GET payment-mode is set, there's no way to have this variable set in the Checkout Page field chosen in General Settings

    Cart amount == 0 is for freebies.
    Maybe a different approach is to have the default 'manual' configurable to the preferred gateway.

    • Pippin

      1. Yes, that is the intended behavior. It emulates a “free” purchase and bypasses the funds transfer.
      2. That is also intended behavior for the same reason.
      3. This parameter is set automatically if there is an error and the page needs to reload, or when the payment gateway is first selected.

  4. peter

    Hi, Can I set a new order always ‘pending’ ?

    • Pippin

      Yes, when you do edd_insert_payment(), set “status” => “pending” in the arguments.

    • peter

      when I paste this code i have result how ‘test gateway’… but I want new order always pending;
      I mean… add to cart – fill out the form – custom finally page; and admin must change order status;
      is it possible ?

    • Pippin

      Yes, if you do exactly as I said, that is the default behavior.

    • peter

      when I fill out the form I get mail with info about download file (automatic order status complete)

    • Pippin

      Ok show me your complete gateway code. Please paste it to snippi.com and share the link.

    • Pippin

      This is the line that completes the purchase:

      edd_update_payment_status($payment, 'complete');

      Remove that and it will remain pending.

    • peter

      thank you for help 🙂

  5. Akhilesh

    Sir i have a payment gateway code … this is first time i m doing this….
    Please help me to make it work , i am in need very badly…
    Can i send u the code???

    Please make a help , this is gonna decide my future
    :'(

  6. Akhilesh

    I am doing payment gateway integration for very first time…

    This is a task which will decide my future, is there any one who can help me plzzzzz 🙁

    I have the code and i just don’t know wat to do with it

    • Pippin

      I need more details than that to help you out.

      What payment system are you working with?

    • Pippin

      Not that I’m aware of!

    • Pippin

      No, sorry.

  7. Punkrocker

    Where does this code go? I created a file and placed it to /includes/gateways/ but it wont show in the ‘Payment Gateway’ admin panel.

    I downloaded the sample and placed in the same directory and that doesn’t show either. Where am I going wrong?

  8. GoPeer

    I would like to integrate mobile money payment into my site, I have an API to the effect. How do i get it to work? Im a newpie.

    • Pippin

      Which payment processor are you wanting to use?

  9. vishal

    hi does this method work with restrict content pro?

    • Pippin

      No. The process is similar but not the same.

  10. Ronald Caetano

    You explain how to configure a custom CC form. In my case I would have other fields like mobile number, deposit number, deposit date, and use the values ​​of these fields in the order detail. How do I?

  11. Mawande

    Hi Pippin

    I’m about to watch this video now, but I thought I’d ask this anyway. Say there is another payment system you want to add. What processes would I need to get through?

    • Pippin

      Are you asking about getting the payment gateway listed on the Easy Digital Downloads site?

    • Mawande

      Hey Pippin

      I guess it could also be a third party extension. It would save me the hassle of installing it myself.

      But I don’t think you have these particular gateways on your extensive extensions list. PayU and PayGate, both South African systems that offer debit card options for payments. Which are vital here as many people don’t utilise credit cards and PayPal doesn’t quite work here.

    • Pippin

      We do not have either of those extensions but I would love to see them built.

    • Mawande

      I’ll be choosing one of the two. How can we integrate them (manually if need be) into Easy Digital?

    • Sam

      You’d have to follow this tutorial I suppose. I’ve done plugins for some South African gateways, but it’s been a while. They weren’t for PayGate though.

    • Pippin

      Yes, please follow this tutorial.

  12. Nathz

    Hello Pippin..
    I want make payment at my site become like this;
    buyer checkout ==> paypal ==> after succes back to my site ==> buyer can download and status automatic change to succes without need admin to change it by manual.
    I see many tutorial, but that make me confused is menu Payment Gateways at my site is diferen with the tutorial. I can find paypal api form for put my paypal api. This is my Payment Gateways http://prntscr.com/2qs5y1. There is I need install another Add-Ons ?
    Thanks

  13. Nathz

    thanks, its work ! 🙂

    Another question, I want to custom the purchase receipt style. I try to copy all script at template shortcode-receipt.php than paste to my purchase confirmation page so I can change the css class and ID. But why it not work? the page become blank. I do the same method at download history and purchase history, and it working fine. Can you suggest me another way to custom the purchase receipt style?

    • Pippin

      Sounds like you probably created a syntax error. Turn WP_DEBUG on and then see what the error message is.

    • Nathz

      Notice: Undefined index: cart_details in G:\WEBSITES\wp-content\plugins\easy-digital-downloads\includes\payments\functions.php on line 703.

      how to fix it?

    • Nathz

      I try fix it by change the script
      $cart_details = (array) maybe_unserialize( $payment_meta[‘cart_details’] );
      to
      $cart_details = (array) maybe_unserialize( isset($payment_meta[‘cart_details’]));

      than error message is fix, but my purchase confirmation page only show Payment Status: Complete, and another detail is not show 🙁

    • Pippin

      Use edd_get_payment_meta_cart_details( $payment_id ) instead.

    • Nathz

      Ohh..Still error 🙁

      Notice: Undefined variable: payment_id in G:\WEBSITES\page\page-member-purchase-confirmation.php on line 23

    • Pippin

      Paste your complete code to paste.bin then share the link and I can take a look at it.

    • Pippin

      Is there a reason you’re creating a custom purchase confirmation page template instead of just using the standard [edd_receipt] short code?

    • nathz ryuzaki

      Because I want to change the CSS id and class, so I can change the css style as my wish.

    • Nathz

      thanks, I already fix it 🙂
      about this tutorial, I try to modif this $sample_gateway_settings become like this,

      function pw_edd_add_settings( $settings ) {
      $manual_payment_settings = array(
      array(
      ‘id’ => ‘manual_payment_settings’,
      ‘name’ => ‘‘ . __( ‘Manual Payment Settings’, ‘pw_edd’ ) . ‘‘,
      ‘desc’ => __( ‘Configure the gateway settings’, ‘pw_edd’ ),
      ‘type’ => ‘header’
      ),
      array(
      ‘id’ => ‘kurs’,
      ‘name’ => __( ‘Kurs Dollar’, ‘pw_edd’ ),
      ‘desc’ => __( ‘Input kurs dollar in IDR’, ‘pw_edd’ ),
      ‘type’ => ‘text’,
      ‘size’ => ‘regular’
      )
      );
      return array_merge( $settings, $manual_payment_settings );
      }

      than, how I can show the setting value to page that i want ?

    • Pippin

      Which page do you want to show it on?

    • Nathz

      I already fix it by make function like this

      thanks 😀

    • Pippin

      Great!

  14. Nathz

    function edd_kurs() {
    global $edd_options;

    $options = $edd_options[‘kurs’];
    return apply_filters( ‘edd_kurs’, $options );
    }

  15. Shishir Rawat

    Firstly Thnx a Lot for ur patience in replying to different comments..
    My question is :
    A. how are extensions on payment gateways made.
    B. Is the above process used for all.

    Kindly point us to any documentation that provides details on how to create and payment gateway Extension.

    • Pippin

      A. The settings fields?

  16. Dewi

    Hello sir,,thanks for your tutorial..It really helps me for my job..i use another gateway..it’s flow just like Paypal,,using curl (if i’m not wrong) and redirect back to our website and changed status to success..but how can i make it by myself using custom payment gateway?? here some scripts from the payment processor.. https://ipaymu.com/cara-integrasi-webstore-tingkat-lanjut#highlighter_301061 (sorry,,it’s in Bahasa)

    and can i create additional variable such as id transaction and session id in edd_insert_payment??

    thanks for your help.. 🙂

    • Pippin

      Can you be a bit more specific? Your question is really broad.

    • Dewi

      i don’t really understand about using IPN for verifying payment..how to use that??

      and my next question is about storing another transaction detail..
      $payment = array(
      ‘price’ => $purchase_data[‘price’],
      ‘date’ => $purchase_data[‘date’],
      ‘user_email’ => $purchase_data[‘user_email’],
      ‘purchase_key’ => $purchase_data[‘purchase_key’],
      ‘currency’ => $edd_options[‘currency’],
      ‘downloads’ => $purchase_data[‘downloads’],
      ‘cart_details’ => $purchase_data[‘cart_details’],
      ‘user_info’ => $purchase_data[‘user_info’],
      ‘status’ => ‘pending’
      );
      can i store id transaction and session id that i get from merchant?? i mean,,is it possible for me to add
      ‘id_transaction’ => 14930,
      ‘session_id’ => d9us673ihfy79d
      in $payment?? or do i have to declare something or what??

      thank you for your help.. 🙂

  17. Dane

    I want to create a payment gateway plugin for PayFast.co.za from South Africa. Do you know the basic information I need to create it.

    Thanks,
    Dane

    • Dane

      Hi Pippin,

      Thank you for your response. I have checked those links out, but struggling to add these infor to your info on blog. Keep on getting errors.

      This is why I am asking the minimum information I need for the plugin to work. What to add and what to take out.

      Thanks,

    • Dane

      Going to start all over again.

    • Pippin

      What are the errors you’re encountering?

    • Dane

      If I create the plugin in with the code provided above and add their live and test information. The plugin seems to work but when I place an order it generates the email but it does not redirect me to the payfast website. So I am restarting from scratch again…. Any advice?

    • Pippin

      Did you modify any of the code at all? This is meant as a starting point for developers, not as a ready-to-go solution to using any payment provider available.

  18. Dane

    Hi Pippin,

    i managed to get this started and working. Just one problem… My checkout/?payment-mode=payfast redirect to a blank page. Any ideas what this could be?

    Thanks,

    • Pippin

      Could you show me the complete code please? You can post it to pastebin.com and then share the link.

    • Pippin

      That looks fine. Could you enable WP_DEBUG and see if it shows an error then?

    • Dane

      Hi Pippin,

      I defined it as follows….

      function edd_get_payfast_redirect( $ssl_check = false ) {
      global $edd_options;
      if ( is_ssl() || ! $ssl_check ) {

      Now I get the following error… can’t seem to find the error in it…

      Parse error: syntax error, unexpected T_ELSE in wp-content/plugins/edd-payfast/edd-payfast.php on line 304

      Thanks for your help so far.

    • Pippin

      Send me an updated copy of the code.

    • Akenzoo

      code posted

    • Pippin

      Part of the problem is that your function edd_get_payfast_redirect() function is defined inside of another function. You should separate it out into it’s own function an then just call it.

  19. Dane

    I did enable WP_DEBUG and I got an error.

  20. Dane

    Notice: wp_register_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.) in wp-includes/functions.php on line 3245

    Notice: wp_register_style was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.) in wp-includes/functions.php on line 3245

    • Pippin

      Try deactivating all other plugins to see if the error goes away.

    • Dane

      Hi Pippin,

      I deactivated the one plugin that caused the error above. New error now is…

      Notice: Undefined variable: ssl_check in /wp-content/plugins/edd-payfast/edd-payfast.php on line 247

      Thanks,

    • Pippin

      That’s caused by this in your code: if ( is_ssl() || ! $ssl_check ) {

      You need to defined the $ssl_check variable.

  21. Kevin

    Is this process capable of producing a gateway for ccbill? Thanks for the help.

    • Pippin

      It is definitely possible. This is the same general process used for all payment providers.

  22. Kevin

    Hello Pippin,
    I’m really interested in creating a payment gateway for ccbill. Is this possible? Thanks for the help.

    Kevin

  23. Akenzoo

    Hi,

    I am developing a payment gateway plugin and my problem is how to update order after the payment gateway redirect back to my site. My order are still showing as pending after successful payment.

    • Pippin

      It varies for each payment processor. What payment processor are you using?

    • Akenzoo

      It is a local payment gateway called firsteconnect. After payment it redirected back to my success page. I will to query the payment gateway and update order . this is a sample code send to me.

      PHP Transaction Status Sample

      orderID =$_REQUEST[‘OrderID’]; //getting the order id from the query string
      $request->merchantID = “*****”; //replace ***** with your own merchant id

      $client = new SoapClient(‘https://firsteconnect.firstbanknigeria.com/webservice/transactionstatuscheck.svc?wsdl’);

      $result = $client->__call(“GetTransactionDetails”, array($request)); //calling the FirsteConnect transaction status inquiry method

      $theResponse = $result->GetTransactionDetailsResult;

      //the variable: $theResponse contains a string (format can be found in integration guide).
      //The status of the transaction can be gotten with orderID = $_REQUEST[‘OrderID’] can be gotten by processing the string in $theResponse
      echo $theResponse;

      if (isset($theResponse) && $theResponse != ”) {

      } else {

      }

      ?>

  24. Directory

    Hello, i want to ask you if you can create one payment gateway for me and how much will cost me

    I need one of 2 of them or both

    Paysafecard
    Ukash

    Please contact me at the entered email

  25. Ogbonna

    Hi Pippin,
    The code is nice, i am actually new to php…
    I was wondering if you have the sample code for a gateway that redirects off the site, and comes back when its successful.

    Thanks.

  26. Torsten

    Hi Pippin, I actually want to charge nothing for the downloads, but need some other core-functions of EDD. How can I actually disable any payment?

Comments are closed.