I was developed my custom offsite payment gateway for my GiveWP. I need to update the donation status in my WP site according the result from my Payment Gateway status, how can I do this ? I have a little bit problem with notify_url, can I use notify_url to update my donation status ?
Thanks for your help
]]>I am currently using WordPress version 6.4.2 and WooCommerce version 8.3.1 in previous version my custom payment gateway plugin is working but when I updated the WP and WooCommerce it is no longer visible in the checkout page. It say’s, “There are no payment methods available. This may be an error on our side. Please contact us if you need any help placing your order.” in the Payment Options tab.
I have installed and activated the plugin and enabled it also. There is no error and no warning even when I have set WP to debug mode. I have tried this in multiple server’s still I am facing the same issue.
Thank you in advance.
]]>Thanks in advance. Regards,
]]><?php
/**
* Process CCAvenue checkout submission.
*
* @param array $posted_data List of posted data.
*
* @since 1.0.0
* @access public
*
* @return void
*/
function give_process_ccavenue_donation($posted_data) {
// Make sure we don't have any left over errors present.
give_clear_errors();
// Any errors?
$errors = give_get_errors();
// No errors, proceed.
if ( ! $errors ) {
$form_id = intval( $posted_data['post_data']['give-form-id'] );
$price_id = ! empty( $posted_data['post_data']['give-price-id'] ) ? $posted_data['post_data']['give-price-id'] : 0;
$donation_amount = ! empty( $posted_data['price'] ) ? $posted_data['price'] : 0;
// Setup the payment details.
$donation_data = array(
'price' => $donation_amount,
'give_form_title' => $posted_data['post_data']['give-form-title'],
'give_form_id' => $form_id,
'give_price_id' => $price_id,
'date' => $posted_data['date'],
'user_email' => $posted_data['user_email'],
'purchase_key' => $posted_data['purchase_key'],
'currency' => 'INR',
'user_info' => $posted_data['user_info'],
'status' => 'pending',
'gateway' => 'ccavenue',
);
// Record the pending donation.
$donation_id = give_insert_payment($donation_data);
if (!$donation_id) {
// Record Gateway Error as Pending Donation in Give is not created.
give_record_gateway_error(
__( 'CCAvenue Error', 'ccavenue-for-give' ),
sprintf(
/* translators: %s Exception error message. */
__( 'Unable to create a pending donation with Give.', 'ccavenue-for-give' )
)
);
// Send user back to checkout.
give_send_back_to_checkout( '?payment-mode=ccavenue' );
return;
}
} else {
// Send user back to checkout.
give_send_back_to_checkout( '?payment-mode=ccavenue' );
} // End if().
// Do the actual payment processing using the custom payment gateway API. To access the GiveWP
// settings, use give_get_option() as a reference, this pulls the API key entered above: give_get_option('insta_for_give_instamojo_api_key')
$merchant_id = give_get_option('ccavenue_merchant_id');
$access_code = give_get_option('ccavenue_access_code');
$working_key = give_get_option('ccavenue_working_key');
$order_id = rand (100000,999999);
$redirect_url = 'https://localhost/wordpress/donation-confirmation';
$cancel_url = 'https://localhost/wordpress/donation-failed/';
$tx_id = rand (1000000,9999999);
$url = "https://test.ccavenue.com/transaction/transaction.do?command=initiateTransaction";
$merchant_data_arr = array(
'merchant_id' => $merchant_id,
'order_id' => $order_id,
'language' => 'EN',
'amount' => $donation_amount,
'currency' => 'INR',
'redirect_url' => $redirect_url,
'cancel_url' => $cancel_url,
'tid' => $tx_id,
);
foreach ($merchant_data_arr as $key => $value){
$merchant_data.=$key.'='.$value.'&';
}
// Method for encrypting the data.
$encrypted_data = encrypt($merchant_data, $working_key);
redirect_to_gateway($url, $encrypted_data, $access_code);
}
/*
* @param1 : Plain String
* @param2 : Working key provided by CCAvenue
* @return : Decrypted String
*/
function encrypt($plainText,$key)
{
$key = hextobin(md5($key));
$initVector = pack("C*", 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
$openMode = openssl_encrypt($plainText, 'AES-128-CBC', $key, OPENSSL_RAW_DATA, $initVector);
$encryptedText = bin2hex($openMode);
return $encryptedText;
}
/*
* @param1 : Encrypted String
* @param2 : Working key provided by CCAvenue
* @return : Plain String
*/
function decrypt($encryptedText,$key)
{
$key = hextobin(md5($key));
$initVector = pack("C*", 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
$encryptedText = hextobin($encryptedText);
$decryptedText = openssl_decrypt($encryptedText, 'AES-128-CBC', $key, OPENSSL_RAW_DATA, $initVector);
return $decryptedText;
}
function hextobin($hexString)
{
$length = strlen($hexString);
$binString="";
$count=0;
while($count<$length)
{
$subString =substr($hexString,$count,2);
$packedString = pack("H*",$subString);
if ($count==0) {
$binString=$packedString;
}
else {
$binString.=$packedString;
}
$count+=2;
}
return $binString;
}
function redirect_to_gateway($url, $encrypted_data, $access_code) {
echo '<form method="post" name="redirect" action="'.$url.'">';
echo '<input type="hidden" name="encRequest" value="' . $encrypted_data . '">';
echo '<input type="hidden" name="access_code" value="' . $access_code . '">';
echo '</form>';
echo '<script type="text/javascript">document.redirect.submit();</script>';
wp_redirect($url);
}
add_action( 'give_gateway_ccavenue', 'give_process_ccavenue_donation' );
]]>I am trying to add a custom payment Gateway [Braintree] to the marketplace.
I go from Settings> Payment Setting and although the plugin of Braintree is installed and appears as payment method on Woocommerce it doesn’t sync with Marketplace.
I ve found a tip here: https://wclovers.com/knowledgebase/wcfm-marketplace-custom-payment-gateway-developers-guide/
but I don’t know in which php file to put it and how exactly in order to achieve it.
Any ideas? Thanks a lot
]]>and this one:
plugins
->woocommerce
–>gateways
—>cheque
Neither one works. Any help?
]]>