PHP code example of wp-pay / core

1. Go to this page and download the library: Download wp-pay/core library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wp-pay / core example snippets


\add_filter(
	'pronamic_payment_gateway_configuration_id',
	/**
	 * Filter the payment gateway configuration ID to use specific 
	 * gateways for certain WooCommerce billing countries.
	 *
	 * @param int     $configuration_id Gateway configuration ID.
	 * @param Payment $payment          The payment resource data.
	 * @return int Gateway configuration ID.
	 */
	function( $configuration_id, $payment ) {
		if ( 'woocommerce' !== $payment->get_source() ) {
			return $configuration_id;
		}

		$billing_address = $payment->get_billing_address();

		if ( null === $billing_address ) {
			return $configuration_id;
		}

		$id = $configuration_id;

		switch ( $billing_address->get_country_code() ) {
			case 'US':
				$id = \get_option( 'custom_us_gateway_configuration_id', $id );
				break;
			case 'AU':
				$id = \get_option( 'custom_au_gateway_configuration_id', $id );
				break;
		}

		if ( 'pronamic_gateway' === \get_post_type( $id ) && 'publish' === \get_post_status( $id ) ) {
			$configuration_id = $id;
		}

		return $configuration_id;
	},
	10,
	2
);

\add_filter(
	'pronamic_gateway_configuration_display_value',
	function( $display_value, $post_id ) {
		return \get_post_meta( $post_id, '_pronamic_gateway_display_value', true );
	},
	10,
	2
);

\add_filter(
	'pronamic_gateway_configuration_display_value_payvision',
	function( $display_value, $post_id ) {
		return \get_post_meta( $post_id, '_pronamic_gateway_payvision_business_id', true );
	},
	10,
	2
);