// après avoir récupéré $batches = $pobj->get_payouts(['payout_status'=>'unprocessed']); foreach( $batches as $row ){ // 1) ID interne $record_id = is_array($row) ? $row['ID'] : $row->ID; // 2) Charger les détails complets if( method_exists($pobj, 'get_payout') ){ $details = $pobj->get_payout( $record_id ); } else { // selon la version de YITH la méthode peut s’appeler getPayoutById, etc. $details = $pobj->get_payouts(['payout_id'=>$record_id])[0]; } // 3) Extraire l’ID PayPal $paypalBatchId = $details->batch_header->sender_batch_header->sender_batch_id ?? $details->batch_header->payout_batch_id ?? null; if( ! $paypalBatchId ){ throw new Exception("Impossible de lire le PayPal Batch ID pour le record {$record_id}"); } // 4) Exécuter le payout // Méthode YITH dédiée — souvent pay_payouts ou process_payouts if( method_exists($pobj, 'pay_payouts') ){ $resp = $pobj->pay_payouts( $paypalBatchId ); } elseif( method_exists($pobj, 'process_payouts') ){ $resp = $pobj->process_payouts( $paypalBatchId ); } else { throw new Exception("Pas de méthode pay/process détectée dans YITH"); } // 5) Vérifier la réponse et marquer comme “sent” si OK if( ! is_wp_error($resp) && $resp ){ update_post_meta( $record_id, '_ywppp_payout_status', 'sent' ); } else { throw new Exception("Échec du payout pour {$paypalBatchId}"); } } Produits Archive - Page 970 sur 1132 - La Librairie Antique

Enter your keyword

Notre Catalogue de Livres Anciens

La Librairie Antique

GRATUIT
VOIR